2 Replies Latest reply on Jun 15, 2007 8:32 AM by gsferra

    WebServiceRef injection does not work

    ulliobst

      Ha,

      I have JBoss 5.0 beta2 and jbossws-1.2.1 deployed. I wrote a simple web web-service and everything works fine, when I access the service with Service.create(...)

      But when I try to access the service with @WebServiceRef I simply get a NullPointerException.

      @WebServiceRef(wsdlLocation = "http://localhost:8080/jbaddnumbers/addservice?wsdl")
      Service service;

      The injection has not occurred and the service field is null.
      I run the client with the wsrunclient.bat provided in the bin directory of JBoss. Do I have to add some configuration files somewhere?

      Best regards
      Ulli




        • 1. Re: WebServiceRef injection does not work
          heiko.braun

          Well, looking at the wsrunclient script i'd say it's really pointless. In order for @WebServiceRef annotations to work on the client side it needs an IoC container that's capable of providing the injection. EJB3 comes with a ClientLauncher (take a look at the jaxws/samples/webserviceref/WebServiceRefClientTestCase.java) that can do it, however its not being used from the script.

          To me it look like the wsrunclient simply provides a classpath for simple (i.e. Service.create) invocations.

          I did setup an issue for this:

          http://jira.jboss.com/jira/browse/JBWS-1695

          Are you intersted in contributing this functionality?
          I'll gladly advice you.

          • 2. Re: WebServiceRef injection does not work

             


            To me it look like the wsrunclient simply provides a classpath for simple (i.e. Service.create) invocations


            I have problems with Service.create() too using JBoss 4.0.5GA, latest EJB3 and JBossWS packages.

            When I start my client I catch the following exception:
            javax.xml.ws.WebServiceException: java.lang.IllegalArgumentException: Cannot obt
            ain wsdl service: HelloService
             at javax.xml.ws.Service.create(Service.java:731)
             at com.imnet.oam.ws.HelloClient.<init>(HelloClient.java:13)
             at com.imnet.oam.ws.HelloClient.main(HelloClient.java:27)
            Caused by: java.lang.IllegalArgumentException: Cannot obtain wsdl service: Hello
            Service
             at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildM
            etaDataInternal(JAXWSClientMetaDataBuilder.java:131)
             at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildM
            etaData(JAXWSClientMetaDataBuilder.java:85)
             at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.<init>(ServiceDelegat
            eImpl.java:140)
             at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(Provid
            erImpl.java:61)
             at javax.xml.ws.Service.<init>(Service.java:83)
             at org.jboss.ws.core.jaxws.client.ServiceExt.<init>(ServiceExt.java:60)
             at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            
             at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
            orAccessorImpl.java:39)
             at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
            onstructorAccessorImpl.java:27)
             at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
             at javax.xml.ws.Service.create(Service.java:726)
             ... 2 more
            


            This is the WSLD generated while deploying the EJB3 web service:
            <definitions name='HelloService' targetNamespace='http://mypc:8080' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://mypc:8080' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
             <types>
             <xs:schema targetNamespace='http://mypc:8080' version='1.0' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
             <xs:element name='sayHello' nillable='true' type='xs:string'/>
             <xs:element name='sayHelloResponse' nillable='true' type='xs:string'/>
             </xs:schema>
             </types>
             <message name='Hello_sayHello'>
             <part element='tns:sayHello' name='sayHello'/>
             </message>
             <message name='Hello_sayHelloResponse'>
             <part element='tns:sayHelloResponse' name='sayHelloResponse'/>
             </message>
             <portType name='Hello'>
             <operation name='sayHello' parameterOrder='sayHello'>
             <input message='tns:Hello_sayHello'/>
             <output message='tns:Hello_sayHelloResponse'/>
             </operation>
             </portType>
             <binding name='HelloBinding' type='tns:Hello'>
             <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
             <operation name='sayHello'>
             <soap:operation soapAction=''/>
             <input>
             <soap:body use='literal'/>
             </input>
             <output>
             <soap:body use='literal'/>
             </output>
             </operation>
             </binding>
             <service name='HelloService'>
             <port binding='tns:HelloBinding' name='HelloPort'>
             <soap:address location='http://mypc:8080/HelloService/Hello'/>
             </port>
             </service>
            </definitions>
            


            The client code follows:
            package org.me.ws;
            
            import java.net.URL;
            import javax.xml.namespace.QName;
            import javax.xml.ws.Service;
            
            public class HelloClient {
             private static final String SERVICE_NAME = "HelloService";
             private static final String WSDL_LOCATION = "http://mypc:8080/HelloService/HelloService?wsdl";
             private Service service;
            
             public HelloClient() throws Exception {
             service = Service.create(new URL(WSDL_LOCATION), new QName(SERVICE_NAME));
             }
            
             public String getMessage() {
             Hello hello = null;
            
             hello = service.getPort(Hello.class);
             return hello.sayHello("Jim");
             }
            
             public static void main(String[] args) {
             HelloClient client = null;
            
             try {
             client = new HelloClient();
             System.out.println(client.getMessage());
             } catch (Throwable t) {
             t.printStackTrace();
             }
             }
            }
            


            and finally the service implementation class code follows:
            package com.imnet.oam.ws;
            
            import javax.jws.*;
            import javax.jws.soap.SOAPBinding;
            import javax.ejb.Stateless;
            
            @Stateless
            @WebService(name="Hello", targetNamespace="http://mypc:8080", serviceName="HelloService")
            @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
            public class Hello {
             private String message = new String("Hello, ");
            
             @WebMethod
             public String sayHello(String name) {
             return message + name + ".";
             }
            }
            


            The WSDL file is easily accessible using the internet browser or throught the http://localhost:8080/jbossws/services links. I tried to call my service in many different way, changing it's name or targetName but the results are similar. Any ideas?

            Thank you