I have created a simple web service called TimeServerBean. It’s working properly, the GlassFish server is running and I can access the WSDL file from browser. Note this is done on local host.
Next I created a new project and made a web service client and provided the URL to the WSDL file. Then I got some classes generated (JAX-WS).
On my client class I have this code:
public class SimpleClient {
@WebServiceRef(wsdlLocation = "wsdl url here")
static TimeServerBean_Service service;
private TimeServerBean bean;
public SimpleClient() {
bean = service.getTimeServerBeanPort();
}
//methods here
}
Although I get null when I call the getTimeServerBeanPort. During that time the server is up and running. Is there some obvious mistake? TimeServerBean and TimeServerBean_Service are generated classes from the WSDL.
Two suggestions:
DEFINITELY put your method in a
try/catchblockAssuming that
serviceitself is null, then try doing an explicitservice.create()instead of using the@WebServiceRefannotation. Here’s a good example (Websphere, but same principle):http://www-01.ibm.com/support/docview.wss?uid=swg21264135