【发布时间】:2019-04-11 13:40:39
【问题描述】:
我有以下 WCF 服务
[ContractType(ContractKnownType.CORE)]
[ServiceContract(Namespace = WcfConstants.WcfNamespace), ServiceBehavior(Namespace = WcfConstants.WcfNamespace)]
[HostAsWebService]
[XmlSerializerFormat]
public class DeliveryWebService : IFactoryService
{
[OperationContract, Sessional]
public string InboundDelivery(MT_InboundDelivery MT_InboundDelivery)
{
var error = "";
try
{
... some code
}
}
}
每当我使用以下 SOAP 消息发出请求时
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.MEScontrol.net/WebServices">
<soapenv:Header/>
<soapenv:Body>
<web:MT_InboundDelivery>
<web:HeaderDetails/>
</web:MT_InboundDelivery>
</soapenv:Body>
</soapenv:Envelope>
我得到错误
对象引用未设置为对象的实例
如果我在消息中添加一个“InboundDelivery”节点,它就可以工作。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.MEScontrol.net/WebServices">
<soapenv:Header/>
<soapenv:Body>
<web:InboundDelivery>
<web:MT_InboundDelivery>
<web:HeaderDetails/>
</web:MT_InboundDelivery>
<web:InboundDelivery>
</soapenv:Body>
</soapenv:Envelope>
但是我无法更改消息,因为这是由第三方应用程序发送的。我尝试将属性作为 [MessageContract(IsWrapped=true)] 添加到我的服务中,但没有成功。我对 SOAP 很陌生,所以欢迎任何帮助。谢谢!
【问题讨论】:
标签: .net web-services wcf soap