Java Web Services Developer Pack v 1 3

Java Web Services Developer Pack v 1. 3 Zhongnan Shen 12/04/2003

Outlines o o What is WSDP? What’s in WSDP? An Example The Coffee Break Application Resources

What is WSDP o o o A free integrated toolkit used to build and test XML applications, Web services, and Web applications with the latest Web service technologies and standards implementations ; Supports WS-I Basic Profile 1. 0; Can be downloaded at http: //java. sun. com/webservices/downloads/webservicespack. html size: 26 M; platform: windows, unix

What’s in WSDP o o o Java Architecture for XML Binding (JAXB) v 1. 0. 2; Java API for XML Processing (JAXP) v 1. 2. 4; Java API for XML-based RPC (JAX-RPC) v 1. 1; SOAP with Attachments API for Java (SAAJ) v 1. 2; Java API for XML Registries (JAXR) v 1. 0. 5; Java. Server Faces (JSF) v 1. 0 EA 4; Java. Server Pages Standard Tag Library (JSTL) v 1. 1 EA; XML and Web Services Security v 1. 0 EA 2; Java WSDP Registry Server v 1. 0_06; Ant Build Tool 1. 5. 4; Apache Tomcat v 5 development container; Ws-I Supply Chain Management Sample Application 1. 0;

What’s in WSDP o Java Architecture for XML Binding (JAXB) n n n Providing API and tools for automating the mapping between XML documents and Java objects; Compiling an XML schema into one or more Java technology classes; The following operations can be performed: o o o unmarshal XML content into a Java representation; access, update and validate the Java representation against schema constraint; marshal the Java representation of the XML content into XML content.

What’s in WSDP o Java Architecture for XML Binding (JAXB) XML Schema Java Class Files <xsd: element name="purchase. Order" type="Purchase. Order. Type"/> Purchase. Order. java <xsd: element name="comment" type="xsd: string"/> Comment. java <xsd: complex. Type name="Purchase. Order. Type"> <xsd: sequence> <xsd: element name="ship. To" type="USAddress"/> <xsd: element name="bill. To" type="USAddress"/> <xsd: element ref="comment" min. Occurs="0"/> </xsd: sequence> <xsd: attribute name="order. Date" type="xsd: date"/> </xsd: complex. Type> Purchase. Order Type. java

What’s in WSDP o Java API for XML Processing (JAXP) n supports processing of XML documents using DOM, SAX, and XSLT; o o o n Document Object Model (DOM): an application programming interface for HTML and XML documents; Simple API for XML (SAX): a common interface implemented for many different XML parsers; XSL Transformations (XSLT): a language for transforming XML documents into other XML documents; supports for XML schema and an XSLT compiler (XSLTC);

What’s in WSDP o Java API for XML-Based RPC (JAX-RPC) n n an API for building Web services and clients that use remote procedure calls (RPC) and XML ; an easy-to-develop programming model for development of SOAP based web services, including web service clients and endpoints; o n n developers are not exposed to the complexity of SOAP protocol level mechanisms; support for WSDL->Java and Java->WSDL mapping; support for SOAP message processing model; support for document based messaging; support HTTP level session management and SSL based security mechanisms.

What’s in WSDP o Java API for XML-Based RPC (JAX-RPC)

What’s in WSDP o SOAP with Attachments API for Java (SAAJ) n n enables developers to produce and consume messages conforming to the SOAP 1. 1 specification and SOAP with Attachments note; derived from the package originally defined in the JAXM 1. 0 specification; SOAP messages can contain both XML contents and non-XML contents (as attachments); Messages sent using the SAAJ API are called request-response messages;

What’s in WSDP o SOAP with Attachments API for Java (SAAJ)

What’s in WSDP o Java API for XML Registries (JAXR) n n provides a uniform and standard Java API for accessing different kinds of XML Registries; o eb. XML Registry and Repository standard; o Universal Description, Discovery, and Integration (UDDI); JAXR enables Java software programmers to use a single, easy-to-use abstraction API to access a variety of XML registries. A unified JAXR information model describes content and metadata within XML registries;

What’s in WSDP o Java API for XML Registries (JAXR)

What’s in WSDP o Java. Server Faces Technologies n n a server-side user interface framework for Java technology-based Web applications ; Main components include: o o A set of APIs for: representing UI components and managing their state; handling events and input validation; defining page navigation; supporting internationalization and accessibility. A Java. Server Pages (JSP) custom tag library for expressing UI components within a JSP page.

What’s in WSDP o Java. Server Faces Technologies

What’s in WSDP o Java. Server Pages Standard Tag Library (JSTL) encapsulates core functionality common to many JSP applications; <c: for. Each var="item" items="${session. Scope. cart. items}"> n . . . <tr> <td align="right" bgcolor="#ffffff"> ${item. quantity} </td>. . . </c: for. Each>

What’s in WSDP o Java. Server Pages Standard Tag Library (JSTL) Area Subfunction Prefix Variable Support Core Flow Control URL Management c Miscellaneous Core XML Flow Control x Transformation Locale I 18 n Database Functions Message formatting Number and date formatting SQL Collection length String manipulation fmt sql fn

What’s in WSDP o XML and Web Services Security n Transport-Level Security security is addressed by the transport layer. o Basic Authentication with JAX-RPC; o Client-Certificate Authentication over HTTP/SSL with JAX-RPC; n Message-Level Security security information is contained within the SOAP message.

What’s in WSDP o Java WSDP Registry Server n n n The Java Web Services Developer Pack (Java WSDP) Registry Server implements Version 2 of UDDI; provide a UDDI registry for Web services in a private environment; use it with the Java WSDP APIs as a test registry for Web services application development.

An Example o Coffee Break Application The Coffee Break server obtains the coffee varieties and their prices by querying distributors at startup and on demand. • The Coffee Break server uses SAAJ messaging to communicate with one of its distributors. • The Coffee Break server uses JAXR to send a query searching for coffee distributors that support JAX-RPC to the Registry Server. • The Coffee Break server requests price lists from each of the coffee distributors. The Coffee Break server forwards suborders to each distributor to get confirmations.

An Example-Coffee Break o JAX-RPC Distributor Service n Service side Service Interface public interface Supplier. IF extends Remote { public Confirmation. Bean place. Order(Order. Bean order) throws Remote. Exception; public Price. List. Bean get. Price. List() throws Remote. Exception; } o Publishing the Service in the Registry JAXRPublisher publisher = new JAXRPublisher(); publisher. make. Connection(query. URL, publish. URL); String key = publisher. execute. Publish(username, password, endpoint); o

An Example-Coffee Break o JAX-RPC Distributor Service n Client side Building the Static Stub Client; Clients makes remote call through a stub, a local object which acts as a proxy for the remote service. o wscompile -gen: client -d build -classpath build config-wsdl. xml -gen: client flag instructs wscompile to generate the stubs; -d: flag tells the tool to write the output to the build subdirectory; config-wsdl. xml file: specifies the location of the WSDL file; o Invoking the remote method Price. List. Bean price. List = Price. Fetcher. get. Price. List(distributor);

An Example-Coffee Break o SAAJ Distributor Service n SAAJ Service o o Returning the Price List public void do. Post(Http. Servlet. Request req, Http. Servlet. Response resp) { …Analyze the request… …Compose the message… Output. Stream os = resp. get. Output. Stream(); reply. write. To(os); os. flush(); } Returning the Order Confirmation

An Example-Coffee Break o SAAJ Distributor Service n SAAJ Client SOAPConnection. Factory scf = SOAPConnection. Factory. new. Instance(); SOAPConnection con = scf. create. Connection(); …… Compose the request …… SOAPMessage response = con. call(request, endpoint);

An Example-Coffee Break o Coffee Break Server The Coffee Break Server uses servlets, JSP pages, and Java. Beans components to dynamically construct HTML pages for consumption by a Web browser client. n Retail. Price. List. Servlet o o & Retail. Price. List The Retail. Price. List. Servlet responds to requests to reload the price list; Component Retail. Price. List n Discovering the JAX-RPC Service JAXRQuery. By. Name jq = new JAXRQuery. By. Name(); connection = jq. make. Connection(query. URL, publish. URL); jq. execute. Query(query. String); n n Query JAX-RPC service and SAAJ service Checkout. Form. Bean submits suborders to each distributor

Resources o Java Web Services Developer Pack 1. 3 dowload: http: //java. sun. com/webservices/downloads/webservice spack. html Tutorial: http: //java. sun. com/webservices/docs/1. 3/tutorial/doc/i ndex. html Sample Applications: http: //java. sun. com/webservices/docs/1. 3/wsisampleapp/index. html

Thanks for Listening
- Slides: 27