axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From consultantchris <consultantch...@hotmail.com>
Subject wrapping OMElement from XMLStreamReader with SOAPEnvelope error
Date Thu, 05 Jul 2007 21:57:01 GMT

Hi,

I was trying to debug a null pointer exception that was coming up with
Rampart, but have found that my SOAPEnvelope is malformed. Once I add a
child to the body, the closing </soapenv:Envelope> tag seems to get dropped.
I've put a code snippet below (not the literal code, but the flow is correct
so far as variables and values are concerned), along with the resulting
actual output. Any help would be appreciated as I'm quite new to these
products. I can also provide all code if my cut and paste below is not
telling enough.

    ConfigurationContext ctx =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
    EchoStub echoClient = new EchoStub(ctx, args[0]);

    java.io.File file = new java.io.File(args[1]);
    XMLStreamReader reader =
XMLInputFactory.newInstance().createXMLStreamReader(new
FileInputStream(file));
    StAXOMBuilder builder = new StAXOMBuilder(reader);
    OMElement request = builder.getDocumentElement();

System.out.println("Sending Echo request: ");
System.out.println(request.toString());

  	org.apache.axis2.description.AxisOperation[] operations = new
org.apache.axis2.description.AxisOperation[1];

  	// Instantiated to use http://localhost:8080/axis2/services/Echo. In
actual code,
  	// class extends Stub and is called from main[]. Put all together to show
overriding flow
  	org.apache.axis2.client.OperationClient operationClient =
echoClient._getServiceClient().createClient(operations[0].getName());
   
operationClient.getOptions().setAction("http://www.example.org/Echo/Echo");
    operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);

    // create SOAP envelope with that payload
    org.apache.axiom.soap.SOAPEnvelope env = null;

    // Style is Doc.
    org.example.www.echo.Echo dummyWrappedType = null;

    // getFactory is out of scope in this context, but is here to show logic
only
    org.apache.axiom.soap.SOAPFactory factory =
echoClient.getFactory(operationClient.getOptions().getSoapVersionURI());

    org.example.www.echo.Echo wrappedType = new org.example.www.echo.Echo();
    org.example.www.echo.AnyType wrappedComplexType = new
org.example.www.echo.AnyType();

    wrappedComplexType.setExtraElement(request);

    wrappedType.setEcho(wrappedComplexType);

    org.apache.axiom.soap.SOAPEnvelope emptyEnvelope =
factory.getDefaultEnvelope();

System.out.println("Envelope  : "+emptyEnvelope.toStringWithConsume());
System.out.println("Message   : "+request.toStringWithConsume());
		OMNode child = org.example.www.echo.EchoHelper.getOMElement(wrappedType, 
				org.example.www.echo.Echo.MY_QNAME, factory);
    emptyEnvelope.getBody().addChild(child);
System.out.println("Body+Child:
"+emptyEnvelope.getBody().toStringWithConsume());
    emptyEnvelope.build();
System.out.println("Final XML : "+emptyEnvelope.toString()); // Missing tag
here!!!!!!

============================== Output ===================================
Sending Echo request: 
<test />
Envelope  : <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header
/><soapenv:Body /></soapenv:Envelope>
Message   : <test />
Body+Child: <soapenv:Body
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><ns1:Echo
xmlns:ns1="http://www.example.org/Echo/"><ns1:Echo><test
/></ns1:Echo></ns1:Echo>
Final XML : <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header
/><soapenv:Body><ns1:Echo
xmlns:ns1="http://www.example.org/Echo/"><ns1:Echo><test
/></ns1:Echo></ns1:Echo></soapenv:Body>

-- 
View this message in context: http://www.nabble.com/wrapping-OMElement-from-XMLStreamReader-with-SOAPEnvelope-error-tf4032521.html#a11455373
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message