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/xsdbut 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 does it silently without errors!