SOAPMessage GZIP实现

时间:2009-08-07 06:54:38

标签: java soap gzip message

我想为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。

2 个答案:

答案 0 :(得分:2)

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

在jdk 1.6中给出了不可读的回应

答案 1 :(得分:0)

尝试使用以下内容设置accept-encoding标头:

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