Domanda

DOMANDA : come posso usare una codifica (set di caratteri e trasferimento) diversa con asse?

Ecco il mio cliente:

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;

    }

Ecco la SOAPEnvelope che viene generata (catturata usando il monitor TCP / IP):

<?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>

PERCHÉ Axis2 ha generato questa stupida codifica ( http://schemas.xmlsoap.org/soap/envelope ) ???

Utilizzando Apache TCPMon ho acquisito questa richiesta:

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

Se invio la richiesta XML usando soapUI è ciò che TCPMon acquisisce:

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>

Ho notato questo strano output: 102 e 0 nel mezzo dell'XML ... cosa può essere?

È stato utile?

Soluzione 2

Dopo tutto il plug-in TCP / IP di Eclipse apparentemente non mi stava dando la giusta richiesta XML che mi conduceva in direzioni sbagliate.

Stava mostrando encoding = " http: //schemas.xmlsoap.org/soap/envelope/" , mentre Apache TCPMon mi ha dato risultati diversi (DESTRA).

Come notato da saua , il problema era la codifica Chunk, che puoi modificare con questo (E RISOLTO IL MIO PROBLEMA):

options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);

E per rispondere alla mia domanda:

options.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");

Altri suggerimenti

I 102 e 0 nel mezzo dell'XML sono artefatti di " Transfer-Encoding: chunked " non fanno parte del contenuto inviato.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top