You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Kim Thrysøe <kt...@atira.dk> on 2005/04/18 15:07:56 UTC
Encoding request as iso8859_1
Is it possible to configure Axis to post requests using a charset other
that UTF8, eg. iso8859_1?
This question has been posted a while ago
(http://marc.theaimsgroup.com/?l=axis-user&m=104617666812022&w=2), but I
failed to find a response.
thanks
kim
Re: Encoding request as iso8859_1
Posted by jayachandra <ja...@gmail.com>.
Hi Kim!
I've a work around suggestion to the problem you described. Try using
the call.invoke(Message msg) method call by creating your own message
(needn't fear, it could be as simple as changing a few lines here and
there of a template file) and setting the "javax.xml.soap.encoding"
property of that Message to your custom encoding say "ISO-8859-1".
This would enable you to set the HTTP contentType sent as the your
custom encoding. Below is the listing of a TestClient which tries to
invoke a EchoStirng method of sample Echo service hosted on localhost
in the described way. It worked for me. Hope you would find it useful
/*
* Created on Apr 19, 2005
*
*/
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import javax.xml.namespace.QName;
/**
* @author sunja07
*
*/
public class TestClient1 {
public static void main(String[] args) throws Exception{
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress("http://localhost:9090/axis/services/Echo");
MessageContext msgCtxt = call.getMessageContext();
String sXML =
"<soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+ "<soapenv:Body>"
+ "<ns1:EchoString
soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"
xmlns:ns1=\"http://myownurl.org\">"
+ "<ns1:arg0 xsi:type=\"soapenc:string\"
xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"
xmlns:ns1=\"http://myownurl.org\">Hi, World! ß is a foreign
character</ns1:arg0></ns1:EchoString>"
+ "</soapenv:Body>"
+ "</soapenv:Envelope>";
sXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + sXML;
Message oMsg;
oMsg = new Message (sXML);
oMsg.setProperty("javax.xml.soap.character-set-encoding","ISO-8859-1");
msgCtxt.setRequestMessage(oMsg);
Object result = call.invoke(oMsg);
//Object result = call.invoke(new Object[]{"Hi, World! ß is a
foreign character"});
System.out.println("Returned result is: " + result.toString());
}
}
P.S:: Actually returned object is a SOAPEnvelope, so you would see as
output the whole envelope when you run this.
Bye
Jayachandra
On 4/19/05, Kim Thrysøe <kt...@atira.dk> wrote:
> The scenario is this: I use axis as ws client to call a server which
> takes the data from a search request and forwards it without
> modification to a legacy system. This legacy system requires the
> characters recieved in search queries to be latin1, not UTF8.
>
> With the tcp-dump of what is actually transmitted on the wire I see that
> it is indeed UTF8, where the letter ø (ø) is transmitted as two
> bytes.
>
> The best solution is of course to have the server handle encoding in a
> better way. But unfortunately I cannot do this, so I will have to post
> iso8859 in stead.
>
> /kim
>
>
> Venkat Reddy wrote:
>
> >Do you have a test case that demostrates the issue?
> >
> >thanks
> >venkat
> >
> >On 4/18/05, Kim Thrysøe <kt...@atira.dk> wrote:
> >
> >
> >>Is it possible to configure Axis to post requests using a charset other
> >>that UTF8, eg. iso8859_1?
> >>
> >>This question has been posted a while ago
> >>(http://marc.theaimsgroup.com/?l=axis-user&m=104617666812022&w=2), but I
> >>failed to find a response.
> >>
> >>thanks
> >>kim
> >>
> >>
> >>
>
>
--
-- Jaya
Re: Encoding request as iso8859_1
Posted by Kim Thrysøe <kt...@atira.dk>.
The scenario is this: I use axis as ws client to call a server which
takes the data from a search request and forwards it without
modification to a legacy system. This legacy system requires the
characters recieved in search queries to be latin1, not UTF8.
With the tcp-dump of what is actually transmitted on the wire I see that
it is indeed UTF8, where the letter ø (ø) is transmitted as two
bytes.
The best solution is of course to have the server handle encoding in a
better way. But unfortunately I cannot do this, so I will have to post
iso8859 in stead.
/kim
Venkat Reddy wrote:
>Do you have a test case that demostrates the issue?
>
>thanks
>venkat
>
>On 4/18/05, Kim Thrysøe <kt...@atira.dk> wrote:
>
>
>>Is it possible to configure Axis to post requests using a charset other
>>that UTF8, eg. iso8859_1?
>>
>>This question has been posted a while ago
>>(http://marc.theaimsgroup.com/?l=axis-user&m=104617666812022&w=2), but I
>>failed to find a response.
>>
>>thanks
>>kim
>>
>>
>>
Re: Encoding request as iso8859_1
Posted by Venkat Reddy <vr...@gmail.com>.
Do you have a test case that demostrates the issue?
thanks
venkat
On 4/18/05, Kim Thrysøe <kt...@atira.dk> wrote:
> Is it possible to configure Axis to post requests using a charset other
> that UTF8, eg. iso8859_1?
>
> This question has been posted a while ago
> (http://marc.theaimsgroup.com/?l=axis-user&m=104617666812022&w=2), but I
> failed to find a response.
>
> thanks
> kim
>