Charset encoding problem from Linux to Windows with Dispatch
cavani Apr 1, 2008 11:10 AMHi,
I am using JBossWS Native for client code implementation in a set of Eclipse plugins. At first, I used WSDL2Java approach to generate client code - this works fine with WS-Security and all. But now, I need take advantage of BIRT's WS/XML ODA driver (that uses something like XPath to map XML as tables).
So, I converted all generated code to Dispatch approach with StreamSource. My first problem was with WS-Security with Dispatch not decrypting response. This was fixed with 2.0.4, and works perfectly when server and client are on Linux machines. But when I ran the client on a Windows XP, no accent character is read, but the message are decrypted.
The server is an unmodified AS 4.2.2 (running on linux). Java 5 (13 for linux, 15 for windows bundled together).
I start digging into JBossWS code but could not find an fix yet.
My code (it work fine on linux-linux):
QName serviceName = new QName("http://tlon.com.br", local); QName portName = new QName("http://tlon.com.br", local + "Port"); Service service = Service.create(wsdlLocation, serviceName); Dispatch<StreamSource> dispatch = service.createDispatch(portName, StreamSource.class, Mode.MESSAGE); Map<String, Object> reqContext = dispatch.getRequestContext(); reqContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress); reqContext.put(BindingProvider.USERNAME_PROPERTY, username); reqContext.put(BindingProvider.PASSWORD_PROPERTY, ""); ConfigProvider config = (ConfigProvider) dispatch; config.setSecurityConfig(DispatchFactory.class.getClassLoader().getResource("META-INF/jboss-wsse-client.xml").toExternalForm()); config.setConfigName("Standard WSSecurity Client");
Reader requestReader = new StringReader(requestMessage); StreamSource request = new StreamSource(requestReader); StreamSource response = dispatch.invoke(request); requestReader.close(); Reader responseReader = response.getReader(); StringWriter responseWriter = new StringWriter(); char[] buffer = new char[1024]; int read = -1; while ((read = responseReader.read(buffer)) != -1) responseWriter.write(buffer, 0, read); responseReader.close(); return responseWriter.toString();
If someone has a good clue, please let me know... if I find a fix I will report here.
Thanks,