Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Web Service AXIS

Options
  • 13-11-2008 5:09pm
    #1
    Registered Users Posts: 269 ✭✭


    I want to use Java with AXIS to create a web service that will generate a WSDL File however how much of the exsisting java that i know can i use with AXIS to create a web service. I know Java SE eg the likes of Swing etc and i am currently doing JSP and Servlets. What kinds of things will i need to focus on with regards to java when trying to create web service


Comments

  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    I recommend you read the documentation on Axis as it explains how the whole thing works.

    Basically you create your javabean with the methods to call. Then generate your WSDL file from that. Server handles the SOAP request/responses for you.

    I recommend using SOAPUI for testing the web services.

    based on what you list as your knowledge it should be pretty easy to pick up.


  • Registered Users Posts: 269 ✭✭cyberwit


    Is their certin API 's i should be looking at. Do you know any IDE for creating web Services from AXIS. I have tried Netbeans doe not work an a pulgin for eclipse is giving be bother


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    You can use any java based IDE. Writing a web service is painfully simple starting off.

    You just create a javabean and name the text file .JWS and put it onto your AXIS server. The server handles the rest.

    Seriously, have a read through the documentation for Axis. They have a starter tutorial. Just remember a web service is not a UI based system. So if you need a UI you have to write it and call the web service.

    Again Axis will write all the code for you from the generated WSDL file from the JWS file.


  • Registered Users Posts: 269 ✭✭cyberwit


    Seriously your advice is greatly appriciated


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    cyberwit wrote: »
    Do you know any IDE for creating web Services from AXIS.

    Axis has a command line option that will read the WSDL file and create the java classes for you. After that you would just create the class it made and then call the method.

    The AXIS generated class handles the connection to the web service and returns an object you can read like normal java.

    WSDL files can be processed by anything that supports web services. For example Notes (as of version 7/8) can read a WSDL file and generate lotuscript or java libraries to access the webservice the WSDL file relates to.

    So for example I create a java webservice in notes like so...
      class SampleWebService {
         public int sampleMethod(int x) {
            return x + x;
         }
       }
    

    and that generates this.
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions targetNamespace="urn:DefaultNamespace" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:DefaultNamespace" xmlns:intf="urn:DefaultNamespace" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <wsdl:types>
      <schema targetNamespace="urn:DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
       <element name="x" type="xsd:int"/>
       <element name="sampleMethodReturn" type="xsd:int"/>
      </schema>
     </wsdl:types>
     <message name="sampleMethodRequest">
      <part element="impl:x" name="x"/>
     </message>
     <message name="sampleMethodResponse">
      <part element="impl:sampleMethodReturn" name="sampleMethodReturn"/>
     </message>
     <portType name="SampleWebService">
      <operation name="sampleMethod">
       <input message="impl:sampleMethodRequest" name="sampleMethodRequest"/>
       <output message="impl:sampleMethodResponse" name="sampleMethodResponse"/>
      </operation>
     </portType>
     <binding name="DominoSoapBinding" type="impl:SampleWebService">
      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="sampleMethod">
       <wsdlsoap:operation soapAction="sampleMethod"/>
       <input name="sampleMethodRequest">
        <wsdlsoap:body use="literal"/>
       </input>
       <output name="sampleMethodResponse">
        <wsdlsoap:body use="literal"/>
       </output>
      </operation>
     </binding>
     <service name="SampleWebServiceService">
      <port binding="impl:DominoSoapBinding" name="Domino">
       <wsdlsoap:address location="http://localhost"/>
      </port>
     </service>
    </definitions>
    

    that WSDL then can be used to generate the library to talk to the web service, or create a new bean to work on a different platform.


  • Advertisement
  • Registered Users Posts: 269 ✭✭cyberwit


    Basically i write java then put on AXIS which compiles it to SOAP and WSDL i can use WSDL if i want to allow others use that webservice.

    Do i need to know theses API or will i have to use them.
    The Java API for XML Processing (JAXP)
    • The Java API for XML-based RPC (JAX-RPC)
    • SOAP with Attachments API for Java (SAAJ)
    • The Java API for XML Registries (JAXR)

    Can i use JDBC in allow a user connect to a database from the webservice


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    cyberwit wrote: »
    Basically i write java then put on AXIS which compiles it to SOAP and WSDL

    WSDL describes the service and SOAP is the method of communication between the consumer and the web service.
    i can use WSDL if i want to allow others use that webservice.

    Yep. But can also use it to create the library to interact with your webservice automatically.
    Do i need to know theses API or will i have to use them.
    The Java API for XML Processing (JAXP)
    • The Java API for XML-based RPC (JAX-RPC)
    • SOAP with Attachments API for Java (SAAJ)
    • The Java API for XML Registries (JAXR)

    It is good to have an understanding of them if your debugging. But for the most part no. Your interaction of your consumer to the webservice should be transparent to you.

    For debugging I recommend SoapUI (mentioned earlier). It will show you the raw soap request/responses from the web service if something is misbehaving.
    Can i use JDBC in allow a user connect to a database from the webservice

    Yep. Your webservice can make the connection and the client calls the webservice to request the data. Again this should be pretty much transparent from a code point of view.


  • Registered Users Posts: 269 ✭✭cyberwit


    When you say library do you mean the WSDD. The library is where you describe all the java libraries or api i use. Also do you know any good website where i can access exsisting web services maybe from companies i have looked at paypals


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    When I mean library your program needs to access a class that will connect to the webservice and expose the methods the web service has.

    Axis will take a WSDL file and automatically create this for you.

    Probably being pendatic at this point but if you follow the Axis tutorial in the product it all becomes very clear.


  • Registered Users Posts: 269 ✭✭cyberwit


    I am having trouble setting up classpath.
    I do the following right click my computer, properties,
    the click Advanced, environment variables see attachment

    I tyep the following
    In Variable Name: AXISCLASSPATH
    In Variable Value:
    set AXIS_HOME=C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis
    set AXIS_LIB=%AXIS_HOME%\lib
    set AXISCLASSPATH=%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery.jar;
      %AXIS_LIB%\commons-logging.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;
      %AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar
    

    set AXIS_HOME is where my AXIS directory is on my apache tomcat server

    When i try use the AXIS client code in the command prompt i get the following


  • Advertisement
  • Registered Users Posts: 269 ✭✭cyberwit


    Have also tried this
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis;C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\lib;C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\lib\axis.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\lib\commons-discovery.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\lib\commons-logging.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\lib\jaxrpc.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\lib\saaj.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\lib\log4j-1.2.8.jarC:\Program Files\Apache Software Foundation\Tomcat6.0\webapps\axis\lib\xml-apis.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\lib\xercesImpl.jar 
    
    


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    Those are command line commands. So to put it into your environment you would remove the "set" and only have after the equals.

    AXIS_HOME
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis

    AXIS_LIB
    %AXIS_HOME%\lib

    AXISCLASSPATH
    %AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery.jar;%AXIS_LIB%\commons-logging.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar; %AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar


  • Registered Users Posts: 269 ✭✭cyberwit


    
    Sorry, something seems to have gone wrong... here are the details:
    Fault - ; nested exception is: 
    	java.lang.RuntimeException: No compiler found in your classpath!  (you may need to add 'tools.jar')
    
    AxisFault
     faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
     faultSubcode: 
     faultString: java.lang.RuntimeException: No compiler found in your classpath!  (you may need to add 'tools.jar')
     faultActor: 
     faultNode: 
     faultDetail: 
    	{http://xml.apache.org/axis/}hostname:john-12f439374d
    
    

    I have added the claspath as shown above in attachment still not working

    I am getting a CLASSNOTFOUNDEXCEPTION


  • Registered Users Posts: 269 ✭✭cyberwit


    I reinstalled my server and AXIS i pu the following webservice on the server
    
    public class HelloWorldService
    {
    	public String HelloWorld(String data)
    	{
    		return "Hello World! You sent the string '" + data + "'.";
    	}
    }
    
    
    

    I created a test program in eclipse to run web service
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.rmi.RemoteException;
    
    import javax.xml.namespace.QName;
    import javax.xml.rpc.ServiceException;
    
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    
    public class HelloWorldClient
    {
    	public static void main(String[] args) throws ServiceException, MalformedURLException, RemoteException
    	{
    
    		Service service = new Service();
    
    		Call call = (Call)service.createCall();
    		call.setTargetEndpointAddress(new URL("http://localhost:8080/axis/HelloWorldService.jws"));
    		call.setOperationName(new QName("http://soapinterop.org/", "HelloWorld"));
    
    		String returnValue = (String)call.invoke(new Object[]{"My name is Rob."});
    
    		System.out.println(returnValue);
    	}
    }
    
    
    

    I got the following result Hello World! You sent the string 'My name is Rob.'. whih what i am supposed to get the attachment show what i got in the browser i think that writye so why when i try to do the following from the installation notes in the commandline
    
    java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd
    
    
    

    I get the ClassNotFoundException i have the classpath setup properly (i believe) as shown in attachment.

    I know i am being a pain asking for all this help but i am very greatful for all your help


Advertisement