Cannot assign object of type System.Xml.XmlNode[] to an object of type <<some complex type>> calling a PHP Web Service RRS feed

  • Question

  • Our application (.Net 4.0 client) is consuming a web service build on php. 

    We don't know how the Service is built as we don't own it, we only use it.

    Our process which calls a particular proxy method, gives the following error:-

    Error in deserializing body of reply message for operation 'some_process'.
    System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'some_process'. ---> System.InvalidOperationException: There is an error in XML document (1, 474). ---> System.InvalidCastException: Cannot assign object of type System.Xml.XmlNode[] to an object of type Some.Proxies.some_process_rec.

    The same method works fine when tested with SOAP Client.

    I went looking for solutions on internet, i found only below, but is not of great help-

    Any help here is appreciated.

    Thanks in advance!

    Mounika K

    • Edited by Mounika_K Tuesday, July 23, 2019 11:42 AM
    Tuesday, July 23, 2019 11:40 AM

All replies

  • document (1, 474)

    In line 1 at position 474 in the line, you have to find out what it is that is causing the exception to be thrown.

    Wednesday, July 24, 2019 7:24 AM
  • Hi,
    How did you generate the SOAP client?  I mean that how did you exactly call the service properly. I didn’t know PHP. As far as I know, if the service based on the web service specification, we could generate the client by using the service WSDL page, web service description language. In C# project, we could use SVCUtil tool or the way with adding service reference to call the service.
    Feel free to let me know if there is anything I can help with.
    Best Regards
    Wednesday, July 24, 2019 7:42 AM
  • I need to know which xml should i look at. Is it the response xml?

    Mounika K

    Friday, July 26, 2019 6:58 AM
  • Hi Abraham,

    I installed SoapUI 5.5.0 and used the wsdl and tested the problem request. It works fine.

    But the same doesn't work fine from .Net client. Yes, the service proxy in .Net might have been generated using the SvcUtil. but i was not part of that dev team who actually did it.

    So from my analysis, it seems to me that when a web method returns a complex type (object array, in my case), it doesn't seem to deserialize.

    Any ideas on how to fix this?


    Mounika K

    Friday, July 26, 2019 11:57 AM
  • Hi,

    How do you call the service in DotNet client? the default serializer is DataContractSerializer. I don’t think there is something wrong with the serialization.
    Please refer to the below call.

    ServiceReference1.ServiceClient client = new ServiceClient();
                Product product = new Product()
                    ID = 1,
                    Name = "Apple"
                    var result = client.GetData(product);
                catch (Exception)

    For strong-typed data, the client proxy class will generate the Data Contract too.
    The same goes for arrays, generics.
    On the client side, the parameter that we need to pass and the returned result should be defined during generating the client proxy.
    Best Regards

    Monday, July 29, 2019 6:59 AM