You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Ann Flory <An...@thirdspace.tv> on 2002/03/29 04:09:46 UTC

Corrupted Japanese Data in SOAP Response

Hello, 
I'm trying to return Japanese data (Shift_JIS) in XML from my SOAP service.
I've tried a couple of approaches and continue to get corrupted data.  The
XML on the server end looks perfect, but when I receive it at the client,
it's not what I expect.

In my first attempt I tried to send the XML as an Element. This is how I set
up the call in my client:

        Call call = new Call(); 
        call.setTargetObjectURI( serviceId ); 
        call.setMethodName( "select" ); 
        call.setEncodingStyleURI( Constants.NS_URI_LITERAL_XML ); 

        Vector params = new Vector(); 

        params.addElement( new Parameter( "max", 
                                       int.class, 
                                       new Integer( 50 ), 
                                       Constants.NS_URI_SOAP_ENC ) ); 

When I printed this out to a file, the Japanese text was wrong and included
question marks.

In my second attempt, I decided to try make the a string out of the Element
and return that string.  The client code looked like this:
 
    Locale.setDefault(new Locale("ja","JP"));

    Call call = new Call();
    call.setTargetObjectURI( serviceId );
    call.setMethodName( "select" );
    call.setEncodingStyleURI( Constants.NS_URI_SOAP_ENC );

    Vector params = new Vector();

    // Specify to return a maximum of 50 records
    params.addElement( new Parameter( "max",
                                      int.class,
                                      new Integer( 50 ),
                                      null ) );

This result was better, but still not right.  The output did have the
correct Japanese characters, but also included several extra ones.

Does anyone have any suggestions on how to fix this?  Any help would be
greatly appreciated.

Thanks! 
-ann