How do I consume a web service protected with HTTP basic authentication using the CXF framework?

后端 未结 3 1984
渐次进展
渐次进展 2020-12-17 14:48

I tried to get it to work using the CXF User Guide, but I\'ve had no luck.

I\'m trying to call the web service using java code.

3条回答
  •  抹茶落季
    2020-12-17 15:14

    This is covered by the JAX-WS Specification. Basically, set the username/password as properties on the request context:

    ((BindingProvider)proxy).getRequestContext().put(
        BindingProvider.USERNAME_PROPERTY, "joe");
    ((BindingProvider)proxy).getRequestContext().put(
        BindingProvider.PASSWORD_PROPERTY, "pswd");
    

    The runtime puts them into the HTTP header.

提交回复
热议问题