none
Getting a deserialization error while getting a web service response RRS feed

  • Question

  • Hi there,

    I am using the following code to call a web service from a windows phone app:

    PayByPhone.integraMobileWS.integraMobileWSSoapClient soapClient = new integraMobileWSSoapClient();
    string sXMLIn = "<ipark_in><IMEI></IMEI><WIFIMAC></WIFIMAC><SessionID>be1d2da820a093f7fa0fc371d22493f7ee1458ef2a4513f7</SessionID><u>ulric</u><f>Ghyyyt</f><d>232029180213</d><vers>1.0</vers><ah>8E2EE8125BA6DF32</ah></ipark_in>";
    string m_username = "*************";
    string m_password = "**********";
    soapClient.QueryFinePaymentQuantityCompleted += new EventHandler<PayByPhone.integraMobileWS.QueryFinePaymentQuantityCompletedEventArgs>(soapClient_QueryFinePaymentQuantity);
    using (OperationContextScope contextScope = new OperationContextScope(soapClient.InnerChannel))
    {    
        var br = Encoding.UTF8.GetBytes(string.Format(@"{0}:{1}", m_username, m_password));
        HttpRequestMessageProperty httpProps = new HttpRequestMessageProperty();    
        httpProps.Headers[HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(br);
        OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpProps;        // Call service
        
    soapClient.QueryFinePaymentQuantityAsync(sXMLIn); }   

    The Web Service function QueryFinePaymentQuantityAsync is one of many functions from the same URL. The web service references were built automatically using VS2012 wizards. The others work fine and return some XML. However this one return an error:

    {System.ServiceModel.Dispatcher.NetDispatcherFaultException}
    There was an error deserializing the object of type PayByPhone.integraMobileWS.QueryFinePaymentQuantityResponseBody. Content cannot be converted to the type Int. Line 1, position 372.   

    It crash on the second line of this function:

    public PayByPhone.integraMobileWS.QueryFinePaymentQuantityResponse EndQueryFinePaymentQuantity(System.IAsyncResult result) 
    {
        object[] _args = new object[0];
        PayByPhone.integraMobileWS.QueryFinePaymentQuantityResponse _result = ((PayByPhone.integraMobileWS.QueryFinePaymentQuantityResponse)(base.EndInvoke("QueryFinePaymentQuantity", _args, result)));
        return _result;
    }

    Any Help?


    Monday, February 25, 2013 3:40 PM

Answers

  • What MiniPeter trying to say is, when you call QueryFinePaymentQuantityAsync in client side, it will actually call a function on the server side like QueryFinePaymentQuantity().

    Put a breakpoint in this function on the server side and see why it is returning something other than an integer which is expected out of this function.


    ViBi

    Friday, March 1, 2013 11:36 AM

All replies

  • Hi, it seems you are trying to convert a type to Int, please inspect the value by setting a breakpoint.
    Wednesday, February 27, 2013 8:25 AM

  • The conversion itself itself accurs inside a dll, System.ServiceModel.ni.dll, so I don't have any idea what exactly it's doing.

    The method above is called in Async mode, so there is no caller shown in the call stack. As for the variable "result"... inspecting it when it crash... its a very large hierarchy of classes within classes, but delving into the depth, I have actually found the XML Im looking for:


    {<?xml version="1.0" encoding="utf-16"?>
    <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">
      <s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
      <soap:Body>
        <QueryFinePaymentQuantityResponse xmlns="http://tempuri.org/">
          <QueryFinePaymentQuantityResult>&lt;ipark_out&gt;&lt;r&gt;-27&lt;/r&gt;&lt;/ipark_out&gt;</QueryFinePaymentQuantityResult>
        </QueryFinePaymentQuantityResponse>
      </soap:Body>
    </soap:Envelope>}


    But i'm not sure this is the source of the crash... Any help?


    Wednesday, February 27, 2013 9:24 PM
  • What MiniPeter trying to say is, when you call QueryFinePaymentQuantityAsync in client side, it will actually call a function on the server side like QueryFinePaymentQuantity().

    Put a breakpoint in this function on the server side and see why it is returning something other than an integer which is expected out of this function.


    ViBi

    Friday, March 1, 2013 11:36 AM