Presentation is loading. Please wait.

Presentation is loading. Please wait.

Eclipse Web Tools Platform Project © 2005 IBM Corporation Developing Web Services with Eclipse – Programming Examples Arthur Ryman IBM Rational

Similar presentations


Presentation on theme: "Eclipse Web Tools Platform Project © 2005 IBM Corporation Developing Web Services with Eclipse – Programming Examples Arthur Ryman IBM Rational"— Presentation transcript:

1 Eclipse Web Tools Platform Project © 2005 IBM Corporation Developing Web Services with Eclipse – Programming Examples Arthur Ryman IBM Rational ryman@ca.ibm.com EclipseWorld New York, 2005-08-30

2 Eclipse Web Tools Platform Project © 2005 IBM Corporation 2Developing Web Services with Eclipse, EclipseWorld, New York Development Scenarios  Accessing Web Services  Creating Web Services –Bottom-Up –Top-Down

3 Eclipse Web Tools Platform Project © 2005 IBM Corporation 3Developing Web Services with Eclipse, EclipseWorld, New York Accessing Web Services  The preceding demo generated a JSP test client for the Stock Quote service  We’ll now code a JSP client application that accesses it  The Web Service wizard generated JAX-RPC compliant client code and a convenience wrapper  We’ll use this code in our client

4 Eclipse Web Tools Platform Project © 2005 IBM Corporation 4Developing Web Services with Eclipse, EclipseWorld, New York JAX-RPC Client Code

5 Eclipse Web Tools Platform Project © 2005 IBM Corporation 5Developing Web Services with Eclipse, EclipseWorld, New York JAX-RPC Client Code  package NET.webserviceX.www –targetNamespace="http://www.webserviceX.NET/"  StockQuoteLocator.java – Service locator StockQuoteLocator.java  StockQuote.java – Service interface StockQuote.java –  StockQuoteSoap.java – Remote interface StockQuoteSoap.java –  StockQuoteSoapStub.java – Client stub wrapper for Call object StockQuoteSoapStub.java  StockQuoteSoapProxy.java – Client proxy convenience wrapper StockQuoteSoapProxy.java

6 Eclipse Web Tools Platform Project © 2005 IBM Corporation 6Developing Web Services with Eclipse, EclipseWorld, New York Web Client Version 1: getQuote.jspgetQuote.jsp 1)Create a JSP 1)get a query parameter, “symbol”, 2)create a service proxy, and 3)invoke the “getQuote” operation 2)Select getQuote.jsp and invoke Run As->Run on ServergetQuote.jsp 1)The Web app is added to the server, 2)the server is started, and 3)a Web browser is opened on the appropriate URL for getQuote.jsp getQuote.jsp

7 Eclipse Web Tools Platform Project © 2005 IBM Corporation 7Developing Web Services with Eclipse, EclipseWorld, New York

8 Eclipse Web Tools Platform Project © 2005 IBM Corporation 8Developing Web Services with Eclipse, EclipseWorld, New York

9 Eclipse Web Tools Platform Project © 2005 IBM Corporation 9Developing Web Services with Eclipse, EclipseWorld, New York Processing XML  This service has a poorly designed interface –XML is returned as an escaped string –No schema for result  The client needs to parse the result to extract the price, etc.  Client application can parse XML using: –DOM, –SAX, –Java data binding code (JAXB, etc), or –server-side XSLT  For fun, we’ll use browser-side XSLT

10 Eclipse Web Tools Platform Project © 2005 IBM Corporation 10Developing Web Services with Eclipse, EclipseWorld, New York Web Client Version 2: getQuote-xsl.jspgetQuote-xsl.jsp 1)View example of XML response ibm-quote.xmlibm-quote.xml 2)Create XSLT StockQuotes.xslStockQuotes.xsl 1)Generate to get symbol 2)Generate to present stock quote 3)Create JSP getQuote-xsl.jspgetQuote-xsl.jsp 1)Insert processing instruction 2)Return unparsed XML 4)Run on Server to view result

11 Eclipse Web Tools Platform Project © 2005 IBM Corporation 11Developing Web Services with Eclipse, EclipseWorld, New York

12 Eclipse Web Tools Platform Project © 2005 IBM Corporation 12Developing Web Services with Eclipse, EclipseWorld, New York

13 Eclipse Web Tools Platform Project © 2005 IBM Corporation 13Developing Web Services with Eclipse, EclipseWorld, New York

14 Eclipse Web Tools Platform Project © 2005 IBM Corporation 14Developing Web Services with Eclipse, EclipseWorld, New York

15 Eclipse Web Tools Platform Project © 2005 IBM Corporation 15Developing Web Services with Eclipse, EclipseWorld, New York Bottom-Up Web Service Creation  Any “reasonable” Java class can be easily deployed as a Web service  This approach is very appealing to Java programmers since it lets them be immediately productive  The WSDL is generated from the Java  The result is acceptable if the methods use “tame” argument types, however object graphs are problematic  Top-Down design is recommended to achieve the cleanest and most interoperable Web service interfaces

16 Eclipse Web Tools Platform Project © 2005 IBM Corporation 16Developing Web Services with Eclipse, EclipseWorld, New York Bottom-Up Service: BUService 1)Create a new Web project: BUService 2)Create a data object to represent the result: BUStock.javaBUStock.java 3)Create a business object to take a symbol and return a stock quote for it: BUQuoter.javaBUQuoter.java 4)Use the Web service wizard to deploy it. Use rpc-encoded style for fun so we can see WS-I errors. Generate and monitor a JSP test client. 5)Test the service, view the messages in the monitor, and validate the SOAP messages for WS-I conformance. Note the errors caused by rpc-encoded style.

17 Eclipse Web Tools Platform Project © 2005 IBM Corporation 17Developing Web Services with Eclipse, EclipseWorld, New York

18 Eclipse Web Tools Platform Project © 2005 IBM Corporation 18Developing Web Services with Eclipse, EclipseWorld, New York

19 Eclipse Web Tools Platform Project © 2005 IBM Corporation 19Developing Web Services with Eclipse, EclipseWorld, New York

20 Eclipse Web Tools Platform Project © 2005 IBM Corporation 20Developing Web Services with Eclipse, EclipseWorld, New York

21 Eclipse Web Tools Platform Project © 2005 IBM Corporation 21Developing Web Services with Eclipse, EclipseWorld, New York

22 Eclipse Web Tools Platform Project © 2005 IBM Corporation 22Developing Web Services with Eclipse, EclipseWorld, New York

23 Eclipse Web Tools Platform Project © 2005 IBM Corporation 23Developing Web Services with Eclipse, EclipseWorld, New York Top-Down Web Service Creation  Business is transacted by exchanging documents – purchase orders, receipts, application forms, insurance claims, building permits, etc.  For best interoperability, treat Web services as document interchange, not distributed objects  Model documents using XSD, and operations using WSDL  Generate Java from WSDL

24 Eclipse Web Tools Platform Project © 2005 IBM Corporation 24Developing Web Services with Eclipse, EclipseWorld, New York Top-Down Service: TDService 1)Create a new Web project: TDService 2)Create an XML schema for the Stock quote result: TDStock.xsdTDStock.xsd 3)Create a WSDL for the quote service with an operation that takes a symbol and returns a quote: TDQuoter.wsdl. Use the WSDL Binding wizard to generate document-literal SOAP binding style this time.TDQuoter.wsdl 4)Use the Web service wizard to generate the service. 5)Fill in the implementation of the service: TDQuoterSOAPImpl.javaTDQuoterSOAPImpl.java 6)Create a new Web project: TDServiceClient 7)Select /wsdl/TDQuoterSOAP.wsdl, create a JSP test client, and monitor the service. 8)Test the service and validate the SOAP messages for WS-I conformance. There should be no errors this time.

25 Eclipse Web Tools Platform Project © 2005 IBM Corporation 25Developing Web Services with Eclipse, EclipseWorld, New York

26 Eclipse Web Tools Platform Project © 2005 IBM Corporation 26Developing Web Services with Eclipse, EclipseWorld, New York

27 Eclipse Web Tools Platform Project © 2005 IBM Corporation 27Developing Web Services with Eclipse, EclipseWorld, New York

28 Eclipse Web Tools Platform Project © 2005 IBM Corporation 28Developing Web Services with Eclipse, EclipseWorld, New York

29 Eclipse Web Tools Platform Project © 2005 IBM Corporation 29Developing Web Services with Eclipse, EclipseWorld, New York

30 Eclipse Web Tools Platform Project © 2005 IBM Corporation 30Developing Web Services with Eclipse, EclipseWorld, New York

31 Eclipse Web Tools Platform Project © 2005 IBM Corporation 31Developing Web Services with Eclipse, EclipseWorld, New York


Download ppt "Eclipse Web Tools Platform Project © 2005 IBM Corporation Developing Web Services with Eclipse – Programming Examples Arthur Ryman IBM Rational"

Similar presentations


Ads by Google