简而言之,我尝试使用 WCF手动构建 Web 服务使用者;这是 SOAP 响应:
<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>
很快,下面是我的 C# 代码中的相关部分(之后我展示了跟踪结果):
[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; }
}
}
这是跟踪结果:
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
我究竟做错了什么?