In short, I try to build a web service consumer with WCF manually; here is the SOAP response:
<s:Body xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<AMethodResponse xmlns="http://v_namespace">
<ReturnObjectHeader>
<Field5>V5</Field5>
<Field3>V5</Field3>
<Field4>V5</Field4>
</ReturnObjectHeader>
</AMethodResponse>
</s:Body>
Shortly, below is the related part in my C# code (after that I present the trace results):
[System.ServiceModel.MessageContractAttribute(WrapperName = "AMethodResponse", IsWrapped = true, WrapperNamespace = "http://v_namespace")]
public partial class ReturnObjectWrapper
{
private ReturnObject _ReturnObjectHeader;
[System.ServiceModel.MessageBodyMemberAttribute(Name = "ReturnObjectHeader", Namespace = "http://v_namespace")]
public ReturnObject ReturnObjectHeader
{
get { return _ReturnObjectHeader; }
set { _ReturnObjectHeader = value; }
}
}
[System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
public partial class ReturnObject
{
private string _Field5;
private string _Field3;
private string _Field4;
[System.ServiceModel.MessageBodyMemberAttribute(Name = "Field5", Namespace = "http://v_namespace")]
public string Field5
{
get { return _Field5; }
set { _Field5 = value; }
}
[System.ServiceModel.MessageBodyMemberAttribute(Name = "Field3", Namespace = "http://v_namespace")]
public string Field3
{
get { return _Field3; }
set { _Field3 = value; }
}
[System.ServiceModel.MessageBodyMemberAttribute(Name = "Field4", Namespace = "http://v_namespace")]
public string Field4
{
get { return _Field4; }
set { _Field4 = value; }
}
}
And here is the trace result:
Description: An unrecognized element was encountered in the XML during deserialization which was ignored.
Element: http://v_namespace:Field5
NOTE: Same for Field4 and 3
What am I doing wrong?
Found on this site; adding
ServiceBehaviorattribute worked for me, i.e.: