• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SEVERE: SAAJ0008: Bad Response; Bad request

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote a web service client to generate a soap request and make a soap call to server. I m getting the below error .
But when i use the same request that is generated using code and post in soapUI , I m getting response .
The error i get is :
com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
SEVERE: SAAJ0008: Bad Response; Bad request
Error occurred while sending SOAP Request to Server
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad request
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at SeibelClient.main(SeibelClient.java:58)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad request
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
... 2 more

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad request
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 SeibelClient.main(SeibelClient.java:58)

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad request
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 SeibelClient.main(SeibelClient.java:58)




The program that i used is as below:
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.ws.WebServiceException;


public class SeibelClient {

public static void main(String args[]){
try {
System.out.println("**********************************************************");
// Create SOAP Connection
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory
.newInstance();
SOAPConnection soapConnection = soapConnectionFactory
.createConnection();


String url ="http://hostname:8002/eai_enu/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&WSSOAP=1";

try{
SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(),
url);
printSOAPResponse(soapResponse);
}catch(WebServiceException e){
e.printStackTrace();
}


soapConnection.close();
} catch (Exception e) {
System.err
.println("Error occurred while sending SOAP Request to Server");
e.printStackTrace();
}
}

private static SOAPMessage createSOAPRequest() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
soapMessage.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
soapMessage.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");
//soapMessage.setProperty(SOAPMessage., arg1);
SOAPPart soapPart = soapMessage.getSOAPPart();

String serverURI = "http://xmlns.oracle.com/yyy";

// SOAP Envelope
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("cus", "http://xxx.com/CustomUI");
envelope.addNamespaceDeclaration("cmit", "http://xmlns.oracle.com/yyy");
envelope.addNamespaceDeclaration("cus1", "http://xxx.com/webservices");
SOAPHeader header = envelope.getHeader();
//SOAPElement authElem = header.addChildElement("AuthenticationInfo",
//"urn");
QName name = new QName("xmlns");
QName user = new QName("UsernameToken");
QName pwd = new QName("PasswordText");
// QName nillable = new QName("nillable");
//authElem.addAttribute(name, "AuthenticationInfo");

SOAPElement authEle1 = header.addChildElement("UsernameToken","cus1");



authEle1.addTextNode("zzz");
SOAPElement authEle2 = header.addChildElement("PasswordText","cus1");

authEle2.addTextNode("zzz$");

// SOAP Body
SOAPBody soapBody = envelope.getBody();
//soapBody.addNamespaceDeclaration("cus", serverURI);
SOAPElement soapBodyElem = soapBody.addChildElement(
"Process_Input", "cus");
SOAPElement elemOne = soapBodyElem.addChildElement(
"Process_spcInstance_spcId", "cus");
elemOne.addTextNode("");
SOAPElement elemTwo = soapBodyElem.addChildElement(
"Object_spcId", "cus");
elemTwo.addTextNode("");
SOAPElement elemThree = soapBodyElem.addChildElement(
"Siebel_spcOperation_spcObject_spcId", "cus");
elemThree.addTextNode("");

SOAPElement elemNext = soapBodyElem.addChildElement(
"CMITelematicsRequestMsg", "cmit");

SOAPElement elem1 = elemNext.addChildElement(
"Engine_Serial_Number", "cmit");
elem1.addTextNode("46452657");

SOAPElement elem2 = elemNext.addChildElement(
"VIN", "cmit");
elem2.addTextNode("TSV0037859389");
SOAPElement elem3 = elemNext.addChildElement(
"Fault_Code", "cmit");
elem3.addTextNode("EN202928808829");
SOAPElement elem4 = elemNext.addChildElement(
"Fault_Code_Description", "cmit");
elem4.addTextNode("TEST FAULT");

SOAPElement elem6 = elemNext.addChildElement(
"Customer_Email", "cmit");
elem6.addTextNode("aluu7834@yahoo.com");



SOAPElement elem7 = elemNext.addChildElement(
"Service_Model_Name", "cmit");
elem7.addTextNode("C8.3");

SOAPElement elem8 = elemNext.addChildElement(
"Customer_ID", "cmit");
elem8.addTextNode("33453933");



MimeHeaders headers = soapMessage.getMimeHeaders();
headers.addHeader("SOAPAction", serverURI + "yyy");

soapMessage.saveChanges();

// Print the request message
System.out.print("Request SOAP Message = ");
soapMessage.writeTo(System.out);
System.out.println();

return soapMessage;
}

/**
* Method used to print the SOAP Response
*/
private static void printSOAPResponse(SOAPMessage soapResponse)
throws Exception {
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
Source sourceContent = soapResponse.getSOAPPart().getContent();
System.out.print("\nResponse SOAP Message = ");
StreamResult result = new StreamResult(System.out);
transformer.transform(sourceContent, result);
}


}





Please help me in solving the problem.




 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check your serverURI value again and then the line of addHeader adding SOAPAction. It looks doubtful. Also the SOAPAction should appear to be quoted in the actual outgoing HTTP header if you use tool to monitor the wire. If not, that shows you should give the add header line an extra pair of quotes to the value. In any case, you have to check that part.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is unlikely that your request ever got routed to the service, instead you got a response code 400 = bad request, possibly accompanied by a text message which your SOAP client could not understand. I would use TCPMON or SOAPui to look at the actual request and response.

Bill
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing the same issue. can you please confirm how this can be solved.

soapConnection.call is going to Exception in case we receive Fault message in response.

same request is working fine in SOAPUI and giving correct fault message but in Java client it is going to exception
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I also have the same issue. Can anyone solved it?

SOAP UI works ok but in Netbeans is not working  "400Bad-request"
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic