Hi Andreas,
The service we are accessing is Omniture Sitecatalyst webservice, which i
think we (atleast i) dont have any control over them. they are claiming that
they are sending data in UTF-8 format, i accept it is we who are sending
these invalid characters(because our site has multi language support ) to
omniture which Omniture is storing in its database, but omniture should
takecare of normalizing them when sending data back in UTF-8 format.

I added following code to my client handler to bring required stream, i put
this handler in clients InFlow Address phase,

        ByteArrayOutputStream byteOutStr = new ByteArrayOutputStream();
        SOAPEnvelope se = msgContext.getEnvelope();
        OMOutputFormat outputFormat = new OMOutputFormat();
        outputFormat.setCharSetEncoding("ISO-8859-1"); //Also tried with
differnt formats
        try{
        se.serializeAndConsume(byteOutStr, outputFormat);
        }catch (Exception e){
            e.printStackTrace();
        }

i got the byte stream but it is copy of the actual stream, the problem with
this is msgContext.getEnvelope() contains data until it reached invalid
UTF-8 character, so the same has been copied to ByteArrayOutputStream
because of this wehave only partial response, As soon as stream is coming
from the service axis2 is reading it using UTF8Reader as per below exception
stracktrace. so if we can somehow get the control of reading the actual
stream this will help us in normalizing the invalid characters before
converting it into a streamreader, can you please show how we can read raw
stream from message builder?

Thanks
Sanat.


================================================================================


The only place where you have access to the raw stream is in the
message builder.

I'm just curious: what is preventing you from having the issue fixed
by the people who implemented the service?

Andreas


On Thu, Mar 12, 2009 at 11:33 AM, Sanat Mastan Kumar
<sanatmas...@gmail.com>wrote:

> Hi Andreas thanks for your response,
>
> can you please suggest how we can take the raw response steam from axis2
> with out any char encoding applying to it?
>
> Sanat,
>
> It is the responsibility of the service to choose the encoding it
> wants to use in its response, and the service is expected to indicate
> the encoding in the Content-Type and then to use that encoding in the
> response. In your case the service fails to do so (unless you have
> discovered a very rare bug in Axis2) and violates the SOAP specs. You
> should collect the evidence for this by inspecting the response using
> TCPMon or Wireshark and tell the people who developed this service to
> fix it.
>
> Andreas
>
> On Wed, Mar 11, 2009 at 18:16, yskm <sanatmas...@gmail.com> wrote:
> >
> > Hi,
> >
> > i am consuming a webservice (dont know the implementation of the service)
> > for this i have written my client using axis2 1.4 and rampart 1.4, this
> > client is working fine under normal response payload, if response
> contains
> > any special characters like "Hello world ai? " i.e invalid UTF-8
> characters
> > myclient is breaking... following is the stacktrace....
> >
> > org.apache.axis2.AxisFault: Error in extracting message properties
> > � � � �at
> >
> org.apache.rampart.handler.RampartReceiver.setFaultCodeAndThrowAxisFault(RampartReceiver.java:166)
> > � � � �at
> >
> org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:99)
> > � � � �at org.apache.axis2.engine.Phase.invoke(Phase.java:317)
> > � � � �at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)
> > � � � �at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:163)
> > � � � �at
> >
> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:363)
> > � � � �at
> >
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
> > � � � �at
> >
> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
> > � � � �at
> > org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
> > � � � �at
> > org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:548)
> > � � � �at
> > org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
> > � � � �at
> >
> com.paypal.sparta.inbox.ws.OmnitureWSClient.callService(OmnitureWSClient.java:152)
> > � � � �at
> >
> com.paypal.sparta.inbox.ws.OmnitureWSClient.call2(OmnitureWSClient.java:88)
> > � � � �at
> com.paypal.sparta.inbox.ws.OmnitureReport.main(OmnitureReport.java:35)
> > Caused by: org.apache.rampart.RampartException: Error in extracting
> message
> > properties
> > � � � �at
> > org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:322)
> > � � � �at org.apache.rampart.RampartEngine.process(RampartEngine.java:70)
> > � � � �at
> >
> org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:92)
> > � � � �... 12 more
> > Caused by: org.apache.ws.security.WSSecurityException: Error in
> converting
> > SOAP Envelope to Document; nested exception is:
> > � � � �org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxIOException:
> Invalid
> > UTF-8 middle byte 0x66 (at char #57163, byte #56398)
> > � � � �at
> >
> org.apache.rampart.util.Axis2Util.getDocumentFromSOAPEnvelope(Axis2Util.java:161)
> > � � � �at
> > org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:158)
> > � � � �... 14 more
> > Caused by: org.apache.axiom.om.OMException:
> > com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 middle byte 0x66 (at char
> > #57163, byte #56398)
> > � � � �at
> >
> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:249)
> > � � � �at
> org.apache.axiom.om.impl.llom.OMNodeImpl.build(OMNodeImpl.java:327)
> > � � � �at
> > org.apache.axiom.om.impl.llom.OMElementImpl.build(OMElementImpl.java:706)
> > � � � �at
> >
> org.apache.rampart.util.Axis2Util.getDocumentFromSOAPEnvelope(Axis2Util.java:96)
> > � � � �... 15 more
> > Caused by: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 middle byte
> 0x66
> > (at char #57163, byte #56398)
> > � � � �at
> com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:683)
> > � � � �at
> com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1086)
> > � � � �at
> >
> org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:506)
> > � � � �at
> >
> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:161)
> > � � � �... 18 more
> > Caused by: java.io.CharConversionException: Invalid UTF-8 middle byte
> 0x66
> > (at char #57163, byte #56398)
> > � � � �at
> com.ctc.wstx.io.UTF8Reader.reportInvalidOther(UTF8Reader.java:313)
> > � � � �at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:204)
> > � � � �at com.ctc.wstx.io.MergedReader.read(MergedReader.java:101)
> > � � � �at com.ctc.wstx.io.ReaderSource.readInto(ReaderSource.java:84)
> > � � � �at
> >
> com.ctc.wstx.io.BranchingReaderSource.readInto(BranchingReaderSource.java:57)
> > � � � �at
> >
> com.ctc.wstx.sr.StreamScanner.loadMoreFromCurrent(StreamScanner.java:1021)
> > � � � �at
> com.ctc.wstx.sr.StreamScanner.parseLocalName2(StreamScanner.java:1771)
> > � � � �at
> com.ctc.wstx.sr.StreamScanner.parseLocalName(StreamScanner.java:1731)
> > � � � �at
> >
> com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2912)
> > � � � �at
> >
> com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2846)
> > � � � �at
> com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1019)
> > � � � �... 20 more
> >
> >
> > I tried different ways to change the character encoding of the response
> > input stream
> >
> > 1) by adding following options before calling the service method, this
> > didn't worked.
> >
> >
> options.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING,"UTF-16");
> > at what circumstance does this statement work??
> >
> > 2) I tried adding a handler in the InFlow phase inside Transport and
> > Addressing and with in the handler i added following statements
> >
> > � � � � � � � �SOAPEnvelope se = msgContext.getEnvelope();
> > � � � � � � � �System.out.println(se);
> > Here :) fortunately sysout is printing entire response payload , but the
> > problem is it is printing up to valid UTF-8 characters,
> >
> > inspite of all these i didnt succeed in getting a response stream,
> >
> > i have two questions
> > 1) can we change the response character encoding? before response stream
> is
> > converted in to reader.
> > 2) if not can we get raw response stream alone? later i will be parsing
> it
> > in my program?
> >
> > This is very urgent requirement any help would be highly appreciated.
> >
> > Thanks
> > Sanat.
> > --
> > View this message in context:
> http://www.nabble.com/How-to-change-Axis2-response-character-encoding-tp22460000p22460000.html
> > Sent from the Axis - User mailing list archive at Nabble.com.
>
> >
> >
>
>
> On Thu, Mar 12, 2009 at 1:33 AM, Nabble Alerts <no-re...@nabble.com>
> wrote:
> >
> > Nabble email alert
> >
> > New reply to your post How to change Axis2 response character encoding
> >
> > Re: How to change Axis2 response character encoding - 3 star
> > Sanat, It is the responsibility of the service to choose the encoding it
> wants to use in its response, and the service is expected to indicate th...
>  Read the entire message
> > by Andreas Veithen-2 on 2009-03-11 in the Axis - User forum
> >
> > Delete this alert
> >
> > ________________________________
> > DO NOT REPLY TO THIS E-MAIL.
> >
> > Replies sent to this address are not read or processed. If you want to
> respond to a Nabble post for which you received this alert, please go to the
> Nabble website.
>
>
> --
>
> Regards,
>
> Sanat
>



-- 

Regards,

Sanat

Reply via email to