Protocol Exception was unhandled by User - wcf-binding

I'm getting the below error message while receive a webservice response. And this is after the webservice version upgraded.
The content type multipart/related; type="application/xop+xml"; start=""; start-info="text/xml"; boundary="----=_Part_2_7001591.1292244022237" of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '
------=_Part_2_7001591.1292244022237
Content-Type: application/xop+xml; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID:
ee5f1f723c8d3e4cde6d82624edb85b0_1292244022143_61101522KrishnM<'.

Try changing the messageEncoding attribute of the binding in web.config from Text to Mtom.

It might be due to stackoverflow exception.Some times Stack overflow exception will come due to the debugger is running in infinite (thread)loop.

Related

How to resolve Error while building Passthrough stream java.util.zip.ZipException in WSo2 Gateway?

I am getting the following error on the WSo2 Gateway 2.1.0 when trying to pass a response back to WSo2 EI that originated an API call on APIM and I am not sure what the issue is:
[2021-05-06 15:19:26,401] ERROR org.apache.synapse.transport.passthru.util.RelayUtils:344 - Error while building Passthrough stream
java.util.zip.ZipException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:165)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:79)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:91)
at org.apache.axis2.transport.http.HTTPTransportUtils.handleGZip(HTTPTransportUtils.java:262)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:95)
at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:151)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:114)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:78)
at org.wso2.carbon.apimgt.gateway.handlers.LogsHandler.buildResponseMessage_aroundBody16(LogsHandler.java:264)
at org.wso2.carbon.apimgt.gateway.handlers.LogsHandler.buildResponseMessage(LogsHandler.java:254)
at org.wso2.carbon.apimgt.gateway.handlers.LogsHandler.handleResponseInFlow_aroundBody6(LogsHandler.java:141)
at org.wso2.carbon.apimgt.gateway.handlers.LogsHandler.handleResponseInFlow(LogsHandler.java:131)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.invokeHandlers(Axis2SynapseEnvironment.java:1077)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:242)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:556)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:186)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:265)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at datadog.trace.bootstrap.instrumentation.java.concurrent.Wrapper.run(Wrapper.java:25)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
There can be some possible scenarios for the above issue.
Content-Encoding: gzip header comes in the response header but the content of the response is not in GZIP format. You can verify that by enabling the wire logs.
You can get rid of this behavior by removing the Content-Encoding header using header mediator as shown below before calling the EI endpoint.
<header action="remove" name="Content-Encoding" scope="transport"/>
The client(according to your case it's EI) is expecting the content encoded as gzip while the APIM is serving it deflated or some other way.
So in such a case, You can use the below property to send the response in gzip format
<property name="Content-Encoding" value="gzip" scope="transport"/>

WCF client talking to Java WS, exception: The content type application/xop+xml; type="application/soap+xml" of the response message

I'm having problems talking to Java WS. I'm using "wsHttpBinding" binding with client certificates for authentication, message encoding is set "Text", .net framework is 4.0. Server side is Java and I have no control over it. Connection is being proxied through Fiddler (this is how I see requests on the wire, much more user friendly than tracing "System.Net").
Exception I get is following:
The content type application/xop+xml; type="application/soap+xml" of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8).
If I change message encoding to "Mtom", then the exception changes:
The content type application/xop+xml; type="application/soap+xml" of the response message does not match the content type of the binding (multipart/related; type="application/xop+xml").
Server is accepting both "Text" and "Mtom" message encodings for request, and response is always the same. This is the raw response that I'm getting from the server:
HTTP/1.1 200 OK
X-Backside-Transport: OK OK
Connection: Keep-Alive
X-Powered-By: Servlet/3.0
SOAPAction: ""
Content-Type: application/xop+xml; type="application/soap+xml"
Content-Language: en-US
Date: Thu, 25 Jul 2013 13:05:09 GMT
Content-Length: 628
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope ... </env:Envelope>
From all the docs which I have been reading, response that is being returned is somewhere between regular SOAP message and MTOM message. I'm saying this because every example which I've seen says that the MTOM request and response use MIME as an envelope for communication: regular SOAP message is enveloped in XOP package, and then this XOP message is enveloped with MIME. Even the W3C recommendation uses MIME for XOP packages: W3C: XML-binary Optimized Packaging. Excerpt from this link:
Content-Type: Multipart/Related;boundary=...
If I try calling web service using tool "soapUI" (written in Java, available from "www.soapui.org"), service call is successfully executed and response is parsed without any problem.
FYI, this is a cross-post from MSDN WCF forum., but no responses there yet.
Any idea is appreciated, thanks in advance,
Alex
I'm also using CXF, and has a C# client. Try modifying your binding setting, replace textMessageEncoding with mtomMessageEncoding. Something like this:
<binding name="yourSoapBinding">
<mtomMessageEncoding messageVersion="Soap12"/>
<httpTransport />
</binding>
Try setting the message encoding in the binding configuration to messageEncoding="Mtom" and basicHTTPBinding instead of wsHTTP one...
Hope it helps!

How do I handle WCF SOAP deserialization errors in HTTP Reponse?

How do I hide the following error information and show custom message in WCF? This error occur when we inject invalid parameter in http request
HTTP/1.0 500 Internal Server Error
Cache-Control: private
Content-Length: 494
Content-Type: text/xml; charset=utf-8
Date: Mon, 23 Jan 2012 22:34:36 GMT
X-Cache: MISS from test.int.testgroup.com
Via: 1.0 test.int.testgroup.com:80 (squid/2.6.STABLE22)
Proxy-Connection: close
<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:DeserializationFailed</faultcode><faultstring xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'GetData'. Character reference not valid. Line 1, position 121.</faultstring></s:Fault></s:Body></s:Envelope>
You will need a custom WCF deserializer that can catch the errors and produce custom error messages. Have a look here: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/dcd48a7f-4494-455f-8504-cbdc372badcf/

WCF & Soap returning --uuid:{value} in body?

I am making a soap request which is returning the following:
HTTP/1.1 200 OK
Content-Length: 7048
Content-Type: multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:dc2ee0dc-fd91-40ef-949d-2c1b02108e23+id=4";start-info="text/xml"
Server: Microsoft-HTTPAPI/2.0
MIME-Version: 1.0
Date: Tue, 25 Oct 2011 12:56:17 GMT
--uuid:dc2ee0dc-fd91-40ef-949d-2c1b02108e23+id=4
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
<s:Envelope details />
Everything is good except that the section
--uuid:dc2ee0dc-fd91-40ef-949d-2c1b02108e23+id=4
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Is being considered part of the body which it throwing off xml parsing. I'm wondering what this uuid information id and why is it coming down as part of the body rather than the header? (Along with the content-id, content-transfer-encoding and content-type?)
Figured it out based on Ladislav Mrnkas MTOM comment. In my app.config I changed:
<binding name="BindingName" messageEncoding="Mtom" maxReceivedMessageSize="1006710886">
To
<binding name="BindingName" messageEncoding="Text" maxReceivedMessageSize="1006710886">
This is important for anyone running ksoap2 as it will not process the mtom message and will throw an xml parsing exception.
If SOAP UI client is used for running the SOAP request, set the TestRequest Properties: Inline Response Attachments to "false". This will fix the uuid being appended in the SOAP response.
[Note :The TestRequest Properties is unique to every Test step in a Test Suite.]

ProtocolException with WCF Service

When I try to access WCF client, I get the following error. I was able to access my service using IE and able to reference in VS 2010. My development environment is Windows server 2008. I hosted service in Sharepoint Project server. I am stuck with this error. Please advice.
"The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. "
Here is some data Headers from Fiddler.
GET /_vti_bin/psi/helloservice.svc HTTP/1.1
Content-Type: text/xml; charset=utf-8
MicrosoftSharePointTeamServices: 14.0.0.4762
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-SharePointHealthScore: 4
WCF HTTP Activation must be enabled on the server. If the script maps for WCF are not installed you may receive the error.