QUESTION: how can I use a different encoding (charset and transfer) with axis?
Here is my client:
public Object[] invoke(String xmlRepresentation) throws CustomApplicationException { Object[] responseWS = null; RPCServiceClient serviceClient = new RPCServiceClient(); Options options = serviceClient.getOptions(); options.setAction('WBSREFT'); options.setTo(new EndpointReference('http://localhost:6132')); QName qName = new QName(XML_SCHEMA, operation); Object[] args = new Object[] { 'blablabla' }; responseWS = serviceClient.invokeBlocking(qName, args, returnTypes); String responseAsString = (String) responseWS[0]; return responseWS; }
Here is the SOAPEnvelope being generated (captured using TCP/IP Monitor):
<?xml version='1.0' encoding='http://schemas.xmlsoap.org/soap/envelope/'?> <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> <soapenv:Body> <WBSREFT xmlns='http://tempuri.org/LICPOCSampleService'> <arg0 xmlns=''>blablabla</arg0> </WBSREFT> </soapenv:Body> </soapenv:Envelope>
WHY Axis2 generated this stupid encoding (http://schemas.xmlsoap.org/soap/envelope)???
Using Apache TCPMon I’ve captured this request:
POST / HTTP/1.1 Content-Type: text/xml; charset=UTF-8 SOAPAction: 'WBSREFT' User-Agent: Axis2 Host: 172.17.192.113:6133 Transfer-Encoding: chunked 102 <?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> <soapenv:Body> <WBSREFT xmlns='http://tempuri.org/LICPOCSampleService'> <arg0 xmlns=''>to cobol</arg0> </WBSREFT> </soapenv:Body> </soapenv:Envelope>0
If I send the XML request using soapUI that’s what TCPMon captures:
POST / HTTP/0.9 Content-Type: text/xml;charset=UTF-8 SOAPAction: '' User-Agent: Jakarta Commons-HttpClient/3.1 Host: 172.17.192.113:6133 Content-Length: 265 <?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> <soapenv:Body> <WBSREFT xmlns='http://tempuri.org/LICPOCSampleService'> <arg0 xmlns=''>to cobol</arg0> </WBSREFT> </soapenv:Body> </soapenv:Envelope>
I’ve noticed this weird output: 102 and 0 in the middle of the XML… what can it be?
After all Eclipse’s plugin TCP/IP Monitor was apparently not giving me the right XML request leading me to wrong directions.
It was showing encoding=’http://schemas.xmlsoap.org/soap/envelope/’, while Apache TCPMon gave me different (RIGHT) results.
As saua noted, problem was the Chunk encoding, which you can change with this (AND SOLVED MY PROBLEM):
And to answer my question: