users@jax-ws.java.net

Re: NullPointerException when running client

From: kathy walsh <Kathleen.Walsh_at_Sun.COM>
Date: Wed, 28 Jun 2006 11:34:41 -0400

Daniel- Please see below-

Daniel Robinson wrote:

>
> Kathy,
>
> Thanks for the quick reply.
>
> The server side in running in Java 6_beta2_b84 (and therefore the
> integrated jaxws).

yes

>
>
> The client side is running on Java 5 with version
> JAXWS2.0.1ea_2006-06-23_11-00-18.jar that I downloaded from the
> nightly build web site : https://jax-ws.dev.java.net/ri-download.html.

Ok beware that JAXWS 2.0.1ea nightly builds can be very unstable. If you
need stability of the bits use JAXWS 2.0 FCS.

>
>
> I am not quite certain what you mean by your HelloService example.
> What service class do you want me to instantiate? I do not have a
> service implementation on the client side. All I have is a java
> interface that matches the WSDL signature.

Where did you get the java interface?

>
>
> Is this the part that I went wrong? Should I have generated something
> on the client side based on the WSDL?

Yes. Typically, the JAXWS client side programming model with java 5 is
to generate needed classes from the WSDL.
Included in these generated classes would be the service class and the
java sei reflecting the wsdl to java
mapping, along with any javabean classes. The service class would be
instantiated and the getPort() method
invoked on the service.

Generating needed classes is done using the wsimport tools. Please read
the Users guide that comes with jaxws 2.0
regarding tool use.

After you read this info on wsimport let us know if you have any questions-

Thanks,
Kathy


>
>
>
> Daniel
>
>
>
> On 28/06/06, * kathy walsh* <Kathleen.Walsh_at_sun.com
> <mailto:Kathleen.Walsh_at_sun.com>> wrote:
>
>
> Daniel,
>
> What version of jaxws are you using with your program and where
> did you
> get it from?
>
> I suspect that there is a difference in the runtime you are using of
> jaxws that comes with java 6
> versus what you are using with java 5.
>
> In your program try creating the service by instantiating the
> service class.
>
> HelloService helloService = new HelloService();
>
> HelloPort hello = helloService.getHelloPort();
>
>
> Please let us know if you have more problems-
>
> Thanks,
> Kathy
>
>
>
>
>
> Daniel Robinson wrote:
>
> >
> > Hello all,
> >
> > I have got a simple WebService running. I have successfully
> called it
> > from Perl.
> >
> > I have also sucessfully called it using a java client running in
> Java 6.
> >
> > However I now need to get this working in Java 5. I am starting
> by the
> > client side of things. This is where I get the
> NullPointerException. I
> > have had a look through the source code and am unsur how this
> could work.
> >
> > This is the trace I get :
> >
> > java.lang.NullPointerException
> > at
> >
> com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:352)
> > at com.sun.xml.ws.client.WSServiceDelegate.getPort
> > (WSServiceDelegate.java:242)
> > at javax.xml.ws.Service.getPort(Service.java:94)
> > at
> >
> jet.container.managers.webservicesclient.WebServicesClientManager$1.run
> (WebServicesClientManager.java:101)
> > at java.security.AccessController.doPrivileged (Native Method)
> > at
> >
> jet.container.managers.webservicesclient.WebServicesClientManager.getWebServiceInstance
> (WebServicesClientManager.java:96)
> > at
> >
> jet.container.managers.webservicesclient.WebServicesClientManager.invoke
> > (WebServicesClientManager.java:77)
> > at
> > jet.container.exchange.AbstractContext.invoke
> (AbstractContext.java:300)
> > at
> >
> jet.container.managers.webservicesclient.WebServicesClientManagerContextImpl.getWebServiceInstance
> > (WebServicesClientManagerContextImpl.java:28)
> > at
> >
> be.inveo.jet.test.webservices.WebServiceTestNut.run(WebServiceTestNut.java:92)
> > at java.lang.Thread.run(Thread.java:595)
> >
> >
> > AS you can see the problem starts in the getPort method. This is
> how
> > things are called in the client :
> >
> >
> > private Object getWebServiceInstance(final Class sei, final URL
> > wsdlLocation, final String namespaceURI, final String serviceName,
> > final String portName) throws ConnectException {
> > final QName serviceQName = new QName(namespaceURI,
> serviceName);
> >
> > Object obj = null;
> > try {
> > obj = AccessController.doPrivileged(new
> > PrivilegedExceptionAction<Object>() {
> > public Object run() throws Exception {
> > Service service = Service.create(wsdlLocation,
> > serviceQName);
> >
> > QName portQName = new QName(namespaceURI,
> portName);
> > Object proxy = service.getPort(portQName, sei);
> > BindingProvider bp = (BindingProvider) proxy;
> >
> > Map<String, Object> context =
> bp.getRequestContext();
> >
> > context.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,
> Boolean.TRUE);
> >
> > return proxy;
> > }
> > });
> > } catch (PrivilegedActionException pae) {
> > Throwable t = pae.getCause();
> > if (t instanceof WebServiceException) {
> > WebServiceException wse = (WebServiceException) t;
> > throw wse;
> > }
> > if (t instanceof ConnectException) {
> > ConnectException ce = (ConnectException) t;
> > throw ce;
> > }
> > }
> >
> >
> > return obj;
> > }
> >
> >
> >
> > When I run this through the debugger I can see that the problem is
> > that the seiContext in the WSServiceDelegate is empty. This is the
> > case as the addSEI() method is not called in the constructor as the
> > serviceClass == Service.class.
> >
> > It is not clear where I have gone wrong (though I am certain I have
> > gone wrong somewhere). The NullPointerException is not much help
> however.
> >
> > Does anybody with a better understanding of the inner workings of
> > JAX-WS know what is going on here?
> >
> > Thank you in advance for any help.
> >
> > Daniel
> >
> >
> >
> >
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jax-ws.dev.java.net
> <mailto:users-unsubscribe_at_jax-ws.dev.java.net>
> For additional commands, e-mail: users-help_at_jax-ws.dev.java.net
> <mailto:users-help_at_jax-ws.dev.java.net>
>
>