Wednesday, 20 June 2007

Printing the SOAPElement JAX-RPC 1.4 type to standard out

I am constantly consuming web services which have a service class with methods using org.w3c.dom.Element

The web service stub proxy within JDeveloper 10.1.3.x will then use the JAX-RPC 1.4 client interface as follows for clients to consume the web service methods with parameters of this type.

javax.xml.soap.SOAPElement

In order to print out the XML you can easily just use this piece of code to display the XML to standard out for testing purposes.

SOAPElement soapElement =
myPort.executeQuery("select empno, ename, hiredate, deptno from emp");
((XMLElement)soapElement).print(System.out);

Note: XMLElement is fully defined as oracle.xml.parser.v2.XMLElement part of oracle's XML parser V2 which is the JAR file xmlparserv2.jar

2 comments:

Anonymous said...

I get the following error

com.sun.xml.messaging.saaj.soap.impl.ElementImpl cannot be cast to oracle.xml.parser.v2.XMLElement

Pas Apicella said...

I am not sure how to display a soap message using SAAJ. If you google around I am sure there will be a way to display this, just not sure how it's done.