You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "udaff.com" <za...@udaff.com> on 2004/01/08 14:22:20 UTC
Help!!! Can't create message from InputStream! Axis 1.1
Hello everybody,
Can anyone help me in using MessageFactory.createMessage()? (Axis 1.1)
I have a text version of fault response got from SOAP 1.1 spec. I'm
trying to create a SOAPMessage instance with
MessageFactory.createMessage(). It helps me perfectly with normal
response - I'm getting properly initialized SOAPMessage and can
traverse result fields with iterators. But when I try to deserialize a
fault like this (spec sample):
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client.Authentication</faultcode>
<faultstring>Server Error</faultstring>
<detail>
<e:myfaultdetails xmlns:e="Some-URI">
<message>
My application didn't work
</message>
<errorcode>1001</errorcode>
</e:myfaultdetails>
</detail>
<SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
then I got an exception like this:
Exception in thread "main" javax.xml.soap.SOAPException: java.lang.NullPointerException
at org.apache.axis.SOAPPart.getEnvelope(SOAPPart.java:806)
at Util.Test.runTest(Test.java:55)
at Util.Test.main(Test.java:77)
Caused by: java.lang.NullPointerException
at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:543)
at org.apache.axis.SOAPPart.getEnvelope(SOAPPart.java:804)
... 2 more
Caused by: java.lang.NullPointerException
at org.apache.axis.message.BodyBuilder.onStartChild(BodyBuilder.java:196)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:963)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1635)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
... 3 more
Below is my test sample method code which reads the SOAP fault text file and
trying to obtain a SOAPMessage. Sorry for a bad code but it's just a
proof-of-concept:
public void runTest(String param) throws Exception
{
InputStream is = new FileInputStream(param);
MimeHeaders mh = new MimeHeaders();
mh.addHeader("Content-Type","text/xml");
_msg = MessageFactory.newInstance().createMessage(mh, is);
SOAPPart sp = _msg.getSOAPPart();
System.out.println("SOAPPart: " + sp);
SOAPEnvelope envelope = sp.getEnvelope();
System.out.println("SOAPEnvelope: " + envelope);
SOAPBody body = envelope.getBody();
System.out.println("SOAPBody: " + body);
SOAPElement service = (SOAPElement)body.getChildElements().next();
System.out.println("--->>>>>>>" + service);
System.out.println("");
SOAPElement element = null;
for (Iterator iter = service.getChildElements(); iter.hasNext();)
{
element = (SOAPElement)iter.next();
System.out.println("<<<<<--- " + element.getElementName().getQualifiedName());
}
}
This sample perfectly works reading normal web service response but
not fault. Sun JWSDP and WASP can't even create SOAPMessage from a
normal normal web service response.
Thanks in advance!
--
Best regards,
Dim Dimych