Monday, April 2, 2012

Create HTTPS Web Service Client

HTTPS web services uses certificate authentication. So, web service clients must be created with SSL.

In netbeans, you can create HTTPS web service client. Follow the steps.

1) Create Java project in Netbeans
2) Copy certificate into project root directory
3) Use Netbeans Web Service Client wizard to create client 

This will create web service clients successfully. But, when calling service, it is again needed to create SSL session with service.

Before calling service, certificate needs to be stored in java key store. 

Refer article on seguide :-

Use following code before calling service methods.

System.setProperty("", "export/home/myTrustStore"); System.setProperty("", "changeit"); 
System.setProperty("", "JKS"); System.setProperty("java.protocol.handler.pkgs", ""); Security.addProvider(new; 

URL url = new URL("https://~~~~~~~~~~~~~~~~~~~/service.asmx?wsdl");
Service service = new Service(url); service.getServiceSoap().getData();