欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

通过http代理远程调用webservice SOA 

程序员文章站 2022-06-08 11:07:03
...
从局域网远程调用外网的webservice服务提供的操作。贴出代码片段。我用的是xfire


/**
     * 获取Client对象实例并设置http代理
     * @return Client
     * @throws Exception 
     */
    public Client getClient() throws Exception {

        String proxyHost = "代理ip";
        String proxyPort = "代理端口";
        System.getProperties().put("proxySet", "true");
        System.getProperties().put("proxyHost", proxyHost);
        System.getProperties().put("proxyPort", proxyPort);

        Client client = new Client(new URL(URL));
        client.setProperty(client.getOutChannel().USERNAME, "代理上的用户名");
        client.setProperty(client.getOutChannel().PASSWORD, "代理上的密码");
//        client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, "300");
        client.setProperty(CommonsHttpMessageSender.DISABLE_KEEP_ALIVE, "true");
        client.setProperty(CommonsHttpMessageSender.DISABLE_EXPECT_CONTINUE, "true");
        client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_HOST, "代理ip");
        client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT, "代理端口");
        client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_USER, "代理上的用户名");
        client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PASS, "代理上的密码");
        return client;
    }

相关标签: SOA