wcf - SOAP信封中的WCF和输入参数顺序

标签 wcf soap request input-parameters

我在使用webHttpBinding(soap 1.1)的WCF Web服务中得到的对象引用未设置为对象错误的实例,我注意到,如果您按特定顺序输入参数,则不会引发该错误。

IE。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:not="http://schemas.globalfoundries.com/NotificationService">
   <soapenv:Header/>
   <soapenv:Body>
      <not:NotifyWorkflowItemUpdate>
         <not:userIDs>testUserID</not:userIDs>
         <not:taskID>testTaskID</not:taskID>
         <not:taskType>testTaskType</not:taskType>
         <not:status>testStatus</not:status>
         <not:appID>testAppID</not:appID>
         <not:message>testMessage</not:message>
      </not:NotifyWorkflowItemUpdate>
   </soapenv:Body>
</soapenv:Envelope>

但是,如果我更改请求模板中输入参数的顺序,则会收到上述错误。即(注意消息和用户ID参数已切换)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:not="http://schemas.globalfoundries.com/NotificationService">
   <soapenv:Header/>
   <soapenv:Body>
      <not:NotifyWorkflowItemUpdate>
     <not:message>testMessage</not:message>
         <not:taskID>testTaskID</not:taskID>
         <not:taskType>testTaskType</not:taskType>
         <not:status>testStatus</not:status>
         <not:appID>testAppID</not:appID>
         <not:userIDs>testUserID</not:userIDs>
      </not:NotifyWorkflowItemUpdate>
   </soapenv:Body>
</soapenv:Envelope>

为什么会这样呢?请求参数是否通过顺序而不是通过名称映射到.Net方法参数?我必须在服务契约(Contract)上指定一个属性以使命名参数映射成为可能吗?

最佳答案

您需要在WCF服务界面中使用 XmlSerializerFormat 类。

[ServiceContract, XmlSerializerFormat]
public interface IGoodMessageService
{
    ...
}

在此链接中说明问题和解决方案:http://neimke.blogspot.com.tr/2012/03/serialization-ordering-causes-problems.html

关于wcf - SOAP信封中的WCF和输入参数顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11667771/

相关文章:

wcf - 使用 PowerShell 的 New-WebServiceProxy 访问 net.tcp 端点

asp.net - 捕获对ASP.NET ASMX Web服务的SOAP请求

java - 在 servlet 中模拟/生成 SocketTimeoutException

python - 使用请求 python 发布复杂数据字典

c# - 我应该如何获取 URI 的特定部分

c# - 从 C# 中的对象类型获取数据

c# - WCF 模拟的目的

c# - 如何回收自托管 WCF 服务

java - JAXB2 Maven Plugin xjc parse error : org. xml.sax.SAXParseException: Unexpected <xs:element>出现

javascript - 向 Fluxpoint api 发送请求时出错