我在使用webHttpBinding(soap 1.1)的WCF Web服務中收到沒有設置爲對象錯誤實例的對象引用我注意到,如果您有輸入參數某些順序錯誤不會引發。WCF和SOAP Envelope中的輸入參數順序
即
<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方法參數的嗎?是否有必須在服務合同上指定一個屬性來使命名參數映射成爲可能?
是的,如果可以,請添加一些解釋,我會接受這個答案。等待兩年的答案,但:D – Harindaka 2014-07-10 12:30:15