3

When consuming my WCF service from client, I get the following error message. Problem is when I am able to run the code easily from a windows client or a console app. Just not from my web application.

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"/>

This is my WCF Service binding configuration

<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>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kobojunkie
  • 6,375
  • 31
  • 109
  • 164

2 Answers2

1

From the message, it appears that your WCF service is correctly returning a SOAP message, while your client might be expecting a raw POX (Plain Old XML) message back.

What kind of client is this? Are they expecting to just make a REST-style call to a URL and get back a payload of XML??

If so, you'll need to change your WCF service to use the WebHttpBinding instead of the basicHttpBinding (or expose a second endpoint with the webHttpBinding for that client).

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Wish there was a way to mark this as an answer, i modified my web.config to weHttpBinding and it worked, however i had to also use this settings found on these pages use the second best answer here and – You Rule Avi Apr 04 '14 at 15:46
1

It seems the service returns MTOM encoded response which the client does not expect. The service configuration does not indicate that MTOM is used so maybe it is not wired correctly to the service. Check what the service actually returns using Fiddler or WCF Logging.

Yaron Naveh
  • 23,560
  • 32
  • 103
  • 158