WCF: Deserialization error, the response elements disappeared.

Deserialization error, the response elements disappeared. Namespace in Wsdl is not conforming to the namespace in Response message
 
I generated client for the Web-service and made a request.
The response on the service side had the data inside, the notification element.
The problem was on the client side where the notification element disappeared.
I used the SoapUI utility to test the service. The SoapUI response had the right notification element! But my client got any notification element.
I created different type of clients in VS2005, VS2008, by SvcUtil.exe, as Service-reference (as the WCF-client), and Web-reference (as Asmx client). I generated the proxy with the Software Factory. The result was the same, any notification element! And the SoapUI had get the right response with right notification element
Response in the SoapUI was:
<soapenv:Body>
 <ns:removeNotificationByEmailIDResponse xmlns:ns="http://service.MyService">
 <ns:return type="projectnamespace.Notifications">
   <ns:notification type="projectnamespace.Notification">
     <ns:msgID>159</ns:msgID>
   </ns:notification>
   </ns:return>
 </ns:removeNotificationByEmailIDResponse>
</soapenv:Body>
 
Responses in my clients were:
<soapenv:Body>
 <ns:removeNotificationByEmailIDResponse xmlns:ns="http://service.MyService">
   <ns:return type="projectnamespace.Notifications">
   </ns:return>
 </ns:removeNotificationByEmailIDResponse>
</soapenv:Body>
 
At last I started to compare Responses and the Wsdl, and I had found source of this problem.
In short word, Wsdl did not conform to Response messages.
 
For instance, Response message was:
<soapenv:Body>
 <ns:removeNotificationByEmailIDResponse xmlns:ns="http://service.MyService">
 <ns:return type="projectnamespace.Notifications">
   <ns:notification type="projectnamespace.Notification">
     <ns:msgID>159</ns:msgID>
   </ns:notification>
  </ns:return>
 </ns:removeNotificationByEmailIDResponse>
</soapenv:Body>
 
And the Wsdl was:
 
  <wsdl:types>
        <xs:schema xmlns:ax22="http://vo.com/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://vo.com/xsd">
              <xs:complexType name="Notification">
                    <xs:sequence>
                          <xs:element minOccurs="0" name="msgID" nillable="true" type="xs:long" />
                    </xs:sequence>
              </xs:complexType>
              <xs:complexType name="Notifications">
                    <xs:sequence>
                          <xs:element minOccurs="0" maxOccurs="unbounded" name="notification" nillable="true" type="ax22:Notification" />
                    </xs:sequence>
              </xs:complexType>
        </xs:schema>
 
This Wsdl generates the proxy like:
 
    [System.Runtime.Serialization.CollectionDataContractAttribute(Name = "Notifications", Namespace = "http://vo.com/xsd, ItemName = "notification")]"
    [System.SerializableAttribute()]
    public class Notifications : System.Collections.Generic.List<vo.notification.clearmedia.com.xsd.Notification>
    {
    }
 
    [System.Runtime.Serialization.DataContractAttribute(Name = "Notification", Namespace = "http://vo.com/xsd")]
    [System.SerializableAttribute()]
    public partial class Notification : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
    {
         private string msgIDField;
 ...
 
I've marked the errors. In Wsdl classes Notification and Notifications had Namespace = "http://vo.com/xsd" but in response messages they had namespaces xmlns:ns="http://service.MyService".
I' had change the first namespace to the second one in the proxy code and the client started working well.
 
SoapUI returns the response but it doesn't care about processing the response message, it just shows response.
 
The service was created by Axis2 tool and service developers told me that they could not change this error. When I request the Wsdl, it generates automatically somewhere inside tool and the error could not be fixed easily.
 
Conclusion: If the response is compound from the elements with several namespaces and some elements do not passed the proxy, check if these elements in the response message and in the Wsdl have the same namespaces. If namespace in Wsdl is not conforming to the namespace in Response message the proxy does not serialize the elements. It disappears silently without errors!
 
 
Print | posted on Tuesday, April 1, 2008 10:12 PM

Feedback

# re: WCF: Deserialization error, the response elements disappeared.

left by Pim at 11/6/2009 6:56 AM Gravatar
I'm trying to get the TecDoc webservice running. This one:
http://webservice.tecdoc.net/pegasus-1-3/wsdl/TecdocToCatWL
But the solution provided on this page doesn't work. Nor do solutions found on any other page that I can find. I always get an empty record, even if the returned raw XML is exactly what I expect.

So can anybody provide me with a working example of a call to this service? TIA!

Pim

# re: WCF: Deserialization error, the response elements disappeared.

left by Danilo at 10/18/2011 1:21 AM Gravatar
I've same problem, but with VS2010 that doesn't generate any proxy class.
How can I fix it?
Post A Comment
Title:
Name:
Email:
Comment:
Verification: