Java 如何调用SOAP webserivce以及如何设置代理设置?

Java 如何调用SOAP webserivce以及如何设置代理设置?,java,web-services,soap,proxy,Java,Web Services,Soap,Proxy,我想通过代理调用webservice(SOAP)。 假设代理用户名:xyz,密码:xyz Web服务url: 服务名称:上载数据 我用过 System.getProperties().put("http.proxyHost", "some host"); System.getProperties().put("http.proxyPort", "some port"); System.getProperties().put("http.proxyUser", "usern

我想通过代理调用webservice(SOAP)。 假设代理用户名:xyz,密码:xyz

Web服务url

服务名称:上载数据

我用过

    System.getProperties().put("http.proxyHost", "some host");
    System.getProperties().put("http.proxyPort", "some port");
    System.getProperties().put("http.proxyUser", "username");
    System.getProperties().put("http.proxyPassword", "password"); // I have also tried base64 password.
但它抛出身份验证必需的异常

基本上,我需要用一些参数调用这个webservice并从中获得响应


谢谢..

您必须像这样使用验证器

final PasswordAuthentication AUTHENTICATOR = new PasswordAuthentication(proxyUser, proxyPassword.toCharArray());
                Authenticator.setDefault(new Authenticator()
                {
                    @Override
                    protected PasswordAuthentication getPasswordAuthentication()
                    {
                        if( ObjectUtil.equals(getRequestorType(), Authenticator.RequestorType.PROXY) ) {
                            return AUTHENTICATOR;
                        }
                        return null;
                    }
                });

您使用的是什么库还是纯httpconnection?@DhanaKrishnasamy I使用QName、Service、,SOAPMebug等考虑使用纯HTTP客户端来发送所创建的SOAP消息或具有代理支持的另一个套件,并且可以设置每个连接的身份验证。注意JVM中的认证器对象,JavaNET.Un认证器不能基于每个连接设置;因此,如果您将应用程序服务器与其他应用程序一起使用自己的验证器,则应用程序的“Authenticator.setDefault()”方法将重写先前定义的验证器,而其他应用程序将失败。这种行为存在一些公开的bug