代码之家  ›  专栏  ›  技术社区  ›  dbones

使用SOAP调用调用WCF

  •  1
  • dbones  · 技术社区  · 15 年前

    我想使用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">
    

    那么通过soap我该如何称呼它呢?例如,使用(HttpWebRequest)WebRequest

    非常感谢

    3 回复  |  直到 15 年前
        1
  •  5
  •   dbones    15 年前
    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>
    

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

        2
  •  1
  •   Darin Dimitrov    15 年前

    有什么原因让你更喜欢它吗 WebRequest svcutil.exe

        3
  •  1
  •   marc_s HarisH Sharma    15 年前

    有很多方法可以做到这一点:

    • 使用以下方法为您的服务自己创建一个小型WCF客户端 svcutil
    • 运行SOAP测试工具,如 SoapUI WCFStorm
    • 使用WCF测试客户端 WcfTestClient.exe 哪个在你的房间里 (Visual Studio)\Common7\IDE\Tools\bin (?? 不是100%确定位置-检查一下,您肯定会找到的!)它允许您连接到正在运行的WCF服务,检查其操作,并调用它们