开发者

Retrieving WSDL file from secure service

开发者 https://www.devze.com 2023-01-18 02:08 出处:网络
I have a Web Service developed with JAX-WS. I have secured the web service with BASIC authentication configured in Tomcat.

I have a Web Service developed with JAX-WS. I have secured the web service with BASIC authentication configured in Tomcat.

When I try to access the web service using a Java client, I first need to create the port, and then specify the credentials, as follows:

CustomerServiceClient customerServiceClient = new CustomerServiceBottomUpService(); //1
CustomerService customer = customerServiceClient.getCustomerServicePort(); //2

Map<String, Object> context = ((BindingProvider) cus开发者_Go百科tomer).getRequestContext(); //3
context.put(BindingProvider.USERNAME_PROPERTY, "kermit"); //4
context.put(BindingProvider.PASSWORD_PROPERTY, "thefrog"); //5

The problem I have is that, after line 1, I get an Authorization error (HTTP 401) as I obviously haven't provided the server with the credentials yet.

I am creating the client artifacts from a server WSDL, hence the authentication problem when creating the service, and don't want my clients to store the WSDL locally as it's just annoying for them. How can I get around this problem?


BindingProvider.USERNAME_PROPERTY, BindingProvider.PASSWORD_PROPERTY are used primarily for service requests. When you instantiate Service, it fetches WSDL and the server is returning 401. You could try any one of the following solutions:

  • Use java.net.Authenticator class in your client application.
  • Provide a local access to the WSDL using catalog.
  • Configure web.xml to allow GET requests without authentication.

Reference java.boot.by

0

精彩评论

暂无评论...
验证码 换一张
取 消