问题描述
我在尝试解决问题时遇到了麻烦,也许你可以帮我
我正在使用具有以下绑定配置的WCF调用WebService
private static System.ServiceModel.Channels.Binding CreateBinding()
{
var securityElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
securityElement.IncludeTimestamp = false;
var encodingElement = new TextMessageEncodingBindingElement(MessageVersion.Soap11,Encoding.UTF8);
var transportElement = new HttpsTransportBindingElement();
System.ServiceModel.Channels.CustomBinding custom = new System.ServiceModel.Channels.CustomBinding(securityElement,encodingElement,transportElement);
return custom;
}
致电服务部门
var client = new ServiceReference1.QueryPortTypeClient(CreateBinding(),"https://...");
ClientResponse response = client.query(request);
服务响应没有问题,但是ClientResponse对象的声明属性为NULL
响应消息的结构
[System.ServiceModel.MessageContractAttribute(WrapperName = "QueryRCEResponse",WrapperNamespace = "urn:wco:datamodel:PE:Declaration:1")]
public class ClientResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "urn:wco:datamodel:PE:Declaration:1",Order = 0)]
public Declaration Declaration;
public ClientResponse()
{
}
public ClientResponse(Declaration Declaration)
{
this.Declaration = Declaration;
}
}
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:wco:datamodel:PE:Declaration:1")]
public class Declaration
{
private string functionCodeField;
[System.Xml.Serialization.XmlElementAttribute(Order = 0)]
public string FunctionCode
{
get
{
return this.functionCodeField;
}
set
{
this.functionCodeField = value;
}
}
}
响应消息XML SOAP
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
<soapenv:Body>
<NS1:QueryRCEResponse xmlns:NS1="urn:wco:datamodel:PE:Declaration:1">
<Declaration>
<FunctionCode>2020-840485</FunctionCode>
</Declaration>
</NS1:QueryRCEResponse>
</soapenv:Body>
</soapenv:Envelope>
NET FRAMEWORK 4.7
感谢您的帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)