我設置了一個非常簡單的WCF服務,只有工作是通過SOAP接收XML消息並將消息發送到內部服務。假設我正在創建的是後衛。 (實際名稱已取代了例如)在.NET中接收純XML WCF服務
初始信息:
我不能改變外部服務呼叫我。據我所知這是一個用java編譯的Soap11客戶端。
在這個例子中,所有名稱都被更改爲虛擬名稱。
端點 - 設置:
<service behaviorConfiguration="GuardpostBehavior" name="Guardpost.ContractImplementation">
<endpoint address="" binding="basicHttpBinding" contract="Guardpost.IContract" bindingConfiguration="basic">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
綁定配置:
<basicHttpBinding>
<binding name="basic" textEncoding="utf-8" messageEncoding="Text">
<security mode="Transport" />
</binding>
</basicHttpBinding>
(我需要交通運輸的安全性由於HTTPS)
我的合同是這樣的:
[ServiceContract]
public interface IContract
{
[OperationContract(Action="urn:#GuardpostReceive")]
void GuardpostReceive(string inputXml);
}
現在我收到的是一個Soap-wrapped消息,其Action設置爲urn:#GuardpostReceive,因此消息的實際路由正確完成。
然而 - 當收到消息時,它實際上並沒有被推入的方法,因爲這種錯誤的:
OperationFormatter encountered an Invalid Message body. Expected to find node type 'Element' with name 'inputXml' and namespace ' http://tempuri.org/ '. Found node type 'Element' with name 'extns:ExternalNodeName' and namespace ' http://foo.com/bar.org/someservice/schema/1 '
這個問題似乎是我的WCF服務是不能提取的體的Soap消息,並簡單地將它作爲普通的XML傳遞,但這正是我需要它做的。
我在WCF中遇到過showstopper嗎?
這裏的問題不是字符串或輸入參數類型,而是OperationFormatter異常。無論我將其設置爲輸入類型,它都會發生。 – 2010-08-18 10:43:34
對不起我的錯,我跳過了你的問題的第一段。如果你構建路由器,你應該直接使用消息類型(返回操作類型也是消息)。你不能只是定義字符串參數,並期望它會被XML填充。您也可以嘗試使用XmlElement或XElement作爲參數類型。 Alex已經向你展示了一個例子。 – 2010-08-19 21:32:43