• [Java] 使用cookie保持Session (Axis2 和 WSIT)


    Axis2:

    Session:_operationClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.HEADER_COOKIE, strCookie);
       _operationClient.getOptions().setManageSession(true);


    Axis2 压缩 Gzip:
    _operationClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);




    WSIT:
      Service s = new Service();
      BindingProvider bt = (BindingProvider) s.getWSHttpBindingIService();
      bt.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
      
     
      IService t = (IService) bt;

      String str = t.doWork("aa1");
      System.out.println(str);
      
      Headers headers = (Headers) bt.getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
      Headers headersForRequest = new Headers();

      Iterator<String> iterator = headers.keySet().iterator();
      
      for(; iterator.hasNext();)
      {
       String key = iterator.next();
       List<String> value = headers.get(key);
       
       
       System.out.println(key);
       System.out.println(value);
       System.out.println("----");
       

       
       if(key != null)
       {
        if(key.toLowerCase().equals("set-cookie"))
        {
         key = "cookie";
        }
        
        headersForRequest.put(key, value);
       }
      }

      String str2 = t.doWork("aa2");
      System.out.println(str2);
      


      
      Service2 ss = new Service2();
      BindingProvider btt = (BindingProvider) ss.getWSHttpBindingIService2();
      btt.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
      btt.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headersForRequest);
     
      
      
      IService2 tt = (IService2) btt;
      

      String vstr = tt.doWork("aabb1");
      System.out.println(vstr);
      
      String vstr2 = tt.doWork("aabb2");
      System.out.println(vstr2);
    //  XWSSecurityConfiguration.MESSAGE_SECURITY_CONFIGURATION;

  • 相关阅读:
    Vue常用特性-表单基本操作和表单修饰符
    Tab选项卡
    Vue模板语法
    Vue基本使用
    Vue概述
    Express框架
    模板引擎artTemplate
    MongoDB增删改查操作
    数据库概述及环境搭建
    请求响应原理及HTTP协议
  • 原文地址:https://www.cnblogs.com/huqingyu/p/1188368.html
Copyright © 2020-2023  润新知