在SOAP信封另一個命名空間我連接到一個SOAP1.1服務。這是一個使用行業標準接口定義(名爲MultiSpeak,在公用程序空間中非常常見)的預先存在的服務包括WCF客戶
MultiSpeak標準不包括傳遞供應商要求的CustomerID的條款,因此他們修改了SoapEvenelope略微。我的問題是我無法確定如何說服WCF發出正確的XML。
我現在的信封看起來是這樣的:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:MultiSpeakMsgHeader UserID="****" Pwd="****" Company="****"
xmlns="http://www.multispeak.org/Version_3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:h="http://www.multispeak.org/Version_3.0" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetAMRSupportedMeters xmlns="http://www.multispeak.org/Version_3.0" />
</s:Body>
</s:Envelope>
這裏是什麼,我需要它看起來像工作:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:MultiSpeakMsgHeader UserID="****" Pwd="****" Company="****"
vendor:CustomerID="StringValue"
xmlns="http://www.multispeak.org/Version_3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:h="http://www.multispeak.org/Version_3.0"
xmlns:vendor="http://www.MyVendor.com/Multispeak3"/>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetAMRSupportedMeters xmlns="http://www.multispeak.org/Version_3.0" />
</s:Body>
所以這是引入了新的命名空間(我的供應商的自定義命名空間),並在現有的「MultiSpeakMsgHeader」對象,引入了新的特性,被稱爲「客戶ID」,但在XML屬性,表示屬性是不同的命名空間
他們提供給我的WSDL(標準MultiSPeak WSDL)不會生成此消息。
我覺得很容易將「CustomerID」作爲字符串屬性添加到reference.cs中的MultiSpeakMsgHeader對象,但它不會被正確的xmlns裝飾發出,因此不會工作(是的,我測試過那......沒有名字空間,沒有愛)。
我不知所措。我嘗試調整他們的WSDL並重新生成以使其工作,但沒有運氣。
任何提示,我就肯定是感激。我已經爲這個問題丟了太多時間了。
謝謝大家。