我在使用 webHttpBinding (soap 1.1) 的 WCF Web 服务中遇到“对象引用未设置为对象实例”错误 我注意到,如果您按特定顺序输入参数,则不会引发错误。
i.e.
<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>
但是,如果我更改请求模板中输入参数的顺序,则会收到上述错误。即(注意消息和 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>
为什么会发生这种情况?请求参数是否通过顺序(而不是名称)映射到 .Net 方法参数?我是否必须在服务合同上指定一个属性才能使命名参数映射成为可能?
你需要使用XmlSerializer 格式WCF 服务接口中的类。
[ServiceContract, XmlSerializerFormat]
public interface IGoodMessageService
{
...
}
问题和解决方案在此链接中进行了解释:http://neimke.blogspot.com.tr/2012/03/serialization-ordering-causes-problems.html http://neimke.blogspot.com.tr/2012/03/serialization-ordering-causes-problems.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)