AXIS2 Erzeugen falsche SOAP-Nachricht wegen der Codierung. wie man es repariert?
-
03-07-2019 - |
Frage
FRAGE : Wie kann ich einen anderen Codierung (charset und Transfer) mit der Achse
Hier ist mein Kunde:
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;
}
Hier wird der SOAPEnvelope erzeugt wird (erfaßt unter Verwendung von 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>
Warum Axis2 diese dumme Codierung erzeugt ( http://schemas.xmlsoap.org/soap/envelope ) ???
Mit Apache tcpmon ich diesen Wunsch aufgenommen haben:
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
Wenn ich die XML-Anforderung mit soapUI senden, das ist es, was tcpmon erfasst:
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>
Ich habe diese seltsame Ausgabe bemerkt: 102 und 0 in der Mitte des XML ... was kann es sein
Lösung 2
Nachdem alle Plugin TCP Eclipse / IP-Monitor wurde offenbar nicht mir die richtige XML-Anforderung gibt führend mich auf falsche Richtung.
Es zeigte encoding = "http://schemas.xmlsoap.org/soap/envelope/" , während Apache tcpmon gab mir verschiedene (rechts) Ergebnisse.
Wie saua erwähnt, Problem war die Chunk-Codierung, die Sie mit dieser ändern kann (und mein Problem gelöst):
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
Und meine Frage zu beantworten:
options.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
Andere Tipps
Die 102 und 0 in der Mitte des XML sind Artefakte des. „Transfer-Encoding: Chunked“ sie nicht Teil des Inhalts sind Sie senden