views:

1191

answers:

0

I have a simple hello-world EJB3 successfully deployed as web service. I can check it with url: http://localhost:8080/jbossws/services

Following is the client which works for Glassfish but doesn't work for JBOSS

package com.hardik.mejb;

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;

public class JAXWSClient {

    private static String host = "localhost";
    private static String portType = "HelloBean";
    private static String serviceName = "Greeter";
    private static String serviceName_jboss = "hello-ws-hello-ws";

    // works for glassfish
    // private static String serviceEndpointAddress = "http://"+ host+ ":8080/" + serviceName;

    // should work for jboss
    private static String serviceEndpointAddress = "http://"+ host+ ":8080/" + serviceName_jboss;

    private static String namespace = "http://mejb.hardik.com/";

    public static void main(String[] args) {

     URL wsdlLocation = null;
     try {
      String urlstr = serviceEndpointAddress + "/" + portType + "?WSDL";
      System.out.println(urlstr);
      wsdlLocation = new URL(urlstr);
     } catch (MalformedURLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }

     QName serviceNameQ = new QName(namespace,serviceName);  
     // dynamic service usage
     Service service = Service.create(wsdlLocation, serviceNameQ);
     Hello firstGreeterPort =  service.getPort(Hello.class);

     // Object beans[] = service.getPorts();
     System.out.println("1: "+ firstGreeterPort.hello());  
    }
}

Here is how I execute the client and the error I get:

wsrunclient.sh  -cp "lib/*:dist/hello-client.jar:jboss-generated/*"  com.hardik.mejb.JAXWSClient
http://localhost:8080/hello-ws-hello-ws/HelloBean?WSDL
Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class com.hardik.mejb.jaxws.Hello is not found. Have you run APT to generate them?
        at com.sun.xml.internal.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:256)
        at com.sun.xml.internal.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:567)
        at com.sun.xml.internal.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:514)
        at com.sun.xml.internal.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:341)
        at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:227)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:588)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:291)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:274)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:302)
        at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:306)
        at javax.xml.ws.Service.getPort(Service.java:161)
        at com.hardik.mejb.JAXWSClient.main(Unknown Source)

Do I need to generate something ? Am I missing some jar file(s) ?