d22 web services

Upload: uday-kumar

Post on 30-May-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 D22 Web Services

    1/109

    2006 IBM Corporation

    Made available under the EPL v1.0

    2006 WebSphere Services Technical Conferenceworld class skill building and technical enablement

    May 1-5, 2006 Las Vegas, NV

    SucceedCollaborate

    Learn

    Network

    SucceedCollaborate

    Learn

    Network

    Developing Web ServicesDeveloping Web Serviceswith Eclipse Web Toolswith Eclipse Web Tools

    Session Number: D22Session Number: D22

    Arthur Ryman, [email protected] Ryman, [email protected]

  • 8/14/2019 D22 Web Services

    2/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation2

    ObjectivesObjectives

    You will learn how to use Eclipse WTP to develop Webservices

    You will learn about top-down and bottom-up service creation,

    client access, interoperability testing, discovery, and

    publication

    After this tutorial you should be able to develop Web services

    using WTP and products such as AST and RAD that are

    based on it

    Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United

    States, other countries, or both.

    Other company, product, or service names may be trademarks or service marks of others.

  • 8/14/2019 D22 Web Services

    3/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation3

    About this tutorialAbout this tutorial

    You will use WTP to develop Web services in a sequence of

    iterations The example used is League Planet, a fictitious Web site for

    amateur sports leagues

    For more information, see Chapter 10 of the forthcoming book,Java Web Application Development Using Eclipse

    For the most benefit, you should follow along You are expected to be comfortable using Eclipse and

    programming in Java

    Some prior knowledge of Web services would be useful

  • 8/14/2019 D22 Web Services

    4/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation4

    Code ExamplesCode Examples

    This tutorial is based on a complete working Web application

    called League Planet All source code is provided in the examples directory The directory structure is: //

    e.g. webservices/iteration1/IceHockeyService/schedule.xml To make the application work, you must create some projects

    and generate some code

    http://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/schedule.xmlhttp://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/schedule.xml
  • 8/14/2019 D22 Web Services

    5/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation5

    IntroductionIntroduction

    Web services have emerged as the standard technology for integrating

    heterogeneous systems across the Internet and intranet

    e.g. services implemented on J2EETM application servers and clients

    implemented on .NET desktops or PHP Web servers

    The key technologies are: Extensible Markup Language: XML for messages

    XML Schema Description: XSD for message description

    Web Service Description Language: WSDL for service description

    Universal Description, Discovery, and Integration: UDDI for service

    registries

    Web Service Interoperability: WS-I for interoperability

  • 8/14/2019 D22 Web Services

    6/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation6

    Overview of IterationsOverview of Iterations

    1. Developing Web Services Top-Down

    2. Developing Web Services Bottom-Up

    3. Generating Web Service Client Proxies

    4. Testing Web Services for Interoperability

    5. Using Web Services in Web Applications6. Discovering and Publishing Web Services

  • 8/14/2019 D22 Web Services

    7/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation7

    Iteration 1 Iteration 1

    Developing WebDeveloping WebServices Top-DownServices Top-Down

  • 8/14/2019 D22 Web Services

    8/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation8

    Iteration 1 - Developing Web ServicesIteration 1 - Developing Web ServicesTop-DownTop-Down

    Top-Down development means designing the Web service

    interface first and then developing the implementation code This approach yields the best interoperability because the

    underlying implementation details do not bleed through into the

    interface This approach is required if the messages use existing industry

    or corporate XML document formats You need to learn XSD and WSDL design skills Luckily, WTP has two great editors that make this task easier

  • 8/14/2019 D22 Web Services

    9/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation9

    Iteration 1 OverviewIteration 1 Overview

    1. Use the XSD editor to describe the League Planet schedule

    format

    2. Use the WSDL editor to describe a Web service for querying

    schedules

    3. Use the Web service wizard to generate a Java skeleton for theservice and deploy it to the Axis SOAP engine running on

    Tomcat

    4. Fill in the implementation of the skeleton by accessing the

    League Planet business tier

    5. Use the Web service explorer to test the Web service

  • 8/14/2019 D22 Web Services

    10/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation10

    Create a new Dynamic Web Project namedCreate a new Dynamic Web Project namedIceHockeyService to contain the Web service.IceHockeyService to contain the Web service.

  • 8/14/2019 D22 Web Services

    11/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation11

    Describing schedule.xmlDescribing schedule.xml

    League Planet has an XML format for schedules Import IceHockeyService/schedule.xml for an example instance

    document Your goal is to describe this format using XSD

    http://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/schedule.xmlhttp://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/schedule.xml
  • 8/14/2019 D22 Web Services

    12/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation12

    Create a new XML Schema file namedCreate a new XML Schema file namedschedule.xsd in IceHockeyService.schedule.xsd in IceHockeyService.

  • 8/14/2019 D22 Web Services

    13/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation13

    schedule.xsdschedule.xsd

    In general, there are many equivalent ways to describe a given

    format using XSD For Web services, its a good practice to describe formats in a

    way that works well with XML data binding toolkits such as JAX-

    RPC Define complexTypes for the content model of each element The XSD editor lets you edit in the source tab, the graphical tab,

    the outline view, and the property view Try creating schedule.xsd

    Import IceHockeyService/schedule.xsd before proceeding

    http://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/schedule.xsdhttp://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/schedule.xsd
  • 8/14/2019 D22 Web Services

    14/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation14

    View schedule.xsd in the Graph tab of theView schedule.xsd in the Graph tab of theXSD editor.XSD editor.

  • 8/14/2019 D22 Web Services

    15/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation15

    View ScheduleContent of schedule.xsd in theView ScheduleContent of schedule.xsd in theGraph tab of the XSD editor.Graph tab of the XSD editor.

  • 8/14/2019 D22 Web Services

    16/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation16

    View schedule.xsd in the Outline view of XSDView schedule.xsd in the Outline view of XSDeditor.editor.

  • 8/14/2019 D22 Web Services

    17/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation17

    query.wsdlquery.wsdl

    Now that youve described the message format using XSD, you

    next goal is to describe a Web service for retrieving it For simplicity, the Web service will have a single operation

    named getSchedule

    The operation will take as input, the schedule id, and return asoutput the corresponding schedule document

  • 8/14/2019 D22 Web Services

    18/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation18

    Create a new WSDL file named query.wsdl inCreate a new WSDL file named query.wsdl inIceHockeyService.IceHockeyService.

  • 8/14/2019 D22 Web Services

    19/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation19

    Enter the namespace for the WSDL and have the wizardEnter the namespace for the WSDL and have the wizardgenerate a skeleton document for you using the SOAP bindinggenerate a skeleton document for you using the SOAP bindingand document/literal style.and document/literal style.

  • 8/14/2019 D22 Web Services

    20/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation20

    WSDL editorWSDL editor

    You can edit the document in the graph tab, the source tab, the

    outline view, and the property view. WSDL describes Web service using a hierachy of constructs:

    message, portType, binding, and service

    The editor has a wizard that generates binding content for you Try creating query.wsdl Import IceHockeyService/query.wsdl before proceeding

    http://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/query.wsdlhttp://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/query.wsdl
  • 8/14/2019 D22 Web Services

    21/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation21

    View query.wsdl in the Graph tab of the WSDLView query.wsdl in the Graph tab of the WSDLeditor.editor.

  • 8/14/2019 D22 Web Services

    22/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation22

    View query.wsdl in the Outline view of theView query.wsdl in the Outline view of theWSDL editor.WSDL editor.

  • 8/14/2019 D22 Web Services

    23/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation23

    Deploying query.wsdlDeploying query.wsdl

    You have now described the Web service Your next goal is to deploy it This step assumes you have previously installed Tomcat and

    added it to WTP

    Select query.wsdl and execute the command Web Services >Generate Java bean skeleton

    This command launches the Web service wizard

  • 8/14/2019 D22 Web Services

    24/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation24

    Check the boxes to Install and Start the WebCheck the boxes to Install and Start the Webservice and clickservice and clickNextNext..

  • 8/14/2019 D22 Web Services

    25/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation25

    The wizard validates your WSDL. ClickThe wizard validates your WSDL. ClickNextNext..

  • 8/14/2019 D22 Web Services

    26/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation26

    The wizard selects Axis and Tomcat.The wizard selects Axis and Tomcat.ClickClickNextNext..

  • 8/14/2019 D22 Web Services

    27/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation27

    The wizard lets you select a source folder and change theThe wizard lets you select a source folder and change thepackage name for the generated skeleton. Accept the defaultspackage name for the generated skeleton. Accept the defaultsand clickand clickNextNext..

  • 8/14/2019 D22 Web Services

    28/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation28

    ClickClickStart server,Start server, wait, then clickwait, then clickNextNext..

  • 8/14/2019 D22 Web Services

    29/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation29

    The wizard lets you publish the WSDL toThe wizard lets you publish the WSDL toUDDI. Just clickUDDI. Just clickFinishFinish..

  • 8/14/2019 D22 Web Services

    30/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation30

    What the wizard did.What the wizard did.

    Installed the Axis SOAP engine in your project Generated the Java bean skeleton for you service and lots of

    Java XML data binding classes in the src folder Copied query.wsdl to WebContent/wsdl/querySOAP.wsdl and set

    its endpoint to your Web application (also copied schedule.xsd) Created the Axis deployment descriptor WebContent/WEB-

    INF/server-config.wsdd Created a couple of handy Axis files to deploy and undeploy your

    Web service in a subfolder of WebContent/WEB-INF

    Started Tomcat to make your Web service available

    Th I H k S i j f h i d l d

  • 8/14/2019 D22 Web Services

    31/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation31

    The IceHockeyService project after the wizard completed.The IceHockeyService project after the wizard completed.Select AxisServlet and execute the commandSelect AxisServlet and execute the commandRun As > Run onRun As > Run onServerServer..

  • 8/14/2019 D22 Web Services

    32/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation32

    View the list of deployed Web services.View the list of deployed Web services.

  • 8/14/2019 D22 Web Services

    33/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation33

    LeaguePlanetModel Business TierLeaguePlanetModel Business Tier

    The Web service is running but it just returns null at this point You next need to fill in the implementation of the Java bean

    skeleton The Web service needs to access the League Planet business

    tier If you have not previously done so, create a new J2EE Utility

    Project named LeaguePlanetModel and import the source code

    from LeaguePlanentModel/src into it

    S l t I H k S i d it P ti di l AddS l t I H k S i d it P ti di l Add

    http://../Temp/notesEA312D/examples/webservices/iteration1/LeaguePlanetModel/srchttp://../Temp/notesEA312D/examples/webservices/iteration1/LeaguePlanetModel/src
  • 8/14/2019 D22 Web Services

    34/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation34

    Select IceHockeyService and open its Properties dialog. AddSelect IceHockeyService and open its Properties dialog. AddLeaguePlanetModel as a J2EE Module Dependency.LeaguePlanetModel as a J2EE Module Dependency.

    Vi h d l f h i hVi th d l t t f th i th

  • 8/14/2019 D22 Web Services

    35/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation35

    View the module structure of the server in theView the module structure of the server in theServers view.Servers view.

    Filli i h J b k lFilli i th J b k l t

  • 8/14/2019 D22 Web Services

    36/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation36

    Filling in the Java bean skeletonFilling in the Java bean skeleton

    You now have a Web service skeleton and access to the League Planet

    business tier. Your next goal is to implement the Web service. The generated skeleton class is

    com.leagueplanet.ws.query.QuerySOAPImpl Import

    IceHockeyService/src/com/leagueplanet/ws/query/QuerySOAPImpl.java

    now This modified skeleton simply delegates to a new class

    com.leagueplanet.Query to avoid confusion with the generated code Create this new class now and try to implement it Import IceHockeyService/src/com/leagueplanet/Query.java before

    proceeding

    T ti th W b iT ti th W b i

    http://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/src/com/leagueplanet/ws/query/QuerySOAPImpl.javahttp://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/src/com/leagueplanet/Query.javahttp://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/src/com/leagueplanet/Query.javahttp://../Temp/notesEA312D/examples/webservices/iteration1/IceHockeyService/src/com/leagueplanet/ws/query/QuerySOAPImpl.java
  • 8/14/2019 D22 Web Services

    37/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation37

    Testing the Web serviceTesting the Web service

    At this point the Web service is ready to test You will test it using the Web Service Explorer Select IceHockeyService/WebContent/wsdl/querySOAP.wsdl and

    execute the command Web Services > Test with Web Service

    Explorer The Web Service Explorer will start and open a new Web

    browser in the editor area

    Vi SOAP dl i th W b S iVi SOAP dl i th W b S i

  • 8/14/2019 D22 Web Services

    38/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation38

    View querySOAP.wsdl in the Web ServiceView querySOAP.wsdl in the Web ServiceExplorer. Click the getSchedule link.Explorer. Click the getSchedule link.

    View the getSchedule operation Enter 1 in the scheduleId fieldView the getSchedule operation Enter 1 in the scheduleId field

  • 8/14/2019 D22 Web Services

    39/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation39

    View the getSchedule operation. Enter 1 in the scheduleId fieldView the getSchedule operation. Enter 1 in the scheduleId fieldand clickand clickGoGo. The schedule is returned in the Status pane.. The schedule is returned in the Status pane.

    D bl li k th St t t i i it Cli k thDouble click the Status pane to maximize it Click the

  • 8/14/2019 D22 Web Services

    40/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    40

    Double-click the Status pane to maximize it. Click theDouble-click the Status pane to maximize it. Click theSourceSource link to view the SOAP message.link to view the SOAP message.

    Vi th SOAP Cli k thVie the SOAP message so rce Click the

  • 8/14/2019 D22 Web Services

    41/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    41

    View the SOAP message source. Click theView the SOAP message source. Click theFormForm link to return to the Form display.link to return to the Form display.

  • 8/14/2019 D22 Web Services

    42/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    42

    Iteration 2 Iteration 2

    Developing WebDeveloping WebServices Bottom-UpServices Bottom-Up

    It ti 2 D l i W b S iIteration 2 De eloping Web Ser ices

  • 8/14/2019 D22 Web Services

    43/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    43

    Iteration 2 Developing Web ServicesIteration 2 Developing Web ServicesBottom-UpBottom-Up

    Bottom-Up development starts with a Java service class and

    generates the WSDL from it This approach is more productive for Java developers since XSD

    and WSDL design skills are not required

    It is suitable when the Java class uses simple data transferobjects as inputs and outputs of its operations

    It is dangerous because the resulting XSD may be complex and

    less interoperable There is risk of implementation bleed through into the service

    interface and coupling between the client and service

    It ti 2 O iIteration 2 Overview

  • 8/14/2019 D22 Web Services

    44/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    44

    Iteration 2 OverviewIteration 2 Overview

    1. Develop a Java service class to get details about a game and

    to update its score

    2. Use the Web service wizard to deploy the service

    3. Use the WSDL editor to view the generated WSDL

    Create the Ja a ser ice implementationCreate the Java service implementation

  • 8/14/2019 D22 Web Services

    45/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    45

    Create the Java service implementationCreate the Java service implementation

    The service implementation will be created in the packagecom.leagueplanet

    Import the following Java classes intoIceHockeyService/src/com/leagueplanet:

    GameDetail.java the data transfer class

    GameException.java

    ScoreException.java

    Update.java the service class

    The service has two operations:

    getGame updateScore

    The service accesses the League Planet business tier

    Deploy the serviceDeploy the service

    http://../Temp/notesEA312D/examples/webservices/iteration2/IceHockeyService/src/com/leagueplanet/GameDetail.javahttp://../Temp/notesEA312D/examples/webservices/iteration2/IceHockeyService/src/com/leagueplanet/GameException.javahttp://../Temp/notesEA312D/examples/webservices/iteration2/IceHockeyService/src/com/leagueplanet/ScoreException.javahttp://../Temp/notesEA312D/examples/webservices/iteration2/IceHockeyService/src/com/leagueplanet/Update.javahttp://../Temp/notesEA312D/examples/webservices/iteration2/IceHockeyService/src/com/leagueplanet/Update.javahttp://../Temp/notesEA312D/examples/webservices/iteration2/IceHockeyService/src/com/leagueplanet/ScoreException.javahttp://../Temp/notesEA312D/examples/webservices/iteration2/IceHockeyService/src/com/leagueplanet/GameException.javahttp://../Temp/notesEA312D/examples/webservices/iteration2/IceHockeyService/src/com/leagueplanet/GameDetail.java
  • 8/14/2019 D22 Web Services

    46/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    46

    Deploy the serviceDeploy the service

    Select Update.java and execute the command Web Services >

    Create Web service

    Check the Install and Start Web service boxes You could clickCheck the Install and Start Web service boxes You could click

  • 8/14/2019 D22 Web Services

    47/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    47

    Check the Install and Start Web service boxes. You could clickCheck the Install and Start Web service boxes. You could clickFinishFinish at this point since the wizard picks sensible defaults.at this point since the wizard picks sensible defaults.ClickClickNextNextto step this the pages.to step this the pages.

    The wizard lets you select a different classThe wizard lets you select a different class

  • 8/14/2019 D22 Web Services

    48/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    48

    The wizard lets you select a different class.The wizard lets you select a different class.ClickClickNextNext..

    The wizard lets you select a different projectThe wizard lets you select a different project

  • 8/14/2019 D22 Web Services

    49/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    49

    The wizard lets you select a different project.The wizard lets you select a different project.ClickClickNextNext..

  • 8/14/2019 D22 Web Services

    50/109

    Confirm that Update was deployed using theConfirm that Update was deployed using the

  • 8/14/2019 D22 Web Services

    51/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    51

    Confirm that Update was deployed using theConfirm that Update was deployed using theAxisServlet.AxisServlet.

    View the generated Update wsdl in the WSDLView the generated Update wsdl in the WSDL

  • 8/14/2019 D22 Web Services

    52/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    52

    View the generated Update.wsdl in the WSDLView the generated Update.wsdl in the WSDLeditor.editor.

  • 8/14/2019 D22 Web Services

    53/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    53

    Iteration 3 Iteration 3

    Generating WebGenerating WebService Client ProxiesService Client Proxies

    Iteration 3 Generating Web Service ClientIteration 3 Generating Web Service Client

  • 8/14/2019 D22 Web Services

    54/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    54

    Iteration 3 Generating Web Service ClientIteration 3 Generating Web Service ClientProxiesProxies

    Web services can be invoked from programs written in many

    programming languages, e.g. Java, C#, PHP, JavaScriptTM etc. Most languages support dynamic invocation and do not require

    any code generation

    A client proxy simplifies Web service invocation by producing aclass that resembles the service interface In J2EE, client proxies are specified by JAX-RPC and its follow-

    on JAX-WS

    Iteration 3 OverviewIteration 3 Overview

  • 8/14/2019 D22 Web Services

    55/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    55

    Iteration 3 OverviewIteration 3 Overview

    1. Use the Web service wizard to generate a Java client proxy

    and a JSP test client

    2. Test the service using the JSP test client

    Select Update.wsdl and execute the commandSelect Update.wsdl and execute the commandWeb Services >Web Services >

  • 8/14/2019 D22 Web Services

    56/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    56

    ppGenerate ClientGenerate Client. The wizard opens. Check the Install, Test, and. The wizard opens. Check the Install, Test, andMonitor boxes and clickMonitor boxes and clickNextNext..

    The wizard validates the WSDL ClickThe wizard validates the WSDL Click

  • 8/14/2019 D22 Web Services

    57/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    57

    The wizard validates the WSDL. ClickThe wizard validates the WSDL. ClickNextNext..

    The wizard lets you select a different clientThe wizard lets you select a different client

  • 8/14/2019 D22 Web Services

    58/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    58

    The wizard lets you select a different clientThe wizard lets you select a different clientproject. Clickproject. ClickNextNext..

    The wizard lets you change the package forThe wizard lets you change the package for

  • 8/14/2019 D22 Web Services

    59/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    59

    The wizard lets you change the package forThe wizard lets you change the package forthe generated client proxy code. Clickthe generated client proxy code. ClickNextNext..

    The wizard lets you select the operations to include in theThe wizard lets you select the operations to include in the

  • 8/14/2019 D22 Web Services

    60/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    60

    y pgenerated JSP test client. It also lets you select a differentgenerated JSP test client. It also lets you select a differentoutput folder for the JSPs. Clickoutput folder for the JSPs. ClickFinishFinish..

    What the wizard didWhat the wizard did

  • 8/14/2019 D22 Web Services

    61/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    61

    What the wizard didWhat the wizard did

    Created a new Dynamic Web project named

    IceHockeyServiceClient Installed Axis in IceHockeyServiceClient Generated Java proxy code including XML data binding classes

    and exceptions in IceHockeyServiceClient/src/com/leagueplanet Generated JSP test client code in

    IceHockeyWebContent/sampleUpdateProxy Started an instance of the TCP/IP Monitor and configured the

    JSP client to use it Opened the JSP test client in a Web browser You are now ready to test the Web service

  • 8/14/2019 D22 Web Services

    62/109

    Click the updateScore method. Enter input parameters andClick the updateScore method. Enter input parameters and

  • 8/14/2019 D22 Web Services

    63/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    63

    clickclickInvokeInvoke. The operation returns an empty result.. The operation returns an empty result.

    Click the getGameDetails method. Enter gameId =1 and clickClick the getGameDetails method. Enter gameId =1 and clickInvokeInvoke..Vi th d t d i th R lt t fi th t thVi th d t d i th R lt t fi th t th

  • 8/14/2019 D22 Web Services

    64/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    64

    View the updated score in the Result pane to confirm that theView the updated score in the Result pane to confirm that theupdateScore operation works correctly.updateScore operation works correctly.

  • 8/14/2019 D22 Web Services

    65/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    65

    Iteration 4 Iteration 4

    Testing Web ServicesTesting Web Servicesfor Interoperabilityfor Interoperability

  • 8/14/2019 D22 Web Services

    66/109

    Click the getEndpoint method. ClickClick the getEndpoint method. ClickInvokeInvoke. View the endpoint. View the endpointdd i th R lt N t th t bdd i th R lt N t th t b

  • 8/14/2019 D22 Web Services

    67/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    67

    address in the Result pane. Note the port number.address in the Result pane. Note the port number.

    Open the Preferences dialog and select the TCP/IP MonitorOpen the Preferences dialog and select the TCP/IP MonitorN t th t b f th it t h thN t th t b f th it t h th

  • 8/14/2019 D22 Web Services

    68/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    68

    page. Note the port number of the monitor matches thepage. Note the port number of the monitor matches theendpoint.endpoint.

    View the recorded messages in the TCP/IP Monitor view. ClickView the recorded messages in the TCP/IP Monitor view. Clickth V lid t i (d t ith h k k)th V lid t i (d t ith h k k)

  • 8/14/2019 D22 Web Services

    69/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    69

    the Validate icon (document with checkmark).the Validate icon (document with checkmark).

    The wizard lets you select a folder to store the message logThe wizard lets you select a folder to store the message logfil S l t I H k S i Cli t d li kfile Select IceHockeyServiceClient and click N tNext

  • 8/14/2019 D22 Web Services

    70/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    70

    file. Select IceHockeyServiceClient and clickfile. Select IceHockeyServiceClient and clickNextNext..

    The wizard lets you validate the message against aThe wizard lets you validate the message against aS f S

  • 8/14/2019 D22 Web Services

    71/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    71

    WSDL file. Select Update.wsdl and click Next.WSDL file. Select Update.wsdl and click Next.

    The wizard lets you select the WSDL elementThe wizard lets you select the WSDL element

  • 8/14/2019 D22 Web Services

    72/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    72

    yyto use. Select the Update port and clickto use. Select the Update port and clickFinishFinish..

    The messages are valid. In the event of errors,The messages are valid. In the event of errors,k l d i h d l filk l d i th t d l fil

  • 8/14/2019 D22 Web Services

    73/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    73

    markers are placed in the generated log file.markers are placed in the generated log file.

    Use the Profile Compliance and ValidationUse the Profile Compliance and ValidationP f t t l th l l f lid tiP f t t l th l l f lid ti

  • 8/14/2019 D22 Web Services

    74/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    74

    Preference page to control the level of validation.Preference page to control the level of validation.

  • 8/14/2019 D22 Web Services

    75/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    75

    Iteration 5 Iteration 5

    Using Web Services inUsing Web Services inApplicationsApplications

    Iteration 5 Using Web Services inIteration 5 Using Web Services in

  • 8/14/2019 D22 Web Services

    76/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    76

    ggApplicationsApplications

    Web services can be used in applications developed with many

    programming languages and technologies Web services allow alternate user interfaces to be developed Web services allow decoupling of the presentation and business

    tiers within an enterprise Java applications can use JAX-RPC or JAX-WS to access both

    Java and non-Java Web services

  • 8/14/2019 D22 Web Services

    77/109

    Create a new servlet in IceHockeyServiceClient.Create a new servlet in IceHockeyServiceClient.E t k d l Cli kEnter package and class names Click N tNe t

  • 8/14/2019 D22 Web Services

    78/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    78

    Enter package and class names. ClickEnter package and class names. ClickNextNext..

    Enter a description and URL mapping.Enter a description and URL mapping.

  • 8/14/2019 D22 Web Services

    79/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    79

    p pp gClickClickNextNext..

  • 8/14/2019 D22 Web Services

    80/109

    Develop the user interfaceDevelop the user interface

  • 8/14/2019 D22 Web Services

    81/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    81

    The wizard created and configured the UpdateScoreServlet Create two new JSPs:

    score-form.jsp to input score, has Submit button

    score-confirmation.jsp to confirm score update, has Edit button

    Code the servlet as follows: doGet takes a gameId query parameter, calls the service to get the

    game detail, puts the game detail in the session, and forwards to

    score-form.jsp

    doPost takes gameId, visitorScore, and homeScore query

    parameters, calls the service to update the score, gets the newgame detail, and forwards to score-confirmation.jsp

    Import the UI codeImport the UI code

  • 8/14/2019 D22 Web Services

    82/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    82

    Just kidding! That was way too much code to write. Import the following code into IceHockeyService:

    /src/com/leagueplanet/ui/UpdateScoreServlet.java

    /WebContent/score-form.js

    /WebContent/score-confirmation.js

    /WebContent/schedule.css

    /WebContent/validator.css

    /WebContent/score-validator.js

    Note the JAX-RPC usage pattern in the servlet

    Select the updateScore servlet and execute the commandSelect the updateScore servlet and execute the commandRun As >Run As >Run on ServerRun on Server. A GameException is thrown because you didnt. A GameException is thrown because you didnt

    http://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/src/com/leagueplanet/ui/UpdateScoreServlet.javahttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/score-form.jsphttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/score-confirmation.jsphttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/schedule.csshttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/validator.csshttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/score-validator.jshttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/score-validator.jshttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/score-validator.jshttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/validator.csshttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/validator.csshttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/schedule.csshttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/schedule.csshttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/score-confirmation.jsphttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/score-confirmation.jsphttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/score-form.jsphttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/WebContent/score-form.jsphttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/src/com/leagueplanet/ui/UpdateScoreServlet.javahttp://../Temp/notesEA312D/examples/webservices/iteration5/IceHockeyServiceClient/src/com/leagueplanet/ui/UpdateScoreServlet.java
  • 8/14/2019 D22 Web Services

    83/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation

    83

    p yp yprovide a gameId query parameter.provide a gameId query parameter.

    Append ?gameId=1 to the URL and try again. Now the scoreAppend ?gameId=1 to the URL and try again. Now the scoreform is displayed. Enter a new score and clickform is displayed. Enter a new score and click SubmitSubmit..

  • 8/14/2019 D22 Web Services

    84/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 84

    form is displayed. Enter a new score and clickform is displayed. Enter a new score and clickSubmitSubmit..

    The score confirmation page is displayed.The score confirmation page is displayed.Cli kCli k EditEdit t d t th it d t th i

  • 8/14/2019 D22 Web Services

    85/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 85

    ClickClickEditEditto update the score again.to update the score again.

  • 8/14/2019 D22 Web Services

    86/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 86

    Iteration 6 Iteration 6

    Discovering andDiscovering andPublishing WebPublishing Web

    ServicesServices

    Iteration 6 Discovering and Publishing WebIteration 6 Discovering and Publishing WebS iServices

  • 8/14/2019 D22 Web Services

    87/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 87

    ServicesServices

    You can look for available Web services in UDDI registries You can also publish Web services in UDDI registries UDDI provides a SOAP Web service for dynamic discovery You can also look for and publish Web services using the simpler

    WSIL document format In the future, Web crawlers might harvest WSIL documents and

    automatically populate UDDI registries so you can take

    advantage of the powerful UDDI inquiry support

    Iteration 6 OverviewIteration 6 Overview

  • 8/14/2019 D22 Web Services

    88/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 88

    1. Explore a UDDI registry

    2. Explore a WSIL document

    3. Create a WSIL document

    Launch the Web Service Explorer. Select theLaunch the Web Service Explorer. Select theXMethods UDDI Registry and clickXMethods UDDI Registry and click GoGo

  • 8/14/2019 D22 Web Services

    89/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 89

    XMethods UDDI Registry and clickXMethods UDDI Registry and clickGoGo..

    View the registry details. Click theView the registry details. Click the FindFindli kli k

  • 8/14/2019 D22 Web Services

    90/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 90

    link.link.

    Enter a name for the query. Search for Services. Enter a partialEnter a name for the query. Search for Services. Enter a partialservice name to search for and clickservice name to search for and clickGoGo..

  • 8/14/2019 D22 Web Services

    91/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 91

    View the query results. Click the service linksView the query results. Click the service linksto explore the servicesto explore the services

  • 8/14/2019 D22 Web Services

    92/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 92

    to explore the services.to explore the services.

    View the webservicex.com service. Click theView the webservicex.com service. Click theAdd to WSDL Page icon (with plus sign)Add to WSDL Page icon (with plus sign)

  • 8/14/2019 D22 Web Services

    93/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 93

    Add to WSDL Page icon (with plus sign).Add to WSDL Page icon (with plus sign).

    View the WSDL details. Click theView the WSDL details. Click theStockQuoteSOAP linkStockQuoteSOAP link

  • 8/14/2019 D22 Web Services

    94/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 94

    StockQuoteSOAP link.StockQuoteSOAP link.

    View the WSDL binding details. Click theView the WSDL binding details. Click theGetQuote linkGetQuote link

  • 8/14/2019 D22 Web Services

    95/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 95

    GetQuote link.GetQuote link.

    View the operation details. Click the Add linkView the operation details. Click the Add linkand enter a stock symbol Clickand enter a stock symbol Click GoGo

  • 8/14/2019 D22 Web Services

    96/109

    2006 WebSphere Services Technical Conference 2006 IBM Corporation 96

    and enter a stock symbol. Clickand enter a stock symbol. ClickGoGo..

    View the result of the operation in theView the result of the operation in theStat s paneStatus pane

  • 8/14/2019 D22 Web Services

    97/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 97

    Status pane.Status pane.

  • 8/14/2019 D22 Web Services

    98/109

    Surf toSurf to http://www.xmethods.nethttp://www.xmethods.net. Click the. Click theAccess linkAccess link

    http://www.xmethods.net/http://www.xmethods.net/http://www.xmethods.net/
  • 8/14/2019 D22 Web Services

    99/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 99

    Access link.Access link.

    View the many access methods supported byView the many access methods supported byXMethods Copy the WS-Inspection linkXMethods Copy the WS-Inspection link

  • 8/14/2019 D22 Web Services

    100/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 10

    XMethods. Copy the WS-Inspection link.XMethods. Copy the WS-Inspection link.

    Open the WSIL page of the Web Service Explorer (page with globeOpen the WSIL page of the Web Service Explorer (page with globeicon). Paste in the XMethods WSIL URL, select WSDL Services, andicon). Paste in the XMethods WSIL URL, select WSDL Services, andclickclick GoGo

  • 8/14/2019 D22 Web Services

    101/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 10

    clickclickGoGo..

    View the list of WSDL services registered atView the list of WSDL services registered atXMethodsXMethods

  • 8/14/2019 D22 Web Services

    102/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 10

    XMethods.XMethods.

    Create an new inspection.wsil file inCreate an new inspection.wsil file inIceHockeyService/WebContentIceHockeyService/WebContent

  • 8/14/2019 D22 Web Services

    103/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 10

    IceHockeyService/WebContentIceHockeyService/WebContent

    Edit inspection.wsilEdit inspection.wsil

  • 8/14/2019 D22 Web Services

    104/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 10

    Select IceHockeyService/WebContent/wsdl/querySOAP.wsdl and

    execute the command Web Services > Generate WSIL to create

    querySOAP.wsil Repeat for Update.wsdl Merge the contents of these into inspection.wsil and add

    abstracts Import IceHockeyService/WebContent/inspection.wsil before

    proceeding

    EnterEnterhttp://localhost:8080/IceHockeyService/inspection.wsilhttp://localhost:8080/IceHockeyService/inspection.wsilininWSIL page, select WSDL Services and clickWSIL page, select WSDL Services and clickGoGo..

    http://../Temp/notesEA312D/examples/webservices/iteration6/IceHockeyService/WebContent/inspection.wsilhttp://../Temp/notesEA312D/examples/webservices/iteration6/IceHockeyService/WebContent/inspection.wsilhttp://localhost:8080/IceHockeyService/inspection.wsilhttp://localhost:8080/IceHockeyService/inspection.wsilhttp://localhost:8080/IceHockeyService/inspection.wsil
  • 8/14/2019 D22 Web Services

    105/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 10

    View the available WSDL services. Click theView the available WSDL services. Click theQuerySOAP.wsdl link.QuerySOAP.wsdl link.

  • 8/14/2019 D22 Web Services

    106/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 10

    QuerySOAP.wsdl link.QuerySOAP.wsdl link.

    View the QuerySOAP.wsdl details.View the QuerySOAP.wsdl details.

  • 8/14/2019 D22 Web Services

    107/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 10

    Web Services SummaryWeb Services Summary

  • 8/14/2019 D22 Web Services

    108/109

    2006 WebSphere Services Technical Conference

    2006 IBM Corporation 10

    In this tutorial you have covered all the major functional areas of

    Web service development that are available in WTP Tools covered included the Web Service Wizard, Web Service

    Explorer, XSD Editor, WSDL Editor, TCP/IP Monitor, and WS-I

    Test Tools Technologies covered include XSD, WSDL, SOAP, UDDI, WSIL,

    JAX-RPC, and Axis For further details consult the WTP Help and Web site

  • 8/14/2019 D22 Web Services

    109/109