【问题标题】:Exchange SOAP messages using WCF使用 WCF 交换 SOAP 消息
【发布时间】:2016-12-23 00:47:44
【问题描述】:

我想开发一个接收 SOAP 请求并返回 SOAP 响应的 Web 服务。我不知道该怎么做。到目前为止,我只使用以下代码来交换消息。谁能帮我正确设置我的服务

IService.cs

[OperationContract(Name = "Receive")]
    [WebInvoke(Method = "POST", UriTemplate = "Receive")]
    string Receive(Stream odata);

Service.cs

  public string Receive(Stream data)
    {
    string response=@"<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/""
    xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/"" xmlns:xsi=""http:/
    /www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/
    XMLSchema"">
        <SOAP-ENV:Body>
            <m:Execute xmlns:m=""http://tempuri.org/"">
                <m:name>name1</m:name>
                <m:Value></m:Value>
            </m:Execute>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>";
    return response;
}

这是 web.config 的一部分

<system.serviceModel>
    <services>
      <service name="Service" behaviorConfiguration="myServiceBehavior">
        <endpoint name="webHttpBinding" address="" binding="webHttpBinding" contract="IService" behaviorConfiguration="webHttp"/>
        <endpoint name="mexHttpBinding" address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="myServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webHttp">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>

【问题讨论】:

    标签: c# .net web-services wcf soap


    【解决方案1】:

    我终于解决了这个问题。我需要让我的服务通过其特殊配置来支持 WSE

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-04
      • 2016-07-29
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 2010-12-16
      • 1970-01-01
      相关资源
      最近更新 更多