Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Webservice .net operations

    Hi,
    i have the following code:

    [CODE]
    isc.Menu.create({
    ID: "usersGridContextMenu",
    autoDraw: false,
    showShadow: true,
    shadowDepth: 10,
    data: [
    {title: "Add New User", icon: "icons/16/add.png", click:"usersListGrid.startEditingNew()"},
    {title: "Remove Task", icon: "icons/16/remove.png", click:"usersListGrid.removeSelectedData()"}
    ]
    });

    isc.ListGrid.create({
    ID: "usersListGrid",
    width:"100%",
    alternateRecordStyles:true,
    canEdit:true,
    modalEditing: true,
    autoSaveEdits:true,
    recordContextClick:"return usersGridContextMenu.showContextMenu()",
    showFilterEditor:true
    });

    function loadWSDLCallback(service) {
    var usersDS = isc.DataSource.create({
    ID: "usersDS",
    dataFormat:"xml",
    serviceNamespace: service.serviceNamespace,
    recordXPath:"//Users",
    operationBindings : [
    {operationType: "fetch", wsOperation:"GetUsers"},
    {operationType:"add", wsOperation:"AddUser"},
    {operationType:"update", wsOperation:"UpdateUser"},
    {operationType:"remove", wsOperation:"DeleteUser"}
    ],
    fields:[
    { name:"userId", canEdit: false, primaryKey: true },
    { name:"userGroup" },
    { name:"userFirstname" },
    { name:"userLastname" }
    ]
    });

    usersListGrid.setDataSource(usersDS);
    usersListGrid.fetchData();
    }

    isc.HLayout.create({
    ID:"pageLayout",
    width:"100%",
    height:"100%",
    members:[
    isc.SectionStack.create({
    ID:"SectionLayout",
    backgroundColor:"white",
    visibilityMode:"multiple",
    showResizeBar:true,
    animateSections:true,
    sections:[
    {title:"Users List", autoShow:true, items:[usersListGrid]}
    ]
    })
    ]
    });

    isc.XMLTools.loadWSDL("Service.asmx?WSDL", "loadWSDLCallback(service)");
    [CODE]

    that consumes a .net webservice, i have the add operation working when i insert a new row, but the remove and update operations wont work, i dont know what would be the reason, why the client can communicate with the webservice in the "add" case and not when deleting or updating. i tested the operations without smartclient and they all work fine.

    thanks

    #2
    Hi again
    when i add the following call in my code:

    service.callOperation("DeleteUser", {userId: 12, userGroup: 3, userFirstname: "Sarah", userLastname: "Shrek"});

    the row with the specified values get deleted in the database

    Comment


      #3
      If you look in the RPC tab in the Developer Console, do the messages sent in the working vs non-working case differ?

      Comment


        #4
        HI,

        when i do update i get this in the response section in the RPC:

        Code:
        <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---&gt; System.InvalidOperationException: There is an error in XML document (7, 36). ---&gt; System.FormatException: Input string was not in a correct format.
           at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
           at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
           at System.Xml.XmlConvert.ToInt32(String s)
           at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read8_UpdateUser()
           at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer12.Deserialize(XmlSerializationReader reader)
           at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
           --- End of inner exception stack trace ---
           at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
           at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
           at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
           --- End of inner exception stack trace ---
           at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
           at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
        as well as for the delete:

        Code:
        <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---&gt; System.InvalidOperationException: There is an error in XML document (6, 30). ---&gt; System.FormatException: Input string was not in a correct format.
           at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
           at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
           at System.Xml.XmlConvert.ToInt32(String s)
           at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read10_DeleteUser()
           at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer16.Deserialize(XmlSerializationReader reader)
           at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
           --- End of inner exception stack trace ---
           at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
           at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
           at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
           --- End of inner exception stack trace ---
           at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
           at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>

        Comment


          #5
          Right, so how about the request in the working and non-working cases?

          Comment


            #6
            in the request for the delete for example it outputs this:

            Code:
            {
                actionURL:"http://localhost:1452/TimeSheet/Service.asmx", 
                showPrompt:true, 
                prompt:"Deleting record(s)...", 
                transport:"xmlHttpRequest", 
                useSimpleHttp:true, 
                promptStyle:"dialog", 
                httpMethod:"POST", 
                contentType:"text/xml", 
                httpHeaders:{
                    SOAPAction:"http://localhost/TimeSheet/DeleteUser"
                }, 
                sendNoQueue:true, 
                callback:{
                    target:null, 
                    methodName:"$37c"
                }, 
                serverOutputAsString:true, 
                data:"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' \n          xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n          xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Header></soap:Header><soap:Body>\r<ns0:DeleteUser \n         xmlns:ns0=\"http://localhost/TimeSheet/\">\r    <ns0:userId>17</ns0:userId>\r    <ns0:userGroup>2</ns0:userGroup>\r    <ns0:userFirstname>Mike</ns0:userFirstname>\r    <ns0:userLastname>Gold</ns0:userLastname>\r    <diffgr:id>Users5</diffgr:id>\r    <msdata:rowOrder>4</msdata:rowOrder>\r</ns0:DeleteUser>\r</soap:Body></soap:Envelope>"
            }

            Comment


              #7
              for the fetch which is working with no problem:

              REQUEST:

              Code:
              {
                  actionURL:"http://localhost:1452/TimeSheet/Service.asmx", 
                  showPrompt:true, 
                  prompt:"Finding records that match your criteria...", 
                  transport:"xmlHttpRequest", 
                  useSimpleHttp:true, 
                  promptStyle:"dialog", 
                  httpMethod:"POST", 
                  contentType:"text/xml", 
                  httpHeaders:{
                      SOAPAction:"http://localhost/TimeSheet/GetUsers"
                  }, 
                  sendNoQueue:true, 
                  callback:{
                      target:null, 
                      methodName:"$37c"
                  }, 
                  willHandleError:true, 
                  serverOutputAsString:true, 
                  clientContext:{
                      requestIndex:1
                  }, 
                  data:"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' \n          xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n          xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Header></soap:Header><soap:Body>\r<ns0:GetUsers \n         xmlns:ns0=\"http://localhost/TimeSheet/\"/>\r</soap:Body></soap:Envelope>"
              }
              RESPONSE:

              Code:
              <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetUsersResponse xmlns="http://localhost/TimeSheet/"><GetUsersResult><xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Users" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="Users"><xs:complexType><xs:sequence><xs:element name="userId" msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" /><xs:element name="userGroup" type="xs:int" /><xs:element name="userFirstname"><xs:simpleType><xs:restriction base="xs:string"><xs:maxLength value="50" /></xs:restriction></xs:simpleType></xs:element><xs:element name="userLastname"><xs:simpleType><xs:restriction base="xs:string"><xs:maxLength value="50" /></xs:restriction></xs:simpleType></xs:element></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType><xs:unique name="Constraint1" msdata:PrimaryKey="true"><xs:selector xpath=".//Users" /><xs:field xpath="userId" /></xs:unique></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><DocumentElement xmlns=""><Users diffgr:id="Users1" msdata:rowOrder="0"><userId>1</userId><userGroup>1</userGroup><userFirstname>Johnny</userFirstname><userLastname>Smith</userLastname></Users><Users diffgr:id="Users2" msdata:rowOrder="1"><userId>4</userId><userGroup>3</userGroup><userFirstname>Bill</userFirstname><userLastname>Martin</userLastname></Users><Users diffgr:id="Users3" msdata:rowOrder="2"><userId>5</userId><userGroup>1</userGroup><userFirstname>Joe</userFirstname><userLastname>Carrey</userLastname></Users><Users diffgr:id="Users4" msdata:rowOrder="3"><userId>6</userId><userGroup>2</userGroup><userFirstname>Kristin</userFirstname><userLastname>Lawrence</userLastname></Users><Users diffgr:id="Users5" msdata:rowOrder="4"><userId>17</userId><userGroup>2</userGroup><userFirstname>Mike</userFirstname><userLastname>Gold</userLastname></Users></DocumentElement></diffgr:diffgram></GetUsersResult></GetUsersResponse></soap:Body></soap:Envelope>

              Comment


                #8
                for the add which also is working with no problem:

                REQUEST:

                Code:
                {
                    actionURL:"http://localhost:1452/TimeSheet/Service.asmx", 
                    showPrompt:false, 
                    transport:"xmlHttpRequest", 
                    useSimpleHttp:true, 
                    promptStyle:"dialog", 
                    httpMethod:"POST", 
                    contentType:"text/xml", 
                    httpHeaders:{
                        SOAPAction:"http://localhost/TimeSheet/AddUser"
                    }, 
                    sendNoQueue:true, 
                    callback:{
                        target:null, 
                        methodName:"$37c"
                    }, 
                    willHandleError:true, 
                    serverOutputAsString:true, 
                    clientContext:{
                        saveCallback:null, 
                        newValues:{
                            userGroup:"3", 
                            userFirstname:"Sarah", 
                            userLastname:"Williams"
                        }, 
                        editInfo:{
                            editValuesID:"_0", 
                            rowNum:5, 
                            colNum:3, 
                            values:{
                                userGroup:"3", 
                                userFirstname:"Sarah", 
                                userLastname:"Williams"
                            }, 
                            oldValues:null, 
                            editCompletionEvent:"enter"
                        }
                    }, 
                    data:"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' \n          xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n          xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Header></soap:Header><soap:Body>\r<ns0:AddUser \n         xmlns:ns0=\"http://localhost/TimeSheet/\">\r    <ns0:userGroup>3</ns0:userGroup>\r    <ns0:userFirstname>Sarah</ns0:userFirstname>\r    <ns0:userLastname>Williams</ns0:userLastname>\r</ns0:AddUser>\r</soap:Body></soap:Envelope>"
                }
                RESPONSE:

                Code:
                <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><AddUserResponse xmlns="http://localhost/TimeSheet/" /></soap:Body></soap:Envelope>

                Comment


                  #9
                  for the update which is not working:

                  REQUEST:

                  Code:
                  {
                      actionURL:"http://localhost:1452/TimeSheet/Service.asmx", 
                      showPrompt:false, 
                      transport:"xmlHttpRequest", 
                      useSimpleHttp:true, 
                      promptStyle:"dialog", 
                      httpMethod:"POST", 
                      contentType:"text/xml", 
                      httpHeaders:{
                          SOAPAction:"http://localhost/TimeSheet/UpdateUser"
                      }, 
                      sendNoQueue:true, 
                      callback:{
                          target:null, 
                          methodName:"$37c"
                      }, 
                      willHandleError:true, 
                      serverOutputAsString:true, 
                      clientContext:{
                          saveCallback:null, 
                          newValues:{
                              userId:"1", 
                              userFirstname:"John"
                          }, 
                          editInfo:{
                              editValuesID:"_1", 
                              rowNum:0, 
                              colNum:2, 
                              values:{
                                  userId:"1", 
                                  userFirstname:"John"
                              }, 
                              oldValues:{
                                  "diffgr:id":"Users1", 
                                  "msdata:rowOrder":"0", 
                                  userId:"1", 
                                  userGroup:"1", 
                                  userFirstname:"Johnny", 
                                  userLastname:"Smith"
                              }, 
                              editCompletionEvent:"enter"
                          }
                      }, 
                      data:"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' \n          xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n          xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Header></soap:Header><soap:Body>\r<ns0:UpdateUser \n         xmlns:ns0=\"http://localhost/TimeSheet/\">\r    <ns0:userId>1</ns0:userId>\r    <ns0:userGroup></ns0:userGroup>\r    <ns0:userFirstname>John</ns0:userFirstname>\r</ns0:UpdateUser>\r</soap:Body></soap:Envelope>"
                  }
                  RESPONSE:

                  Code:
                  <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---&gt; System.InvalidOperationException: There is an error in XML document (7, 36). ---&gt; System.FormatException: Input string was not in a correct format.
                     at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
                     at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
                     at System.Xml.XmlConvert.ToInt32(String s)
                     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read8_UpdateUser()
                     at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer12.Deserialize(XmlSerializationReader reader)
                     at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
                     --- End of inner exception stack trace ---
                     at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
                     at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
                     at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
                     --- End of inner exception stack trace ---
                     at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
                     at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>

                  Comment


                    #10
                    For the "update", I suspect your server requires that both userId and userGroup are sent, whereas the normal policy of the grid is to send only the primary key and updated fields. Implement a dataSource.transformRequest function to get the copy the userGroup from dsRequest.oldValues to dsRequest.data to fix this.

                    For the "remove" operation, there's this mysterious XML in the middle:

                    Code:
                    <diffgr:id>Users5</diffgr:id>\r    <msdata:rowOrder>4</msdata:rowOrder>
                    I'm not sure where that's coming from. Can you isc.logWarn(isc.Log.echoAll(dsRequest.data)) from dataSource.transformRequest() on a "remove" operation and tell us what that produces in the Developer Console?

                    Comment


                      #11
                      Hi this is from the log for the remove operation, after i put the statement isc.logWarn(isc.Log.echoAll(dsRequest.data)); in the transformRequest

                      Code:
                      15:25:13.435:INFO:Log:initialized
                      15:25:15.838:WARN:RecordEditor:usersListGrid$31t:No editable fields in this record editor. Check the 'canFilter' property for each field in usersListGrid
                      15:25:15.998:WARN:RecordEditor:usersListGrid$31t:No editable fields in this record editor. Check the 'canFilter' property for each field in usersListGrid
                      15:25:16.078:WARN:RecordEditor:usersListGrid$31t:No editable fields in this record editor. Check the 'canFilter' property for each field in usersListGrid
                      15:25:16.910:INFO:Log:isc.Page is loaded
                      15:25:34.091:MUP0:WARN:Log:{diffgr:id: "Users7",
                      msdata:rowOrder: "6",
                      userId: "21",
                      userGroup: "1",
                      userFirstname: "Robert",
                      userLastname: "Doe",
                      _selection_4: true}
                      15:25:34.231:MUP0:WARN:RPCManager:sendQueue called with no current queue, ignoring
                      15:25:34.701:XRP9:WARN:Log:findByKeys: passed record does not have a value for key field 'userId'

                      Comment


                        #12
                        And for the update do you have an example about how to copy the oldValues to send them as well? i guess i have to merge the values because not always the same values are changed it could be any combination of the following fields: userGroup, userFirstname, userLastname.

                        thanks

                        Comment


                          #13
                          I did resolve my issue with "remove" but not sure about if it is something bug free:

                          Code:
                          transformRequest : function (dsRequest) {
                          			if (dsRequest.operationType == "remove") {
                          				dsRequest.data = {userId : dsRequest.data.userId, userGroup : dsRequest.data.userGroup, userFirstname : dsRequest.data.userFirstname, userLastname : dsRequest.data.userLastname}
                          
                          				return isc.addProperties({}, dsRequest.data, dsRequest.data);
                          			}
                          		}

                          Comment


                            #14
                            this is what ended with:

                            Code:
                            transformRequest : function (dsRequest) {
                            			if (dsRequest.operationType == "remove") {
                            				dsRequest.data = {userId : dsRequest.data.userId, userGroup : dsRequest.data.userGroup, userFirstname : dsRequest.data.userFirstname, userLastname : dsRequest.data.userLastname}
                            				return isc.addProperties({}, dsRequest.data, dsRequest.data);
                            				isc.logWarn(isc.Log.echoAll(dsRequest.data));
                            			}
                            			if (dsRequest.operationType == "update") {
                            				var Group = (dsRequest.data.userGroup==null||dsRequest.data.userGroup=="")?dsRequest.oldValues.userGroup:dsRequest.data.userGroup; 
                            				var Firstname = (dsRequest.data.userFirstname==null||dsRequest.data.userFirstname=="")?dsRequest.oldValues.userFirstname:dsRequest.data.userFirstname;
                            				var Lastname = (dsRequest.data.userLastname==null||dsRequest.data.userLastname=="")?dsRequest.oldValues.userLastname:dsRequest.data.userLastname;
                            				dsRequest.data = {userId : dsRequest.data.userId, userGroup : Group, userFirstname : Firstname, userLastname : Lastname}
                            				return isc.addProperties({}, dsRequest.data, dsRequest.data);
                            				isc.logWarn(isc.Log.echoAll(dsRequest.data));
                            			}
                            		}
                            and now all operations are working fine

                            thanks for the help and i hope what i did so far is not that bad :)

                            Comment

                            Working...
                            X