2 Replies Latest reply on Dec 20, 2004 5:44 AM by Thomas Diesler

    Paths and Getting Started Guide

    Jerry Payne Newbie

      I am using the Getting Started guide to develop my own web service. One of the questions I came up with that I do not see discussed in the guide is the classpath of the Axis files. I created a sub-directory on my server that I copy the Axis JAR files in to, but I have to believe this is not the best solution.

      Are the JAR files on the server somewhere that I can add to my classpath? I am doing all of this in an Ant script and it works, but I don't feel like I should have to copy the Axis files to the server.

      I have the service deployed and I can access it via the URL, but I am getting the following exception when I try to run my client.

       [java] java.lang.IllegalAccessError: tried to access field org.apache.axis.
      client.Service.engine from class org.jboss.webservice.client.ServiceImpl
       [java] at org.jboss.webservice.client.ServiceImpl.getAxisClient(Service
      Impl.java:255)
       [java] at org.apache.axis.client.Service.<init>(Service.java:185)
       [java] at org.jboss.webservice.client.ServiceImpl.<init>(ServiceImpl.ja
      va:99)
       [java] at org.jboss.webservice.client.ServiceFactoryImpl.createService(
      ServiceFactoryImpl.java:112)
       [java] at com.hott.client.WSClient.main(Unknown Source)
       [java] Exception in thread "main"
      


      I am using the exact code that comes from the Getting started guides files.

      Here is my client code:
      package com.hott.client;
      
      import javax.xml.rpc.Call;
      import javax.xml.rpc.Service;
      import javax.xml.rpc.JAXRPCException;
      import javax.xml.rpc.ServiceFactory;
      import javax.xml.rpc.ParameterMode;
      
      import javax.xml.namespace.QName;
      import java.net.URL;
      
      import com.hott.service.BookSessionEndpoint;
      /**
       *
       * @author HOTT Instructor
       */
      public class WSClient {
      
       /**
       * @param args the command line arguments
       */
       public static void main(String[] args) throws Exception{
       URL url = new URL("http://localhost:8080/ws4ee/services/BookSessionService?wsdl");
      
       QName qname = new QName("http://service.hott.com",
       "BookSessionService");
      
       ServiceFactory factory = ServiceFactory.newInstance();
       Service service = factory.createService(url,qname);
      
       BookSessionEndpoint endpoint = (BookSessionEndpoint)
       service.getPort(BookSessionEndpoint.class);
      
       String byISBN = endpoint.findByISBN(99415);
       String byTitle = endpoint.findByTitle("Little Women");
       String byPrice = endpoint.findByPriceRange(0,100);
      
       System.out.println("By ISBN:" + byISBN);
       System.out.println("By Title:" + byTitle);
       System.out.println("By Price:" + byPrice);
       }
      
      }
      
      


      Thanks

        • 1. Re: Paths and Getting Started Guide
          Jerry Payne Newbie

          I wanted to add another question to this message.

          I have gotten the service deployed and I am trying to access the service from a servlet. Here is the code in the doGet method of my servlet:

           try{
           URL url = new URL("http://localhost:8080/ws4ee/services/BookSessionService?wsdl");
           QName qname = new QName("http://service.hott.com","BookSessionService");
           ServiceFactory factory = ServiceFactory.newInstance();
           Service service = factory.createService(url,qname);
          
           BookSessionEndpoint endpoint = (BookSessionEndpoint)
           service.getPort(BookSessionEndpoint.class);
           System.out.println("It works to here");
           String byISBN = endpoint.findByISBN(99415);
           out.println("By ISBN:" + byISBN);
           System.out.println("Here I am 5");
           String byTitle = endpoint.findByTitle("Little Women");
           out.println("By Title:" + byTitle);
           System.out.println("Here I am 6");
           String byPrice = endpoint.findByPriceRange(0,100);
           out.println("By Price:" + byPrice);
           System.out.println("Here I am 7");
          


          The code works up to the System.out.println("It works to here"). When the code encounters the call to findByISBN(99415) it returns a SOAP fault. Reading the SOAP fault it is telling me that the "Service is unavailable" and I get back a 404 from the server.

          I can access the WSDL file using the URL. Can anyone give me some thoughts on what's going on? If there are any other deployment descriptors you would like to see please let me know.

          Thanks again.

          • 2. Re: Paths and Getting Started Guide
            Thomas Diesler Master

            These are two unrelated issues.

            1) That JBossWS uses Apache Axis internally is an implementation detail which will be removed. You should not need to access axis jars from your implemenation. Neither should you use axis generated client stubs. JBossWS is about portable J2EE compliant Web Services, which should not by definition use any propriatory client stubs. See the wiki for a detailed discussion on how to use WS4EE http://www.jboss.org/wiki/Wiki.jsp?page=JBossWS

            2) The URL of style

            http://[host]:[port]/ws4ee/services/[service name]
            


            is deprecated. Every service endpoint is accessible at its deployment specific context root. Otherwise all WS would vave to share the same security configuration.

            Can you see the WSDL at that URL in you browser? Check the JBoss console for the proper endpoint URL.

            Also beware, that the sandard JAXRPC ServiceFactory is not aware of the WS4EE specific jaxrpc-mapping.xml. JBossWS provides an extension to the createService method that can use.

            Use the WS4EE client programming model, with JNDI lookup of the preconfigured JAXRPC Service instead of creating the Service form the ServiceFactory.