Re: encoding problem

Aleksander Slominski <[email protected]> Fri, 16 Sep 2005 11:16:58 -0500
Newsgroups gmane.comp.apache.webservices.wsif.user
Message-ID <[email protected]>
[email protected] wrote:

> Hello
>
> Alek, can you please tell me if there is any way to deal with 
> encodings in WSIF, I’m using too much WSIF but I’m having problems 
> with different encodings than "UTF-8"
>
> How can I set in the request a header like this:
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> It is possible to set a different encoding in wsif than the one 
> declared in the header for the content of a response?
>
please keep in mind that WSIF uses underlying providers such as AXIS to 
actually send messages so the question has two parts:
1) can AXIS1 can do it
2) how to pass request this from AXIS1 through WSIF API

looking through code you can find WSIFOperation_ApacheAxis is actually 
translating WSIF API into AXIS invocation and after looking into it 
(unfortunately I did not write it so i am not 100% sure) it seems that 
if you cast your WSIFPort to WSIFPort_ApacheAxis then you can access 
AXIS org.apache.axis.client.Call object and set whatever properties you 
like - i do not have AXIS/JAX-RPC code handy but i think you can set 
property CHARACTER_SET_ENCODING 
("javax.xml.soap.character-set-encoding") to value of encoding you like 
if my guessing is right :)

HTH,

alek

>
>
>
> -----Juan David Perez Echeverri/assist wrote: -----
>
>
> To: [email protected]
> From: Juan David Perez Echeverri/assist
> Date: 09/13/2005 06:54PM
> Subject: encoding problem
>
> Hello All,
>
> I have a problem when I try to consume a service that return an object 
> that uses the charset=ISO-8859-1 in some of fields I get the following 
> error:
>
> AxisFault
> faultCode: {http://xml.apache.org/axis/}Server.userException
> faultString: org.xml.sax.SAXParseException: An invalid XML character 
> (Unicode: 0x4) was found in the element content of the document.
> faultActor: null
> faultDetail:
> stackTrace: org.xml.sax.SAXParseException: An invalid XML character 
> (Unicode: 0x4) was found in the element content of the document.
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at 
> org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:232)
> at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:546)
> at org.apache.axis.Message.getSOAPEnvelope(Message.java:377)
> at org.apache.axis.client.Call.invokeEngine(Call.java:2132)
> at org.apache.axis.client.Call.invoke(Call.java:2102)
> at org.apache.axis.client.Call.invoke(Call.java:1851)
> at org.apache.axis.client.Call.invoke(Call.java:1777)
> at 
> org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.invokeAXISRPCStyle(WSIFOperation_ApacheAxis.java:1548)
> at 
> org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.invokeRequestResponseOperation(WSIFOperation_ApacheAxis.java:1433)
> at 
> org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.executeRequestResponseOperation(WSIFOperation_ApacheAxis.java:1037)
> at 
> ve.com.cantv.common.hera.message.framework.wsif.WSIFInvoker.sendSyncMessage(WSIFInvoker.java:55)
> at 
> ve.com.cantv.common.hera.message.framework.wsif.WSIFMessageHandlerSyncImpl.sendSyncMessage(WSIFMessageHandlerSyncImpl.java:50)
> at 
> ve.com.cantv.common.hera.message.sync.MessageHandlerSyncManager.sendSyncMessage(MessageHandlerSyncManager.java:68)
> at 
> ve.com.cantv.common.hera.message.util.MessageInvokerUtil.executeInvocation(MessageInvokerUtil.java:50)
> at 
> ve.com.cantv.ctc.test.SA0030customerCaseDetails.main(SA0030customerCaseDetails.java:40)
>
> If the service do not return any especial characters works just fine.
>
> I used the WS-I monitor and I realized that the request and the 
> response have the following header:
> <?xml version="1.0" encoding="UTF-8"?>
>
> I think that’s where the problem is because the declared encoding is 
> different that the one used. I asked the services team and they said 
> that the server will set in the response the same encoding founded in 
> the request. So I guess I can solve the problem by changing the 
> request content type, how can I do that in WSIF?
> Is there a way to specify the encoding to use for the Deserialization 
> of a specific object, attribute or request?
>
> Thanks in advance
>
> ___________________________________
> Juan David Pérez
>


-- 
The best way to predict the future is to invent it - Alan Kay