Web service client receiving a NullPointerException from getMyWSPort

I created a simple web service called TimeServerBean . It works correctly, the GlassFish server is running, and I can access the WSDL file from the browser. Please note that this is done on the local host.

Then I created a new project and made a web service client and provided the URL of the WSDL file. Then I got some classes (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 getTimeServerBeanPort . During this time, the server is up and running. Is there any obvious mistake? TimeServerBean and TimeServerBean_Service classes are created from WSDL.

+4
source share
2 answers

Two suggestions:

  • DEFINITELY put your method in a try / catch

  • Assuming service itself is NULL, try making explicit service.create() instead of using the @WebServiceRef annotation. Here is a good example (Websphere, but the same principle):

http://www-01.ibm.com/support/docview.wss?uid=swg21264135

+4
source

@WebServiceRef annotations are supported only in certain class types. Examples are JAX-WS endpoint implementation classes, JAX-WS handler classes, Enterprise JavaBeans classes, and servlet classes. This annotation is supported in the same class types as the @Resource annotation. See the Java Platform Specification, Enterprise Edition (Java EE) 5 for a complete list of supported class types.

0
source

Source: https://habr.com/ru/post/1395132/


All Articles