我将要开发一个WCF服务,该服务将被政府机构使用。由于他们将访问由不同承包公司托管的相同服务,因此他们已经指定了消息必须具有的确切格式(因此,他们只会更改URL以访问每个公司的服务)。
因此,对于这个方法:
他们希望我们能够接受以下确切的SOAP消息:
有什么线索吗?谢谢!
因此,对于这个方法:
sbyte Execute(int Id1, short Id2, string Id3, string Id4, string Value)
他们希望我们能够接受以下确切的SOAP消息:
<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:Id1>1</m:Id1>
<m:Id2>2</m:Id2>
<m:Id3>3</m:Id3>
<m:Id4>4</m:Id4>
<m:Value></m:Value>
</m:Execute>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我们的回应必须是:
<?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>
<ExecuteResponse xmlns="http://tempuri.org/">
<ExecuteResult>
<res>0</res>
</ExecuteResult>
</ExecuteResponse>
</soap:Body>
</soap:Envelope>
现在,我的当前服务的消息,绑定名为“basicHttpBinding”,并使用我的测试客户端(以及WCF测试客户端工具),如下所示:
请求:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ISomeService/Execute</Action>
</s:Header>
<s:Body>
<Execute xmlns="http://tempuri.org/">
<Id1>0</Id1>
<Id2>0</Id2>
<Id3>0</Id3>
<Id4>0</Id4>
<Value>0</Value>
</Execute>
</s:Body>
</s:Envelope>
响应:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<ExecuteResponse xmlns="http://tempuri.org/">
<ExecuteResult>1</ExecuteResult>
</ExecuteResponse>
</s:Body>
</s:Envelope>
所以,我的问题是:
我应该怎样修改才能让我的服务像使用下面的SOAP消息:
"<SOAP-ENV:Envelope xmlns:SOAP- ... > <SOAP-ENV:Body>"
而不是使用...
<s:Envelope .... > <s:Header />
我尝试过几种绑定和自定义配置等方法,但是我无法使其看起来相同。
这是我当前的配置,使用提议的customBinding:
<system.serviceModel>
<services>
<service name="Test.SomeService">
<endpoint binding="customBinding" bindingConfiguration="Soap11Binding"
contract="Test.ISomeService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<customBinding>
<binding name="Soap11Binding">
<textMessageEncoding messageVersion="Soap11" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport allowCookies="true" />
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
</behaviors>
</system.serviceModel>
有什么线索吗?谢谢!