[
https://issues.apache.org/jira/browse/WSCOMMONS-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844686#action_12844686
]
Martin commented on WSCOMMONS-526:
----------------------------------
Code:
----------------------------------------------------------------------------------------------------------------------
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory;
public class Test {
/**
* @param args
*/
public static void main(final String[] args) {
final SOAPFactory soapFactory = new SOAP12Factory();
final SOAPEnvelope soapEnvelopeEmpty = soapFactory.createSOAPEnvelope();
System.out.println(soapEnvelopeEmpty.toString());
final SOAPEnvelope soapEnvelopeBody = soapFactory.createSOAPEnvelope();
soapFactory.createSOAPBody(soapEnvelopeBody);
System.out.println(soapEnvelopeBody.toString());
final SOAPEnvelope soapEnvelopeHeader =
soapFactory.createSOAPEnvelope();
soapFactory.createSOAPHeader(soapEnvelopeHeader);
System.out.println(soapEnvelopeHeader.toString()); // <--
Exception
}
}
----------------------------------------------------------------------------------------------------------------------
Output:
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"></soapenv:Envelope>
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body></soapenv:Body></soapenv:Envelope>
Exception in thread "main" org.apache.axiom.om.OMException: SOAPEnvelope must
contain a body element which is either first or second child element of the
SOAPEnvelope.
at
org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.getBody(SOAPEnvelopeImpl.java:177)
at
org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:224)
at
org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:937)
at
org.apache.axiom.om.impl.llom.OMNodeImpl.serialize(OMNodeImpl.java:387)
at
org.apache.axiom.om.impl.llom.OMElementImpl.toString(OMElementImpl.java:1106)
at Test.main(Test.java:38)
> SOAPEnvelope toString() behavior inconsistant dependent on content
> ------------------------------------------------------------------
>
> Key: WSCOMMONS-526
> URL: https://issues.apache.org/jira/browse/WSCOMMONS-526
> Project: WS-Commons
> Issue Type: Bug
> Components: AXIOM
> Affects Versions: Axiom 1.2.8
> Environment: llom, Java 5, Windows
> Reporter: Martin
> Priority: Minor
>
> Using llom 12, SOAPEnvelope.toString() works on empty SOAPEnvelope,
> SOAPEnvelope's with a SOAPBody, SOAPEnvelope's with a SOAPheader and
> SoapBofy, but fails on SOAPEnvelope's with only a SOAPHEader with an
> exception. This behavior is inconsistent.
> Should toString validate the envelope? Should an empty envelope also throw an
> error?
> IMO, the envelope should be serializable with the header only.
> The exception:
> Exception in thread "1" org.apache.axiom.om.OMException: SOAPEnvelope must
> contain a body element which is either first or second child element of the
> SOAPEnvelope.
> at
> org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.getBody(SOAPEnvelopeImpl.java:177)
> at
> org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:224)
> at
> org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:937)
> at
> org.apache.axiom.om.impl.llom.OMNodeImpl.serialize(OMNodeImpl.java:387)
> at
> org.apache.axiom.om.impl.llom.OMElementImpl.toString(OMElementImpl.java:1106)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.