I am trying to execute a SOAP message but I am getting the following error:
Feb 11, 2015 10:18:39 AM com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
SEVERE: SAAJ0008: Bad Response; Service Unavailable
Error occurred while sending SOAP Request to Server
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (503Service Unavailable
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at ProjectDelta.main(ProjectDelta.java:56)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (503Service Unavailable
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
... 3 more
CAUSE:
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (503Service Unavailable
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at ProjectDelta.main(ProjectDelta.java:56)
CAUSE:
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (503Service Unavailable
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at ProjectDelta.main(ProjectDelta.java:56)
I think it has something to do with the MimeHeaders
of the message. Since when I take the generated SOAPMessage xml and paste it into a SoapUI project it works and gets a valid response. No 503 error, no invalid request error when I put into SoapUI. I can't post the xml here though because it contains some sensitive info.
I looked at the SoapUI raw section and it has the following (Sorry I have to remove some of the URLs):
POST /*Service Address*/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Content-Length: 2181
Host: /*Host address */
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
So, on the SOAPMessage
object I did the following:
private void addHeaders(SOAPMessage soapMessage, String serverURL, String action) {
// I know I dont use serverURL or action
MimeHeaders headers = soapMessage.getMimeHeaders();
headers.addHeader("Accept-Encoding", "gzip,deflate");
headers.addHeader("Content-Type", "text/xml;charset=UTF-8");
}
And when I do the connection I do the following:
SOAPMessage soapResponse = soapConnection.call(soapMessage, serviceAddress);
printSOAPResponse(soapResponse);
The error in my main (line 56) occurs on the soapConnection.call
.
I thought it might be a proxy error, but I have used System.setProperty("http.proxyHost", PROXY_URL);
and gone and set the port, username, password etc. But I still get a 503 error.
Any pointers on where to look? I have searched on-line but a lot of people got 400 errors not 503.