axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geuze, Marinus" <Marinus.Ge...@getronics.com>
Subject Retry: Axis2 - Retrieving SOAPBody through MessageContext versus OMException (WstxUnexpectedCharException)
Date Thu, 26 Feb 2009 09:50:00 GMT
> Dear Axis2 Users,
> 
> I hope you can help me with this problem.
> 
> This is the situation. I use the Axis2 framework for accessing a WebService. When I use
the generated Stub then everything works perfectly fine. However I want to obtain the actual
message which is sent to and received from the WebService. This is for logging reasons. Here
the problem starts. See my code example below.
> 
> //Create Stub
> QuickCarRentalServiceStub testStub = new QuickCarRentalServiceStub(url);
> 
> //Set Stub options (only those who are needed)
> Options options = testStub._getServiceClient().getOptions();
> 				
> //Set http protocol version
> options.setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION, 	HTTPConstants.HEADER_PROTOCOL_11);
> 				
> //Set soap version (example: SOAP 1.1 (SOAP11Constants) or SOAP 1.2 //(SOAP12Constants))
> options.setSoapVersionURI(
> 	org.apache.axiom.soap.SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
> 				
> //Set input of proxy method
> CancelBookingDocument input = CancelBookingDocument.Factory.newInstance();
> CancelBookingDocument.CancelBooking secondInput =
> 	CancelBookingDocument.CancelBooking.Factory.newInstance();
> secondInput.setBookingId("1");
> input.setCancelBooking(secondInput);
> 
> //Execute Stub method
> CancelBookingResponseDocument output = testStub.cancelBooking(input);
> 				
> //Get output of proxy method
> String responseAsString = output.getCancelBookingResponse().getResponse();
> 
> //Till now everything is fine. The responseAsString contains a valid value.
> 
> MessageContext msgContextIn = testStub._getServiceClient().getLastOperationContext().getMessageContext("In");
> SOAPEnvelope soapEnvIn = msgContextIn.getEnvelope();
> SOAPBody soapBodyIn = soapEnvIn.getBody();
> return soapBodyIn.toString();
> 
> The soapBodyIn.toString() throws a OMException with the errormessage > '> com.ctc.wstx.exc.WstxUnexpectedCharException:
Unexpected character 'V' (code 86) in epilog; expected '<' at [row,col {unknown-source}]:
[1,593]> '>  
> 
> The returned soap message is (obtained with use of TCPMON, and the message seems valid):

> 
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><rpl:cancelBookingResponse
xmlns:rpl='urn:QuickCarRentalServiceVi'><Response>1 cancelled.</Response></rpl:cancelBookingResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
> 
> My question is this: Why does the output object work and why does the soapBodyIn.toString()
fails? I really hope someone can help.
> 
> I use Axis version 1.4.1 and Axiom version 1.2.8.
> 
> Thanks in advantage.
> 
> Kind regards, 
> Marinus 

Mime
View raw message