平平庸庸

httpclient https

上一篇 / 下一篇  2010-11-02 16:06:28 / 个人分类:java

 String testUrl = " https://******";
//          String reqXml = XmlJaxbUtil.marshal(jc, masMessage);
          String reqXml = "<?xml ****MasMessage>";
          
          PostMethod postMethod = new PostMethod(testUrl);
          System.out.println(reqXml);
          StringRequestEntity isre = new StringRequestEntity(reqXml);
          postMethod.setRequestEntity(isre);
         
          HttpClient client = new HttpClient();
          client.getParams().setAuthenticationPreemptive(true);
          client.getState().setCredentials(new AuthScope("192.168.88.88", 8443),
                            new UsernamePasswordCredentials("2009000000***", "123456"));
          Protocol authhttps = new Protocol("https", 
                    (ProtocolSocketFactory) new AuthSSLProtocolSocketFactory(
                      new URL("file:E: \\cnphttpinterface\\*****"), "123456",
                         new URL("file:E: \\cnphttpinterface\\****"), "***"), ***);
          Protocol.registerProtocol("https", authhttps);
          client.getParams().setSoTimeout(60 * 1000);
          postMethod.setDoAuthentication(true);
         
          int status = client.executeMethod(postMethod);
          System.out.println(status);
          String respXml = null;
          if (status == 200){
           respXml = new String(postMethod.getResponseBody(), "UTF8");
          }
          System.out.println(respXml);
         }

    }
 

TAG:

 

评分:0

我来说两句

Open Toolbar