Skip to main content

Error failed to connect WS with jax-ws

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
lenoil
Offline
Joined: 2013-03-28

Hi all,

I need to connect to a web service then write a java client.
So I use the wsimport tool to generate the classes to connect to this service.
The problem is that this service requires authentication with login / password, so I test from the browser and retrieve the wsdl locally.

So I had a class (JAX-WS) as what:

private final static URL CLIENTPULLSERVICE_WSDL_LOCATION;
    private final static Logger logger = Logger.getLogger(XXXX.class.getName());
    static {
        URL url = null;
        try {
            URL baseUrl;
            baseUrl = pkg.ClientPullService.class.getResource(".");
            url = new URL(baseUrl, "file:/XXXXXXXXXX.wsdl");
        } catch (MalformedURLException e) {
            logger.warning("Failed to create URL for the wsdl Location: 'file:/XXXXXXXXXX.wsdl', retrying as a local file");
            logger.warning(e.getMessage());
        }
        CLIENTPULLSERVICE_WSDL_LOCATION = url;
    }
    public ClientPullService(URL wsdlLocation, QName serviceName) {
  super(wsdlLocation, serviceName);
    }
    public ClientPullService() {
        super(CLIENTPULLSERVICE_WSDL_LOCATION, new QName("XXXXXXXXXXX", "clientPullService"));
    }

When I try to use this service:
ClientPullService clientPullService = new ClientPullService();
ClientPullInterface port = clientPullService.getXXXXXXXXXXXPort();
BindingProvider prov = (BindingProvider) port;
Map<String, Object> requestContext = prov.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"https://XXXXXXXXXX");
Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("Username", Collections.singletonList("xxx"));
headers.put("Password", Collections.singletonList("xxx"));
requestContext.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
D2LogicalModel datex2Data = port.getMethodX();

I have this error:

javax.xml.ws.WebServiceException: Failed to access the WSDL at: XXXXX?wsdl. It failed with:
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

What's the problem ? I don't understand ....

If I use the tool soapUI, it work with next parameters:
- Autorisation type preremptive with login/password
- check enable/disable WS-A Addressing

Thanks very much