I've been struggling recently to create a simple soap web service client in Java. I used several tools from different implementations of jax-ws to generate a client from WSDL. Even though the client gets generated, whenever I try to call a method on that service I never receive the result from that method (there's never a return after calling such method).
Sample code:
try {
TerytWs1Locator locator = new TerytWs1Locator();
ITerytWs1 service = locator.getcustom();
// If authorization is required
((CustomStub)service).setUsername("XXX");
((CustomStub)service).setPassword("YYY");
// invoke business method
System.out.println(service.czyZalogowany());
} catch (javax.xml.rpc.ServiceException ex) {
ex.printStackTrace();
} catch (java.rmi.RemoteException ex) {
ex.printStackTrace();
}
So in this case println is never called as the program stucks on service.czyZalogowany() method.
I thought that maybe the service is not running, so I generated the sample client in .NET:
try
{
var proxy = new ChannelFactory<ServiceReference1.ITerytWs1>("custom");
proxy.Credentials.UserName.UserName = "XXX";
proxy.Credentials.UserName.Password = "YYY";
var result = proxy.CreateChannel();
var test = result.CzyZalogowany();
}catch (Exception ex) { }
And I can easly call any method with the desired outcome.
What is wrong with my Java code?
Here's the wsdl for that service: https://uslugaterytws1test.stat.gov.pl/wsdl/terytws1.wsdl