Har*_*aka 5 wcf soap request input-parameters
我在我的WCF Web服务中使用webHttpBinding(soap 1.1)得到一个Object引用未设置为对象错误的实例我注意到如果你按照特定顺序输入参数,则不会引发错误.
即
<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>
Run Code Online (Sandbox Code Playgroud)
但是,如果我更改请求模板中输入参数的顺序,我会得到上述错误.ie(注意消息和userIDs参数被切换)
<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>
Run Code Online (Sandbox Code Playgroud)
为什么会这样?请求参数是否通过订单而不是名称映射到.Net方法参数?是否有必须在服务合同上指定的属性才能使命名参数映射成为可能?
您需要在WCF服务接口中使用XmlSerializerFormat类.
[ServiceContract, XmlSerializerFormat]
public interface IGoodMessageService
{
...
}
Run Code Online (Sandbox Code Playgroud)
此链接解释了问题和解决方案:http://neimke.blogspot.com.tr/2012/03/serialization-ordering-causes-problems.html
| 归档时间: |
|
| 查看次数: |
4932 次 |
| 最近记录: |