从客户端使用我的WCF服务时,收到以下错误消息。问题是我能够从Windows客户端或控制台应用程序轻松运行代码。只是不是我的网络应用程序。
System.InvalidOperationException was unhandled by user code
Message="Client found response content type of
'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:28551dc8-55af-4ec9-a9dc-169075c7f50a+id=6";start-info="text/xml"', but expected 'text/xml'.
The request failed with the error message: --
--uuid:28551dc8-55af-4ec9-a9dc-169075c7f50a+id=6 Content-ID: <http://tempuri.org/0> Content-Transfer-Encoding: 8bit Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="en-US">PrintOut3: Conversion failed</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException i:nil="true"/>
这是我的WCF服务绑定配置
<basicHttpBinding>
<binding name="BasicHttpBinding_IMakePDFService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" messageEncoding="Mtom"
textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
答案 0 :(得分:1)
从消息中可以看出,您的WCF服务正在正确返回SOAP消息,而您的客户端可能希望返回原始POX(Plain Old XML)消息。
这是什么类型的客户?他们是否期望只对URL进行REST样式调用并获取XML的有效负载
如果是这样,您将需要更改您的WCF服务以使用WebHttpBinding
而不是basicHttpBinding(或为该客户端公开第二个端点和webHttpBinding
。)
答案 1 :(得分:1)
服务似乎返回客户端不期望的MTOM编码响应。服务配置并不表示使用了MTOM,因此可能未正确连接到服务。使用Fiddler或WCF Logging检查服务实际返回的内容。