0

我想为 SOAPMessage 实现 GZIP。下面是普通的 SOAP 客户端调用代码 -

    // Create a new SOAP message from the factory and set the SOAPAction header.

    MessageFactoryImpl factory = new MessageFactoryImpl();
    SOAPMessage soapMsg = factory.createMessage();

    // Set the SOAP envelope contents to our ebXML DOM.

    SOAPPart part = soapMsg.getSOAPPart();
    part.setContent(new DOMSource(docSoapReq));

    // Create a SOAPConnection to send the SOAP request on.

    SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection con = conFactory.createConnection();

    // Point to the service we want to call, and then call it.  
    // Store the response in  the "reply" object.

    URLEndpoint endPoint = new URLEndpoint(serviceURL);


    SOAPMessage reply = con.call(soapMsg, endPoint);
    con.close();

    return (reply);

我如何在上述代码中的 SOAPMessage 中实现 GZIP。我为此做了谷歌,但没有找到任何有用的东西。

请告知我如何实现它 SOAPMessage。

4

2 回答 2

2
MimeHeaders headers = soapMsg.getMimeHeaders();
heders.addHeader("Accept-Encoding", "gzip,deflate");

在 jdk 1.6 中给出不可读的响应

于 2012-10-23T07:07:23.903 回答
0

Try something like the following to set the accept-encoding header:

MimeHeaders headers = soapMsg.getMimeHeaders();
heders.addHeader("Accept-Encoding", "gzip,deflate");
于 2011-07-05T03:46:30.267 回答