cancel
Showing results for 
Search instead for 
Did you mean: 

Web service failing with HTTP 415 error

Former Member
0 Kudos

Hi All,

I am currently troubleshooting an issue we're having with a web service to a customer that has been set up. We are using XI to make the external web service available to our internal network (so the interface is a synchronous SOAP to SOAP scenario). We initially had some issues with our client certificate not working, but were able to solve this using the XISOAPAdapterBean certLookupMode = 3 in the Module tab.

Now we are facing an issue with the content type. I get the following error before SOAP call is even attempted (just after it enters the adapter).

SOAP: call failed: java.io.IOException: invalid content type for SOAP: TEXT/HTML; HTTP 415 Cannot process the message because the content type text/xml; charset=utf-8 was not the expected type application/soap+xml; charset=utf-8.

I was able to get one step further by checking the 'Do Not Use SOAP Envelope' option in the channel. When this is checked, I get the error below. However, the payload does not have a SOAP envelope in it already so I don't think this is the right thing to do.

SOAP: response message contains an error XIAdapter/HTTP/ADAPTER.HTTP_EXCEPTION - HTTP 415 Cannot process the message because the content type text/xml;charset=utf-8 was not the expected type application/soap+xml; charset=utf-8.

Finally, I tried using the MessageTransformBean Transform.ContentType = application/soap+xml;charset=utf-8 to force the content type to what is 'expected', and I get the following error.

SOAP: response message contains an error XIAdapter/HTTP/ADAPTER.HTTP_EXCEPTION - HTTP 400 Bad Request

So, now I'm out of ideas. Can anyone shed some light on how to solve or troubleshoot this issue?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

HI Michael,

Please let me know how you solved the issue ?

We are also getting HTTP 400 Bad request error in SOAP receiver channel.

Your help will be really appreciated.

Regards,

SV

stefan_grube
Active Contributor
0 Kudos

Your webservice requests SOAP 1.2, which is not supported by PI SOAP adapter.

You could use Axis framework to create a SOAP 1.2 message.

Former Member
0 Kudos

Thanks Stefan!

We have confirmed with our partner that they are using WCF which they told us inherently means it is SOAP 1.2. So now we have deployed the Axis framework and are attempting to make the connection using this. On the the next error:

MP: Exception caught with cause org.xml.sax.SAXException: Processing instructions are not allowed within SOAP messages

We inspected the message and haven't found any processing instructions (which would be '<?' + instruction + '?>' and apparently the <?xml version='1.0' ?> doesn't count). Any ideas for this issue?

stefan_grube
Active Contributor
0 Kudos

This error message means, that the XML does not start with <?, but has a <? later (so parser assumes this is a process instructure)

In other words: Your payload has a whitespace at begin.

Former Member
0 Kudos

In order to investigate this, I have used the TCPGateway tool I found in one of your blogs. It is quite helpful in tracking what exactly is being sent. Our customer also provided us with an executable to use from the desktop to send ad-hoc requests to their web service, so I'm comparing what they expect and what we are sending. Here is the message that works (from their tool):

POST /Services/Service.svc HTTP/1.1

Content-Type: application/soap+xml; charset=utf-8

Host: hostname:port

Content-Length: 1259

Expect: 100-continue

Connection: Keep-Alive

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">soapAction</a:Action><a:MessageID>urn:uuid:1793edff-d407-4732-8d43-8a361f6340ff</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://hostname:port/Services/Service.svc</a:To></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetProductReturnInfo xmlns="namespace">

...

</GetProductReturnInfo></s:Body></s:Envelope>

And here is the message from XI:

POST /Services/Service.svc HTTP/1.0

Content-Type: application/soap+xml; charset=UTF-8

Accept: application/soap+xml, application/dime, multipart/related, text/*

User-Agent: Axis/1.4

Host: hostname:port

Cache-Control: no-cache

Pragma: no-cache

Content-Length: 1332

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

<ns1:GetProductReturnInfo xmlns:ns1="namespace">

...

</ns1:GetProductReturnInfo>

</soapenv:Body>

</soapenv:Envelope>

The body of both messages was identical. So there are a few differences I'm noticing:

1) The customer post is in HTTP 1.1 vs XI is 1.0

2) XI has additional and different values in the POST header portion

3) The customer SOAP message is all on one line (no CRLF) vs XI has a new line after each xml tag.

4) XI places <?xml version="1.0" encoding="UTF-8"?> at the start of the SOAP message. The customer does not have this.

5) XI does not put in the SOAP header

I have read that I can change the HTTP protocol using a module parameter, and I have also tried switching the module to use CommonsHTTPSender which uses HTTP 1.1 by default. When I use the second module, it also adds what looks like a character count around the SOAP message:

POST /Services/Service.svc HTTP/1.1

Content-Type: application/soap+xml; charset=UTF-8

User-Agent: Axis/1.4

Host: hostname:port

Transfer-Encoding: chunked

534

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

<ns1:GetProductReturnInfo xmlns:ns1="namespace">

...

</ns1:GetProductReturnInfo>

</soapenv:Body>

</soapenv:Envelope>

0

So, I'm not sure if whitespace is the issue but I am starting to think that the <?xml version="1.0" encoding="UTF-8"?> might be a problem. Any ideas/recommendations on how to resolve these differences (if you think they matter)?

Edited by: Michael R Morrison on Feb 1, 2011 1:50 PM

stefan_grube
Active Contributor
0 Kudos

When your web service really denies the message because there is an XML header (and from the error message I would say so) then you have a severe issue.

A web service should accept at least a message according to the XML standards.

You can add SOAP headers with a Axis hanlders, but there is another aproach:

When you create the SOAP envelope with an additional mapping step and use SOAP adapter with flag "do not use SOAP envelope" you can create the message the same way as the customer requests it.

udo_martens
Active Contributor
0 Kudos

Hi Michael,

you are on a good way: You solved the error with the wrong content-type and now you get the next error "Bad Request". The server does not understand your request, assumedly the path (or url parameter) are wrong.

Regards,

Udo