Hi Gerard,
It is not required to modify generated stub to access incoming
SOAP messages, you could do it simply as follows .
In your client class after you receive the response object , use
getOMElement(....) method.
OMElement
omRes=hotelAvailabilityRes.getOMElement(null, null);
String resText=re.toString();
Thanks ,
On Fri, Mar 27, 2009 at 5:47 PM, Gerard Draper <[email protected]> wrote:
> Hi,
> I have built a Web Service client with Axis2 1.4.1 and I would like to be
> able to access to the SOAP messages I receive from the web service. Among
> other things I need to know the message size (bytes).
> I tried to get the SOAP message in two different ways:
> At the "private java.lang.Object fromOM( org.apache.axiom.om.OMElement
> param, java.lang.Class type, java.util.Map extraNamespaces) throws
> org.apache.axis2.AxisFault" function (the code has been generated with the
> WSDL2J)
> if (com.smilodm.hotels.HotelAvailabilityResponse.class.equals(type)){
>
> OMElement omElement = new
> StAXOMBuilder(param.getXMLStreamReaderWithoutCaching()).getDocumentElement();
> String xml = omElement.toStringWithConsume();
> System.out.println(xml);
>
> return
> com.smilodm.hotels.HotelAvailabilityResponse.Factory.parse(xmlStreamReader);
> }
> the SOAP message is printed, bu I get this error:
> org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException: problem
> accessing the parser. Parser already accessed!
> at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
> at uib.axis2.HotelsmilodmStub.fromOM(HotelsmilodmStub.java:5294)
> at uib.axis2.HotelsmilodmStub.hotelAvailability(HotelsmilodmStub.java:2756)
> I also tried to print the message at the stub generated by Axism, before It
> returns the message Object:
>
> java.lang.Object object = fromOM(_returnEnv.getBody().getFirstElement() ,
> com.smilodm.hotels.OpenSessionResponse.class,
> getEnvelopeNamespaces(_returnEnv));
> System.out.println(_returnEnv.toStringWithConsume());
> return (com.smilodm.hotels.OpenSessionResponse)object;
> But I get the same error (I can get the SOAP message as String or the SOAP
> message as OpenSessionResponse, depending wich instruction goes first. ):
> org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException: problem
> accessing the parser. Parser already accessed!
> I would really appreciate If anyone could help me to get the message as
> String and as an Object.
> thanks,
>
> --
> Gerard Draper Gil
> Sent from: Palma de Mallorca Islas Baleares España.
--
Sagara Gunathunga
Blog - http://ssagara.blogspot.com
Web - http://sagaras.awardspace.com/