Problem using wstools
d_pavel Mar 8, 2007 6:59 PMHi All,
I want to implement web services in my project which is a j2ee web application based on JBoss AS 4.0.5.GA and jbossws-1.2.0.GA.
I installed JBoss AS using "jems-installer-1.2.0.GA.jar" on RedHat Linux RHEL4 (using "all" as a profile for the AS). I bought the "JBoss at Work" book but it's using the sun's jwsdp tool. Since I'm using JBoss I want to leverage the wstools which comes with jbossws-1.2.0.GA.
I am trying to implement first the JSR-109 JAX-RPC Service Endpoints:
1) Here is my SEI:
package generic.hello; import java.rmi.Remote; import java.rmi.RemoteException; public interface Service_SEI_Interface extends Remote { public String hello(String name) throws RemoteException; public String purchase (String person, String product) throws RemoteException; }
2)Here is my JSE:
package generic.hello; /** * * @author dragos * * This class represents the Endpoint Implementation Bean (=our web service implementation). * JAX-RPC service endpoints (JSEs) provide web services from the web tier. They take the form of a simple * Java objects that masquerade as servlets. This case is implemented in this generic package. * In other specs this is reffer to as "Java Service Skeleton". */ public class POJO_EndpointJSE { //ddd - insert all business methods that we provide and expose as web services public String hello(String name) { System.out.println("Hello There : " + name + "!"); return "Hello There : " + name + "!"; } public String purchase (String person, String product) { System.out.println("DDD_EndpointJSE purchase: " + person + "," + product); return "ok" + person + product; } }
3) the input configuration file (wstools-config.xml) for the wstools:
<?xml version="1.0" encoding="UTF-8"?> <!-- using this config file, wstools can generate the JSR-109 required number of deployment artifacts, which are: ? webservices.xml, the deployment descriptor that identifies a deployment of a web service endpoint ? wsdl, the abstract webservice contract ? jaxrpc-mapping.xml, the mapping desriptor that bridges WSDL to java --> <!-- RPC Style Endpoint --> <configuration xmlns="http://www.jboss.org/jbossws-tools"> <java-wsdl> <!-- ddd The service element defines the interface our web service provides --> <service name="SampleService" style="rpc" endpoint="generic.hello.Service_SEI_Interface"/> <namespaces target-namespace="http://hello.generic/" type-namespace="http://hello.generic/types"/> <mapping file="jaxrpc-mapping.xml"/> <webservices servlet-link="HelloWorldWS"/> </java-wsdl> </configuration>
4)I am running WSTools from the command line like this:
/usr/local/jboss-4.0.5.GA/bin/wstools.sh -cp /home/dragos/SW/myeclipsews/testbenchWS/WebRoot/WEB-INF/classes/generic/hello/Service_SEI_Interface -config ./wstools-config.xml
5)Here is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <!-- ddd declare a pseudo-servlet --> <servlet> <servlet-name>HelloWorldWS</servlet-name> <servlet-class>generic.hello.POJO_EndpointJSE</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <!-- ddd : | 1) We declare our web service implementation class as a servlet and provide a servlet mapping | that will respond to the web service invocations | 2) The URL pattern in the servlet mapping is the only externally visible configuration element | = URL the web service lives at = will be primarily noticed as the location of the WSDL file for this service --> <servlet-mapping> <servlet-name>HelloWorldWS</servlet-name> <!-- url-pattern>/Service_SEI_Interface</url-pattern --> <url-pattern>/services/*</url-pattern> </servlet-mapping> </web-app>
6) Here is the output from the command line wstools:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <!-- ddd declare a pseudo-servlet --> <servlet> <servlet-name>HelloWorldWS</servlet-name> <servlet-class>generic.hello.POJO_EndpointJSE</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <!-- ddd : | 1) We declare our web service implementation class as a servlet and provide a servlet mapping | that will respond to the web service invocations | 2) The URL pattern in the servlet mapping is the only externally visible configuration element | = URL the web service lives at = will be primarily noticed as the location of the WSDL file for this service --> <servlet-mapping> <servlet-name>HelloWorldWS</servlet-name> <!-- url-pattern>/Service_SEI_Interface</url-pattern --> <url-pattern>/services/*</url-pattern> </servlet-mapping> </web-app>
7)To me it looks like the parameters passed to
handleJavaToWSDLGeneration(Configuration config, String outDir)are not instantiated properly cause I not see otherways why later I can't load the end point class. Here is the pertinent code from the ToolsHelper class:
public void handleJavaToWSDLGeneration(Configuration config, String outDir) throws IOException jason.greene@jboss.com 97 89 { 90 JavaToWSDLConfig j2wc = config.getJavaToWSDLConfig(false); 91 JavaToWSDL jwsdl = new JavaToWSDL(Constants.NS_WSDL11); 92 jwsdl.setServiceName(j2wc.serviceName); 93 jwsdl.setTargetNamespace(j2wc.targetNamespace); 94 jwsdl.setTypeNamespace(j2wc.typeNamespace); 95 jwsdl.setOperationMap(j2wc.operations); 96 97 if ("document".equals(j2wc.wsdlStyle)) 98 jwsdl.setStyle(Style.DOCUMENT); 99 else if ("rpc".equals(j2wc.wsdlStyle)) 100 jwsdl.setStyle(Style.RPC); thomas.diesler@jboss.com 221 101 else throw new WSException("Unrecognized Style:" + j2wc.wsdlStyle); jason.greene@jboss.com 97 102 103 if ("wrapped".equals(j2wc.parameterStyle)) 104 jwsdl.setParameterStyle(ParameterStyle.WRAPPED); 105 else if ("bare".equals(j2wc.parameterStyle)) 106 jwsdl.setParameterStyle(ParameterStyle.BARE); thomas.diesler@jboss.com 221 107 else throw new WSException("Unrecognized Parameter Style:" + j2wc.parameterStyle); jason.greene@jboss.com 97 108 109 Class endpointClass = loadClass(j2wc.endpointName); 110 thomas.diesler@jboss.com 221 111 if (endpointClass == null) 112 throw new WSException("Endpoint " + j2wc.endpointName + " cannot be loaded"); ............
8) Any ideas about the endpoint class loading issue?
Thanks in advance.