Thanks you for quickly replies:
david wrote:
> I would try a few obvious things.
>
> First read the entire inputstream into a string and print out the string
> that you got.
>
> Reference that instead of the stream in the SOAPMessage creation. This
> is just to verify you got what you think you were getting.
>
> Change the code that does the println to a series of assignments to
> local variables, first extracting the soap body, then the first child,
> and then the local name. Print out each of these.
>
> Step through this code in the debugger and examine the objects being
> created.
>
> I read the InputStream from jsp page in a String and it appears correct, I
tried to debug sending SOAP message below and adding the line:
SOAPBody sb = soapReq.getSOAPBody();
I've noticed for example that the firstChild field in sb object counts 5
chars (the first is a "\n" and the others empty). I did debug on other
objects as SOAPPart: all fields seem empty (except namespaceURI and inherent
fields).
The Application Server that I'm using is Tomcat 6.0.16, I think my problem
is about some jar library that I need to add to my classpath updating from
JDK 1.5 to JDK 1.6 (I've tried with 1.6.0_07 and 1.6.0_10), but I don't know
which it can be.
kumar wrote:
> If it works with JDK 1.5, it should have worked with JDK 1.6 as well.
> The differernce i can imagine is JAXP between your JDK 1.5 and 1.6
> runs. Can you check the JAXP which gets used in both.
>
> Is your suggestion "in your classpath are present jaxp-api.jar and
jaxp-ri.jar"?
Because compiling with JDK 1.5 I haven't them in my classpath and the code
works.
Below java code and SOAP message.
Thanks
Riccardo
public void doPost(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {
res.setContentType("text/xml; charset=utf-8");
SOAPMessage soapReq = null;
SOAPMessage soapRes = null;
try {
MessageFactory msgFactory = MessageFactory.newInstance();
soapReq = msgFactory.createMessage(null,req.getInputStream());
soapReq.saveChanges();
SOAPBody sb = soapReq.getSOAPBody();
soapRes = msgFactory.createMessage();
System.out.println(soapReq.getSOAPBody().getFirstChild().getLocalName());
soapReq.writeTo(res.getOutputStream());
} catch (SOAPException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
********** SOAP Message *********
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<get_SAserviceDetail>
<input_1>
<concept name="ItalianWine" multiplicity="1"/>
</input_1>
<output_1>
<concept name="Winery" multiplicity="1"/>
</output_1>
</get_SAserviceDetail>
</soapenv:Body>
</soapenv:Envelope>