zoukankan      html  css  js  c++  java
  • AXIS2调用web service,返回结果用GZIP解压缩

    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.util.zip.GZIPInputStream;
    
    import javax.xml.namespace.QName;
    
    import org.apache.axiom.soap.SOAP12Constants;
    import org.apache.axis2.addressing.EndpointReference;
    import org.apache.axis2.client.Options;
    import org.apache.axis2.rpc.client.RPCServiceClient;
    
    public class Test3 {
    
        public static void main(String[] args) throws IOException {
            RPCServiceClient serviceClient = new RPCServiceClient();
            Options options = serviceClient.getOptions();
            EndpointReference targetRPR = new EndpointReference(
                    "http://..../LoginWebService.asmx");
            options.setTo(targetRPR);
            options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
            //参数
            Object[] opArgs = new Object[]{"test", "123456"};
            QName opEntry = new QName("http://tempuri.org/", "doctorLogin", "ns1");
            byte[] gzpdata = (byte[])serviceClient.invokeBlocking(opEntry, opArgs, new Class[]{byte[].class})[0];//第三个参数为返回类型,保存为字节数组
            
            GZIPInputStream gzip = new GZIPInputStream(new ByteArrayInputStream(gzpdata));
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            byte[] buffer = new byte[256];
            int n;
            while ((n = gzip.read(buffer)) >= 0) {
                out.write(buffer, 0, n);
            }
            System.out.println(out.toString());
        }
    }
  • 相关阅读:
    模拟器登陆
    mab算法
    用户投票排名算法总结
    vue中路由
    利用ajax全局设置实现拦截器
    对于 前端请求Django 后端服务出现403 Forbidden (CSRF token missing or incorrect.) 问题的解析
    Datatable 插入一行数据到第一行
    Datatable 导出到execl 官网demo
    jquery cookie操作
    on绑定事件支持的事件类型
  • 原文地址:https://www.cnblogs.com/549294286/p/3472837.html
Copyright © 2011-2022 走看看