I've got a Silverlight client application that sends a string "including characters ş ţ ă and â î" over to a Java jax-ws SOAP service.
Now, no matter what I do, I always get "including characters ? ? ? and â î" on the other side. ( "â î" work but the others don't).
I've even tried HttpUtility.UrlEncode("ş ţ ă and â î")
in silverlight, but URLDecoder.decode(inputText, "UTF-8")
in Java still gives me ?s instead of those 3 characters.
What's going on? Java strings are supposed to be encoded in UTF-8 by default, right? And the encoding in .net is Unicode (actually UTF-16). But if I decode with Unicode or UTF-16 on the java side, I get ALL those special chars turned to ?s (â î included).
Any help much appreciated!
[edit] I would love to see what encoding am I using on the Silverlight side, or to specify an encoding myself. The problem is, I can't figure out where/how to do this: The client I've created was by Service References -> Add Reference where I specified the WSDL, and from there, .NET did everything for me, created a Client class and the required events and functions. Here's what the gist of my client looks like:
FooWildcardSOAPClient client = new FooWildcardSOAPClient();
client.CallFooServiceCompleted += new EventHandler<CallFooServiceCompletedEventArgs>(client_CallFooServiceCompleted);
client.CallFooServiceAsync(param1, HttpUtility.UrlEncode(inputString), args);
I browsed the auto generated code but couldn't figure out where to specify an encoding.
And here is the Java side:
@WebService(targetNamespace = "http://jaxwscalcul.org",
name="FooWildcardSOAP",
serviceName="FooWildcardService")
@SOAPBinding( style=SOAPBinding.Style.DOCUMENT,
use=SOAPBinding.Use.LITERAL)
public class FooWildcardServiceImpl {
@WebMethod(operationName="CallFooService", action="urn:FooWildcardService")
@WebResult(name="result")
public String getOutput(
@WebParam(name="FooServiceWSDL") String param1,
@WebParam(name="inputTextOrXML") String inputText,
@WebParam(name="otherArgsString") String[] otherArgs)
{
try {
inputText = URLDecoder.decode(inputText, "UTF-16LE");//ISO-8859-1
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
System.out.println("\r\n\r\n"+inputText);
}
[EDIT2] I've used Fiddler, and I can see that the content on the wire is text/xml UTF-8, and the actual data, as in the "ş ţ ă" chars that don't show in java, DO show on the wire, correctly.
Here's a few pastes from Fiddler:
Client:
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6,ro;q=0.4,fr-FR;q=0.2,de;q=0.2
Entity:
content-type: text/xml; charset=utf-8