2009-09-25 111 views
1

我想使用SOAP調用WCF服務?使用SOAP調用調用WCF

這是我的合同:

[ServiceContract(Namespace = "http://www.MySite.com/Services/TransferFile")] 
public interface ITransferFile : ICloseableAndAbortable 
{ 
    /// <summary> 
    /// This will send the file which is associated with this rule to all the subscribers. 
    /// </summary> 
    /// <param name="ruleId"></param> 
    [OperationContract] 
    void ByRuleId(int ruleId); 
} 

當前設置爲這種結合,將我需要改變呢?

<endpoint address="" binding="wsHttpBinding" contract="FileTransfer.Wcf.ITransferFile"> 

那麼我怎麼稱呼它通過肥皂?例如使用(HttpWebRequest的)的WebRequest

很多感謝

回答

5
  1. 更改綁定到basicHttpBinding的

2消息

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body> 
    <ByRuleId xmlns="http://www.MySite.com/Services/TransferFile"> 
     <ruleId>3</ruleId> 
    </ByRuleId> 
    </soap:Body> 
</soap:Envelope> 

3肥皂動作

POST /FileTransferService/TransferFile.svc HTTP/1.1 
SOAPAction: "http://www.MySite.com/Services/TransferFile/ITransferFile/ByRuleId" 

FYI我要求(HttpWebRequest的)的WebRequest,僅作爲一個可行的方式,我結束了使用Web引用和提琴手

1

有沒有你喜歡WebRequest,而不是產生與svcutil.exe客戶端代理這需要所有的管道照顧理由嗎?

+2

我有一個正在使用Sharepoint設計器的同事,創建一個將調用Web服務的工作流,snag是他正在使用的第三方工具無法做到的WCF,它只能理解SOAP Action和body ..因此我正在尋找一個簡單的例子我可以在.net(WebRequest)中測試,然後通過他所需的字符串 – dbones 2009-09-25 14:22:40

1

有許多方法可以做到這一點:

  • 創建爲您服務自己,一點點WCF客戶端通過使用svcutil或在Visual Studio項目「添加服務引用」
  • 運行SOAP測試工具如SoapUIWCFStorm針對您的服務和創建請求並致電您的服務(並查看結果)
  • 使用WCF測試客戶端WcfTestClient.exe這是您的(Visual Studio)\Common7\IDE\Tools\bin(?不是100%肯定的位置 - 檢查,你會發現它肯定),並允許您連接到正在運行的WCF服務,檢查它的操作,也稱他們爲

馬克