2009-09-25 72 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服务,检查它的操作,也称他们为

马克