如何请求一个压缩/压缩SOAP响应?(How to request a gzipped / comp

2019-07-19 02:07发布

我使用wsimport工具来创建它工作得很好SOAP客户端。 现在,我想从服务器请求一个压缩的响应,因为响应可以说是相当大的。

我不知道如果服务器是能够发送压缩内容。 据我知道我必须添加类似在请求

如何以及在哪里做呢?

谢谢

Answer 1:

如果您使用的KSOAP SOAP请求罐子,那么你需要设置你的头请求您的压缩方法的名称。 要设置页眉您可以使用HeaderProperty类为。 下面是一个简单的例子来发送SOAP请求。

    //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<HeaderProperty> headers=new ArrayList<HeaderProperty>();
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();


文章来源: How to request a gzipped / compressed SOAP response?