我们有一个在IIS中托管的WCF SOAP服务,用于上传二进制数据。为了允许更大的有效载荷(避免base64编码的二进制数据),我们希望添加一个接受MTOM消息的端点,同时保留旧版客户端的当前SOAP端点和向后兼容性。因此,期望的最终结果如下:
http://www.myorg.com/Service.svc给出SOAP端点(当前存在且有效) http://www.myorg.com/Service.svc/mtom提供SOAP w / MTOM端点(新的,不起作用)
我认为这就像添加一个<endpoint>
元素并将其bindingConfiguration
设置为指向新的<binding messageEncoding="Mtom">
元素一样简单,但这不起作用:尝试获取http://www.myorg.com/Service.svc/mtom
服务器始终返回错误400,并返回空响应体。尝试POST到同一端点(通过WCF测试客户端)时,将返回错误415:
无法处理邮件,因为内容类型&#39; application / soap + xml;字符集= UTF-8&#39;不是预期的类型&text; / xml;字符集= UTF-8&#39;&#34;
我的配置:
<behaviors>
<serviceBehaviors>
<behavior name="Service">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="http" port="80" />
<add scheme="https" port="443" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="ServiceMTOM" messageEncoding="Mtom" maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
</binding>
<binding name="Service" maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Service" behaviorConfiguration="Service">
<endpoint address="" binding="basicHttpBinding" contract="MyNamespace.Service" bindingConfiguration="Service" />
<endpoint address="mtom" binding="basicHttpBinding" contract="MyNamespace.Service" bindingConfiguration="ServiceMTOM" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
由于我必须与WCF合作已经很长时间了 - 我错过了什么?