web service in rad6

Upload: prashanth-kasulabadha

Post on 07-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Web Service in RAD6

    1/18

    Introduction

    This document gives the step by step process for developing, deploying and testing of a

    simple Webservice in RAD 6.0 IDE.

    We can create the webservice in two ways

    1) Bottom Up or Stub scenario : create a Web service from a Java bean or a EJB or aDADX.

    2) Top Down or Skeleton scenario : create a Web service from a Web ServiceDescription Language (WSDL) file

    Depending upon the server and the chosen run-time, the artifacts that the Web services

    wizard generates may vary. The end result is a deployed Web service on a server.

    If a vendor deploys a Web service and you would like to create a client to use it, the

    Web service client wizard does this by starting with the WSDL file.

    A Web service can be based on a number of different types including a Java bean,

    Enterprise Java Bean (EJB) component, DADX document, and so on..

    Creating WebService From JavaBean

    We can start at different points in the wizard and create a Web service using different file

    types. One start point is with a Java Bean. The Web services wizard would then generate

    the Requestor-side files including the proxy bean, the WSDL file, and Provider-side files.

    This is known as the Bottom Up scenario

    Bottom Up Web services scenario

  • 8/6/2019 Web Service in RAD6

    2/18

    Creating a Webservice From WSDL File

    We can also start with a WSDL file and generate the Requestor-side artifacts and the

    Provider artifacts including a skeleton bean with the WSDL operations. The

    implementation is left to you to fill in. This is known as the Skeleton or Top DownScenario.

    Top Down scenario

    Web Service Deployment

    When deploying a Web service, your choice of run-time and server affects both the

    chosen J2EE specification level, as well as the files generated. WebSphere Application

    Server V6.0 supports the J2EE 1.4 specification. The concept of Web projects being

    deployed to an EAR file exists for WebSphere Application Server. Web services

    information for J2EE is stored in a file called webservices.xml.

    Suppose if we create a webproject named MyWSProject then the corresponding EAR

    project is named MyWSProjectEAR.

    If we are creating a webservice in Bottom Up scenario,In this case several file types

    have been generated including deserializer, serializer, and helper files. These files

    are used to convert the incoming XML message to Java language and outgoing Java

    language to XML. There is also a SEI file which holds all the operations in the Web

    service. The client proxy is generated using this file. A WSDL file is generated into the

    Web Content directory. This contains information about the Web service that has just

    been deployed to the server. The WSDL Test Clients use the WSDL file to test theservice directly. Rational Application Developer provides the Web service Explorer which

    you can use to test the service.

  • 8/6/2019 Web Service in RAD6

    3/18

    Deploy the service to the EAR and deploy the EAR to the server

    Deploying the Web services using the Web services wizard. A number of files are

    generated to facilitate the serialization and deserialization of the messages to and from

    the service. Information is also added to the webservices.xml, web.xml, and

    x_mapping.xml. This information describes the deployment of the service. This follows

    the J2EE 1.4 standard. At this point all the information about the Web service has been

    deployed to the EAR. The EAR has then been added to WebSphere Application Server.

    Generating the Client

    To generate a client, select the checkbox next to the corresponding label that says

    generate proxy on the first page of the Web services wizard. Another way to generate a

    client is to start with a WSDL from the service. This is known as the Client scenario .In

    this case it is assumed the service has already been deployed. The Web services wizard

    creates a Web project called MyWSProjectClient and a new EAR file that contains this

    project. Again there are serializer, deserializer, and helper classes. The key file that the

    test facilities focus on is the proxy file.

  • 8/6/2019 Web Service in RAD6

    4/18

    Example of HelloWorld Web Service using Bottom-up approach

    To create a new Dynamic Web Project in RAD6.0

    Go to File->NewOther

  • 8/6/2019 Web Service in RAD6

    5/18

    Select Dynamic Web Project

    Click Next, then enter the name of the Dynamic Web Project

    Enter the project name as FirstWSproject

  • 8/6/2019 Web Service in RAD6

    6/18

    Click Next

    Click Next

  • 8/6/2019 Web Service in RAD6

    7/18

    Click Finish and click Yes to open in J2EE perspective otherwise select No to open in

    java perspective.

    Now we can see two folders created in Package Exoplorer view,namely

    FirstWSProject and FirstWSProjectEAR

  • 8/6/2019 Web Service in RAD6

    8/18

    To create a java class, go to FirstWSProjectjavaSourceNewClass

    Give the package name as com.wu.firstws and give the class name as HelloWorld and

    click Finish

  • 8/6/2019 Web Service in RAD6

    9/18

    Add a method sayHello() in the class HelloWorld.

    To create a Web Service right click on HelloWorld.java class goto New->Other

  • 8/6/2019 Web Service in RAD6

    10/18

    Select Web Service in New Window. click Next

    In the Web Services window check the check boxes as shown in below figure.

  • 8/6/2019 Web Service in RAD6

    11/18

    Click Next and browse HelloWorld.java file from that particular package structure

    Click Next

  • 8/6/2019 Web Service in RAD6

    12/18

    Click Next

    Click Next

  • 8/6/2019 Web Service in RAD6

    13/18

    Click Next

    Click Next

  • 8/6/2019 Web Service in RAD6

    14/18

    Click Next it will take some time to generate the Client

    Click Next

  • 8/6/2019 Web Service in RAD6

    15/18

    Click Finish and now WebServices Explorer window will be opened.

    Click on sayHello() in the left panel where we can see the endpoint and the user defined

    methods

  • 8/6/2019 Web Service in RAD6

    16/18

    Enter name in Inputs window against the name label in the text box.

    Click on Invoke button. The result will be displayed in Result window.

  • 8/6/2019 Web Service in RAD6

    17/18

    The folder structure looks like the below.

    A file HelloWorld_SEI.java is created in the same folder where HelloWorld.java resides.

    A HelloWorld.wsdl is created in WEB-INF->wsdl folder which gives the details of the

    webservice which is exposed like the name of the method, SEI, port etc.

  • 8/6/2019 Web Service in RAD6

    18/18

    Client folder structure looks like below.

    HelloWorld, HelloWorldProxy, HelloWorldService, HelloWorldServiceInformation,

    HelloWorldServiceLocator, HelloWorldSoapBindingStub are the files created in the client

    project.

    Some jsps are also created which can be used for testing the webservice.