12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 14 ■ SOAP WEB SERVICESComing back to <strong>Java</strong>, the JCP has a set of specifications that are part of <strong>Java</strong> <strong>EE</strong> 6 and <strong>Java</strong> SE 6. Theyinclude JAX-WS 2.2 (JSR 224), Web Services 1.2 (JSR 109), JAXB 2.2 (JSR 222), Web Services Metadata 2.0(JSR 181), and JAXR 1.0 (JSR 93). Taken together, these specifications are usually referred to by theinformal term <strong>Java</strong> Web Services (JWS).At first, these lists of specifications may make you think that writing a SOAP web service in <strong>Java</strong>would be difficult, especially when it comes to getting your head around the APIs. However, the beautyof it is that you don’t need to worry about the underlying technologies (XML, WSDL, SOAP, HTTP, etc.),as just a few JWS standards will do the work for you.JAX-WS 2.2Since <strong>Java</strong> <strong>EE</strong> 5, JAX-WS (JSR 224) is the preferred technology to write SOAP web services. Prior to JAX-WS was JAX-RPC 1.0 (JSR 101). JAX-RPC has been pruned in <strong>Java</strong> <strong>EE</strong> 6, meaning that it is proposed to beremoved from <strong>Java</strong> <strong>EE</strong> 7.JAX-WS 2.2 defines a set of APIs and annotations that allow you to build and consume web services<strong>with</strong> <strong>Java</strong>. It provides the consumer and service facilities to send and receive web service requests viaSOAP, masking the complexity of the protocol. Therefore, neither the consumer nor the service has togenerate or parse SOAP messages, as JAX-WS deals <strong>with</strong> the low-level processing. The JAX-WSspecification depends on other specifications such as <strong>Java</strong> Architecture for XML Binding (JAXB).Web Services 1.2JSR 109 (“Implementing Enterprise Web Services”) defines the programming model and runtimebehavior of web services in the <strong>Java</strong> <strong>EE</strong> container. It also defines packaging to ensure portability of webservices across application server implementations.JAXB 2.2Web services send requests and responses exchanging XML messages. In <strong>Java</strong>, there are several low-levelAPIs to process XML documents and XML Schemas. The JAXB specification provides a set of APIs andannotations for representing XML documents as <strong>Java</strong> artifacts, allowing developers to work <strong>with</strong> <strong>Java</strong>objects representing XML documents. JAXB (JSR 222) facilitates unmarshalling XML documents intoobjects and marshalling objects back into XML documents. Even if JAXB can be used for any XMLpurpose, it is tightly integrated <strong>with</strong> JAX-WS.WS-Metadata 2.0Web Services Metadata (WS-Metadata, specification JSR 181) provides annotations that facilitate thedefinition and deployment of web services. The primary goal of JSR 181 is to simplify the development ofweb services. It provides mapping facilities between WSDL and <strong>Java</strong> interfaces, and vice versa, throughannotations. These annotations can be used <strong>with</strong>in simple <strong>Java</strong> classes or EJBs.JAXR 1.0The <strong>Java</strong> API for XML Registries (JAXR) specification defines a standard set of APIs that allow <strong>Java</strong> clientsto access UDDI. Like JAX-RPC, JAXR (JSR 93) is the second web service-related specification to be419

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!