Invoking web services via proxy using JAX-RPC and JAX-WS

Invoking Web Services through a proxy using JAX-WS

  MyService service = null;
    service = new MyService();

    MyServiceSoap port = service.getMyServiceSoap();
    BindingProvider bp = (BindingProvider) port;
    Binding binding = bp.getBinding();

    Map ctx = bp.getRequestContext();
    ctx.put(BindingProvider.USERNAME_PROPERTY, "proxyuser");
    ctx.put(BindingProvider.PASSWORD_PROPERTY, "proxypassword");
Note that we don't specify the Proxy Server here. JAX-WS sends authentication information for the proxy in request headers.

Invoking Web Services through a proxy using JAX-WS

    private HttpTransportInfo getHttpInfo() {
    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyServer", 9090));
    HttpTransportInfo httpInfo = new HttpTransportInfo();
    httpInfo.setProxy(proxy);

    httpInfo.setProxyUsername("proxyuser".getBytes());
    httpInfo.setProxyPassword("proxypassword".getBytes());
    return httpInfo;
  }
Reference: http://java-x.blogspot.hk/2009/03/invoking-web-services-through-proxy.html

留言

這個網誌中的熱門文章

Disable ionic's sidemenu content drag to toggle menu

java.lang.NoClassDefFoundError: org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl$Parser

Multiple writable mappings exist for the field. Only one may be defined as writable, all others must be specified read-only.