从自托管的Web服务返回响应消息,它是肥皂吗?

时间:2015-10-15 03:52:23

标签: c# xml web-services wcf soap

目前我有这个小客户:

 static void Main(string[] args)
        {
            MyService.CalculatorClient ws = new MyService.CalculatorClient();

            ws.Open();
            Console.ReadLine();

            ws.xml("<DOCUMENT></DOCUMENT>");

            ws.Close();
            Console.ReadLine();

        }

哪个工作正常它基本上只是发送一个字符串到我的Web服务,我生成一个xml并存储在某个地方。

我想回复一下,如果我使用WCFTestClient.exe,我会看到这个回复。

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://Microsoft.ServiceModel.Samples/ICalculator/xmlResponse</a:Action>
    <a:RelatesTo>urn:uuid:325d2f97-c1f0-4b66-912a-d9b3a6b097a7</a:RelatesTo>
  </s:Header>
  <s:Body>
    <xmlResponse xmlns="http://Microsoft.ServiceModel.Samples">
      <xmlResult>Success</xmlResult>
    </xmlResponse>
  </s:Body>
</s:Envelope>

我想将此内容返回到我的客户端控制台应用并显示它。但是,我很难让它显示出来。我在Web服务上公开了字符串,但无法将其返回。

我的另一个问题是......如果SOAP只是xml是我的web服务的肥皂服务我还没有宣布它是什么定义它是SOAP或者我如何将它变成SOAP。这是我的app.config:

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <!-- This section is optional with the new configuration model
           introduced in .NET Framework 4. -->
      <service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/ServiceModelSamples/service"/>
          </baseAddresses>
        </host>
        <!-- this endpoint is exposed at the base address provided by host: http://localhost:8000/ServiceModelSamples/service  -->
        <endpoint address="" binding="wsHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator" bindingConfiguration="CustomBinding" />
        <!-- the mex endpoint is exposed at http://localhost:8000/ServiceModelSamples/service/mex -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="CustomBinding" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00">
          <security mode="None">
            <message establishSecurityContext="false"/>
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="CalculatorServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

在响应的开头提到了SOAP,这是否意味着这是一个SOAP连接,即使我没有建立它或将其配置为?

非常感谢任何帮助。

0 个答案:

没有答案