3 Replies Latest reply on Apr 10, 2007 8:33 PM by d_pavel

    Problem using wstools

    d_pavel

      Hi 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.

        • 1. Re: Problem using wstools
          d_pavel

          Hello again,

          I should've mention that I replaced jbossws-1.0.4.GA (which was included in the distribution package for JBoss AS) and I installed correctly the jbossws-1.2.0.GA version (I was careful with the libraries and I can access "http://localhost:8080/jbossws/" which is fine).

          Now I read all "Tools Overview" paragraph from the "JAX-WS User Guide" because in the Jason Green's post ("JBossWS 1.2.0.GA Tools Overview (wstools, wsprovide, wsconsu") it is pointed that fact; now because I really want to develop JAX-RPC services I have to use the wstools!
          In the "JAX-RPC User Guide" there is no overview info for wstools, just the link for the "Documentation for jbossws-tool_1_0".
          Any help/suggestion with the wstoos ?

          Thanks, D

          • 2. Re: Problem using wstools
            d_pavel

            I think my post is related with this topic as well:
            http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4025390#4025390

            Need clarification about this please:
            1) the wstools.sh script which comes with the jbossws-1.2.0.GA points to both:
            WSTOOLS_CLASSPATH="$WSTOOLS_CLASSPATH:$JBOSS_HOME/client/jbossws14-client.jar"
            WSTOOLS_CLASSPATH="$WSTOOLS_CLASSPATH:$JBOSS_HOME/client/jbossws-client.jar"
            when esteblishing the wstools classpath.
            The jboss14 is really needed ? I was thinking that only the 'jbossws-client.jar' will be used in the new version.

            2) Do we still have to get an updated "jboss-xml-binding.jar" from the repository ? I want to mention that I used the new distribution for the jboassws-1.2.0.GA which uses the ant.

            3) Do we still have to keep the "jbossws14.sar/" in our jboss server/.../deploy ? I was thinking that with the new version we will use only the "jbossws.sar/" service archive.

            Thanks

            • 3. Re: Problem using wstools
              d_pavel

              I should have posted these answers sooner then one month but time flies so here you go (in case somebody will stumble upon same things):
              -I solved relatively fast the wstools problem which turned out to be the result of using the full path for the SEI class in the command which I described in point 4 in my first post (as was mentioned in the user guide...). So using a path just to WEB-INF/classes directory solved the problem and the related artifacts are generated correct.
              -jbossws14-client.jar is needed for J2EE 1.4, whereas jbossws-client.jar is needed for Java EE; if you keep both jar files order of loading is important depending what you need to use.
              -yes I had to get an updated "jboss-xml-binding.jar