How to request a gzipped / compressed SOAP response?

前端 未结 1 1808
心在旅途
心在旅途 2021-01-22 12:58

i used the wsimport tool to create a soap client which is working very well. Now I like to request a compressed response from the server because the responses can be quite big.

1条回答
  •  别那么骄傲
    2021-01-22 13:19

    If your using ksoap jar for soap request then you need to set your compress method name on your header request. To set header your can use HeaderProperty class for that. Here is a simple example to send soap request.

        //Create Soap Object & their envelop
    SoapObject soapObject=new SoapObject(NameSpace, methodName);
    SoapSerializationEnvelope envelope=new  SoapSerializationEnvelope(SoapSerializationEnvelope.VER11);
    //Add request params into object
    soapObject.addProperty("paramsName", "paramsValue");
    //set object into envelop
    envelope.setOutputSoapObject(soapObject);
    //Set header property which we like, here I dont want to set any compression method so I set "none". For ksoap default compression method is "gzip".
    List headers=new ArrayList();
    HeaderProperty headerProperty=new HeaderProperty("Accept-Encoding", "none");
    headers.add(headerProperty);
    
    //Create transport object.
    HttpTransportSE httpTransportSE=new HttpTransportSE(url);
    //call service
    httpTransportSE.call(SOAP_ACTION, envelope,headers);
    //recive response
    JSONResponse=(String)envelope.getResponse();
    

    0 讨论(0)
提交回复
热议问题