J1PodDemoWebservices

Revision as of 18:33, 6 November 2009 by Admin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

J1 Web Service Designer Demo for NetBeans, Enterprise Pack

1. Introduction & Requirements:

  • Demonstration of the following
  • Creating a Web Service form an external WSDL file.
  • Adding a new operation to the Web Service which uses schema elements from a local schema file.
  • Modifying the WSIT related configuration for the Web Service
  • Deploying and testing the Web Service

Talk/Show:

  • In this demo we will develop a Web Service from an existing external WSDL file which already has a operation. We will add an operation to the Web Service. We will also modify WSIT (Web Services Interoperability) related configuration for the Web Service. And finally we will deploy the Web Service to Sun Java System Application Server and test it using the Web Service test client.


2. Create a Web Application:

  • Click on 'New Project' button to bring up the wizard, select 'Web' category and 'Web Application' project type. Click 'Next'.
  • Type 'PortfolioApp' for project name; select Sun Java System Application Server/GlassFish for target server and 'Java EE 5' for Java EE version. Click 'Finish'.

Talk/Show:

  • We will be creating a Portfolio Web application. We will start with a WSDL which has already defined "GetLastTradePrice" operation which returns the last trading price for a given stock symbol. We will then create a getNetWorth operation which takes a Portfolio containing stocks and their purchased quantities, as an input and returns the the Net-worth for the Portfolio.

3. Create Web Service from WSDL:

  • Right click on 'Portfolio' project and do 'New > Web Service From WSDL...'
  • Enter "StockQuoteService" in the Web Service Name: text field.
  • Enter "example" in the Package: text field.
  • Click on Browse... button next to Local WSDL File: text field and navigate and select Stockquote.wsdl file.
  • Wait for the wizard to fill in the Web Service Port: information and click 'Finish'.

Talk/Show:

  • New Web Service form WSDL allows you to create Web Service implementation for an existing WSDL file. The WSDL file and its closure is copied into the projects Configuration files. After the Web Service is created it will be opened in Web Service Designer.

4. Demonstrate the Web Service design view

  • Show the zoom functionality
  • Show the collapse expand functionality.
  • Switch between tab and list view.
  • Show the popup menus.
  • Show the sample message.
  • Show the Description tab and then switch to Source multiview. Add some javadoc before the getLastTradePrice method. Save the file (CTRL+S) and switch to design view. Show the updated description.

Talk/Show:

  • The Web Service Designer helps user modify Web Service using a user friendly UI rather than the Java editor.
  • It allows zooming.
  • It allows collapsing or expanding of one or more or all operations reducing the cluttering if there are many operations.
  • It presents operations in list or tabbed views.
  • It has a facility to see how the sample input or sample output message would look for an operation.

5. Adding a new operation to the Web Service

  • Copy the schema file representing the schema elements for the new operation. The schema file is Networth.xsd which will be j1data directory in Favorites.
  • Click on the "Add Operation..." button.
  • On the Add Web Service Operation dialog:
  • Enter "getNetWorth" in the text field for Operation Name:.
  • Click on "Import XML Schema..." button.
  • On the "Add Schema" dialog:
  • Click on "Add..." button.
  • On the Select Schema dialog navigate and select the schema file and click OK.
  • Click OK on Add Schema dialog.
  • Click on Add button in the Parameters tab
  • Enter portfolio as name of the parameter and select the schema element portfolio
  • Select the schema element Networth as the Return type
  • Click OK

Talk/Show:

  • The Web Service Designer also allows to add operation to the Web Service. If the new operation requires parameter from a schema file which is local to the project, the Add Operation dialog allows importing the schema file. The schema file will be added as imported schema in the types section of the WSDL file. When the operation is added code generation is triggered which updates the implementation class as well as the WSDL file.

6. Modifying the WSIT configuration

  • Open the WSDL file under configuration files. Show no WSDL extensibility elements present.
  • hover and click over Reliable Messaging.
  • Switch the WSDL file and show the ws Policy created.

Talk/Show:

  • The designer also allows some modifications to WSIT configuration for the Web Service. There are three toggle buttons provided for MTOM, Security and Reliable messaging. Clicking on them will modify the WSDL file and add relevant WS Policy related information.

7. Deploy and Test Web Service

  • Change the body of getNetWorth operation to "return new com.example.networth.NetValue();".
  • Right Click on PortfolioApp project and select Deploy Project. Wait for the deployment to be complete.
  • Right click on PortfolioService and select "Test Web Service".

Talk/Show:

  • It is also possible to deploy and test the Web Service. The Web Service is deployed to Sun Java System Application Server and a browser window will show the Web Service test client. It is possible to see the WSDL file, which will have new operation added and WSIT configuration applied.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo