Java Web 服務(wù)

出版時(shí)間:2010-1  出版社:東南大學(xué)  作者:卡林  頁數(shù):297  
Tag標(biāo)簽:無  

前言

This is a book for programmers interested in developing Java web services and Java clients against web services, whatever the implementation language. The book is a code- driven introduction to JAX-WS (Java APl for XML-Web Services), the framework of choice for Java web services, whether SOAP-based or REST-style. My approach is to interpret JAX-WS broadly and, therefore, to include leading-edge developments such as the Jersey project for REST-style web services, officially known as JAX-RS (Java APl for XML-RESTful Web Services). JAX-WS is bundled into the Metro Web Services Stack, or Metro for short. Metro is part of core Java, starting with Standard Edition 6 (hereafter, core Java 6). However, the Metro releases outpace the core Java releases. The current Metro release can be down- loaded separately from https://wsit, dev.java.net. Metro is also integrated into the Sun application server, GlassFish. Given these options, this book's examples are deployed in four different ways: Core Java only This is the low-fuss approach that makes it easy to get web services and their clients up and running. The only required software is the Java software development kit (SDK), core Java 6 or later. Web services can be deployed easily using the Endpoint, HttpServer, and HttpsServer classes. The early examples take this approach. Core Java with the current Metro release This approach takes advantage of Metro features not yet available in the core Java bundle. In general, each Metro release makes it easier to write web services and clients. The current Metro release also indicates where JAX-WS is moving. The Metro release also can be used with core Java 5 if core Java 6 is not an option. Standalone Tomcat This approach builds on the familiarity among Java programmers with standalone web containers such as Apache Tomcat, which is the reference implementation. Web services can be deployed using a web container in essentially the same way as are servlets, JavaServer Pages (JSP) scripts, and JavaServer Faces (JSF) scripts. A standalone web container such as Tomcat is also a good way to introduce container-managed security for web services. GlassFish This approach allows deployed web services to interact naturally with other enterprise components such as Java Message Service topics and queues, a JNDI (Java Naming and Directory Interface) provider, a backend database system and the @Entity instances that mediate between an application and the database sys- tem, and an EJB (Enterprise Java Bean) container. The EJB container is important because a web service can be deployed as a stateless Session EJB, which brings advantages such as container-managed thread safety. GlassFish works seamlessly with Metro, including its advanced features, and with popular IDEs (Integrated Development Environment) such as NetBeans and Eclipse. An appealing feature of JAX-WS is that the API can be separated cleanly from deploy- ment options. One and the same web service can be deployed in different ways to suit different needs. Core Java alone is good for learning, development, and even lightweight deployment. A standalone web container such as Tomcat provides additional support. A Java application server such as GlassFish promotes easy integration of web services with other enterprise technologies. Code-Driven Approach My code examples are short enough to highlight key features of JAX-WS but also re- alistic enough to show off the production-level capabilities that come with the JAX-WS framework. Each code example is given in full, including all of the import statements. My approach is to begin with a relatively sparse example and then to add and modify features. The code samples vary in length from a few statements to several pages of source. The code is deliberately modular. Whenever there is a choice between con- ciseness and clarity in coding, I try to opt for clarity. The examples come with instructions for compiling and deploying the web services and for testing the service against sample clients. This approach presents the choices that JAX-WS makes available to the programmer but also encourages a clear and thor- ough analysis of the JAX-WS libraries and utilities. My goal is to furnish code samples that can serve as templates for commercial applications. JAX-WS is a rich API that is explored best in a mix of overview and examples. My aim is to explain key features about the architecture of web services but, above all, to illus- trate each major feature with code examples that perform as advertised: Architecture without code is empty; code without architecture is blind. My approach is to integrate the two throughout the book. Web services are a modern, lightweight approach to distributed software systems, that is, systems such as email or the World Wide Web that require different software com- ponents to execute on physically distinct devices. The devices can range from large servers through personal desktop machines to handhelds of various types. Distributed systems are complicated because they are made up of networked components. There is nothing more frustrating than a distributed systems example that does not work as claimed because the debugging is tedious. My approach is thus to provide full, working examples together with short but precise instructions for getting the sample application up and running. Chapter-by-Chapter Overview The book has seven chapters, the last of which is quite short. Here is a preview of each chapter: Chapter 1, Java Web Services Quickstart This chapter begins with a working definition of web services, including the dis- tinction between SOAP-based and REST-style services. This chapter then focuses on the basics of writing, deploying, and consuming SOAP-based services in core Java. There are web service clients written in Peri, Ruby, and Java to underscore the language neutrality of web services. This chapter also introduces Java's SOAP APl and covers various ways to inspect web service traffic at the wire level. The chapter elaborates on the relationship between core Java and Metro.

內(nèi)容概要

《Java Web 服務(wù):構(gòu)建與運(yùn)行(影印版)》提供了對(duì)Java的API的一個(gè)全面介紹,包括針對(duì)XML Web服務(wù)的JAX-WS和針對(duì)RESTful Web服務(wù)的JAX-RS?!禞ava Web服務(wù):構(gòu)建與運(yùn)行》通過提供混合架構(gòu)概述、完整的工作代碼示例以及短而精確的編譯、部署和執(zhí)行應(yīng)用程序的指示,采用明確實(shí)用的方法來處理這些技術(shù)。你將學(xué)習(xí)如何從頭開始編寫Web服務(wù)以及集成現(xiàn)有服務(wù)到你的Java應(yīng)用程序中。有了這《Java Web 服務(wù):構(gòu)建與運(yùn)行(影印版)》,你將:· 理解基于SOAP的和REST樣式的服務(wù)的區(qū)別· 編寫、部署和使用基于SOAP的核心Java服務(wù)· 理解Web服務(wù)描述語言(WSDL)服務(wù)契約· 認(rèn)識(shí)SOAP消息的結(jié)構(gòu)· 學(xué)習(xí)如何交付基于Java的RESTful Web服務(wù)和消耗商業(yè)RESTful服務(wù)· 了解對(duì)基于SOAP和基于REST的Web服務(wù)的安全要求· 學(xué)習(xí)如何在各種環(huán)境下部署JAX-WS服務(wù)不管是學(xué)生還是有經(jīng)驗(yàn)的程序員,當(dāng)你需要立即運(yùn)用這些技術(shù)展開工作時(shí),《Java Web服務(wù):構(gòu)建與運(yùn)行》都是你需要的一本理想的簡明指南。

作者簡介

Martin Kalin, 德保羅大學(xué)計(jì)算機(jī)和數(shù)字媒體學(xué)院教授,擁有西北大學(xué)的博士學(xué)位。他撰寫過關(guān)于C語言、C++和Java的書,并參與開發(fā)過大型分布式系統(tǒng)中的進(jìn)程調(diào)度和產(chǎn)品配置。

書籍目錄

Preface 1. Java Web Services Quickstart What Are Web Services? What Good Are Web Services? A First Example The Service Endpoint Interface and Service Implementation Bean A Java Application to Publish the Web Service Testing the Web Service with a Browser A Perl and a Ruby Requester of the Web Service The Hidden SOAP A Java Requester of the Web Service Wire-Level Tracking of HTTP and SOAP Messages What’s Clear So Far? Key Features of the First Code Example Java’s SOAP API An Example with Richer Data Types Publishing the Service and Writing a Client Multithreading the Endpoint Publisher What’s Next? 2. All About WSDLs What Good Is a WSDL? Generating Client-Support Code from a WSDL The @WebResult Annotation WSDL Structure A Closer Look at WSDL Bindings Key Features of Document-Style Services Validating a SOAP Message Against a WSDL’s XML Schema The Wrapped and Unwrapped Document Styles Amazon’s E-Commerce Web Service An E-Commerce Client in Wrapped Style An E-Commerce Client in Unwrapped Style Tradeoffs Between the RPC and Document Styles An Asynchronous E-Commerce Client The wsgen Utility and JAX-B Artifacts A JAX-B Example Marshaling and wsgen Artifacts An Overview of Java Types and XML Schema Types Generating a WSDL with the wsgen Utility WSDL Wrap-Up Code First Versus Contract First A Contract-First Example with wsimport A Code-First, Contract-Aware Approach Limitations of the WSDL What’s Next? 3. SOAP Handling SOAP: Hidden or Not? SOAP 1.1 and SOAP 1.2 SOAP Messaging Architecture Programming in the JWS Handler Framework The RabbitCounter Example Injecting a Header Block into a SOAP Header Configuring the Client-Side SOAP Handler Adding a Handler Programmatically on the Client Side Generating a Fault from a @WebMethod Adding a Logical Handler for Client Robustness Adding a Service-Side SOAP Handler Summary of the Handler Methods The RabbitCounter As a SOAP 1.2 Service The MessageContext and Transport Headers An Example to Illustrate Transport-Level Access Web Services and Binary Data Three Options for SOAP Attachments Using Base64 Encoding for Binary Data Using MTOM for Binary Data What’s Next? 4. RESTful Web Services What Is REST? Verbs and Opaque Nouns From @WebService to @WebServiceProvider A RESTful Version of the Teams Service The WebServiceProvider Annotation Language Transparency and RESTful Services Summary of the RESTful Features Implementing the Remaining CRUD Operations Java API for XML Processing The Provider and Dispatch Twins A Provider/Dispatch Example More on the Dispatch Interface A Dispatch Client Against a SOAP-based Service Implementing RESTful Web Services As HttpServlets The RabbitCounterServlet Requests for MIME-Typed Responses Java Clients Against Real-World RESTful Services The Yahoo! News Service The Amazon E-Commerce Service: REST Style The RESTful Tumblr Service WADLing with Java-Based RESTful Services JAX-RS: WADLing Through Jersey The Restlet Framework What’s Next? 5. Web Services Security Overview of Web Services Security Wire-Level Security HTTPS Basics Symmetric and Asymmetric Encryption/Decryption How HTTPS Provides the Three Security Services The HttpsURLConnection Class Securing the RabbitCounter Service Adding User Authentication HTTP BASIC Authentication Container-Managed Security for Web Services Deploying a @WebService Under Tomcat Securing the @WebService Under Tomcat Application-Managed Authentication Container-Managed Authentication and Authorization Configuring Container-Managed Security Under Tomcat Using a Digested Password Instead of a Password A Secured @WebServiceProvider WS-Security Securing a @WebService with WS-Security Under Endpoint The Prompter and the Verifier The Secured SOAP Envelope Summary of the WS-Security Example What’s Next? 6. JAX-WS in Java Application Servers Overview of a Java Application Server Deploying @WebServices and @WebServiceProviders Deploying @WebServiceProviders Integrating an Interactive Website and a Web Service A @WebService As an EJB Implementation As a Stateless Session EJB The Endpoint URL for an EBJ-Based Service Database Support Through an @Entity The Persistence Configuration File The EJB Deployment Descriptor Servlet and EJB Implementations of Web Services Java Web Services and Java Message Service WS-Security Under GlassFish Mutual Challenge with Digital Certificates MCS Under HTTPS MCS Under WSIT The Dramatic SOAP Envelopes Benefits of JAS Deployment What’s Next? 7. Beyond the Flame Wars A Very Short History of Web Services The Service Contract in DCE/RPC XML-RPC Standardized SOAP SOAP-Based Web Services Versus Distributed Objects SOAP and REST in Harmony Index

章節(jié)摘錄

插圖:The HTTP start line comes first and specifies the request method, in this case thePOST method, which is typical of requests for dynamic resources such as webservices or other web application code (for example, a Java servlet) as opposed torequests for a static HTML page. In this case, a POST rather than a GET requestis needed because only a POST request has a body, which encapsulates the SOAPmessage. Next comes the request URL followed by the HTTP version, in this case1.1, that the requester understands. HTTP 1.1 is the current version.Next come the HTTP headers, which are key/value pairs in which a colon (:) separates the key from the value. The order of the key/value pairs is arbitrary. The keyAccept occurs three times, with a MIME (Multipurpose Internet Mail Extensions) type/subtype as the value: text/xml, multipart/*, and application/soap. These threepairs signal that the requester is ready to accept an arbitrary XML response, aresponse with arbitrarily many attachments of any type (a SOAP message can havearbitrarily many attachments), and a SOAP document, respectively. The HTTP keySOAPAction is often present in the HTTP header of a web service request and thekey's value may be the empty string, as in this case; but the value also might be thename of the requested web service operation.Two CRLF (Carriage Return Line Feed) characters, which correspond to two Java\n characters, separate the HTTP headers from the HTTP body, which is requiredfor the POST verb but may be empty. In this case, the HTTP body contains theSOAP document, commonly called the SOAP envelope because the outermost ordocument element is named Envelope. In this SOAP envelope, the SOAP body contains a single element whose local name is getTimeAsString, which is the name ofthe web service operation that the client wants to invoke. The SOAP request envelope is simple in this example because the requested operation takes noarguments.

媒體關(guān)注與評(píng)論

“《Java Web服務(wù):構(gòu)建與運(yùn)行》有很多我發(fā)現(xiàn)非常實(shí)用的實(shí)例,從使用Amazon Associates Web服務(wù)到有很好的圖解和安全說明以及加密密碼的關(guān)于安全的一章,還包括使用證書的示例,這部分內(nèi)容我還沒在其他書中見過?!?  ——Greg Ostravich,Denver Java用戶組主席

編輯推薦

《Java Web 服務(wù):構(gòu)建與運(yùn)行(影印版)》是由東南大學(xué)出版社出版的。

圖書封面

圖書標(biāo)簽Tags

評(píng)論、評(píng)分、閱讀與下載


    Java Web 服務(wù) PDF格式下載


用戶評(píng)論 (總計(jì)12條)

 
 

  •   無論是Java的初學(xué)者,還是想學(xué)習(xí)Java Core中Web Services架構(gòu),或者僅僅是想了解Web Services標(biāo)準(zhǔn),這本書都是非常好的選擇。
    計(jì)算機(jī)方面的圖書,還是要看英文原版。老外的清晰、細(xì)膩的講述方式,能讓我們很快了解技術(shù)的內(nèi)在機(jī)理以及其中的思想。看完這本書后,學(xué)到的不是僅僅一些過一段時(shí)間就很可能忘得一干二凈的具體技術(shù),更重要的是Java的編程思想,以及這些思想是怎樣演化為Java框架下的各種豐富多彩的技術(shù),還有各種技術(shù)最終是怎樣為Web Services標(biāo)準(zhǔn)服務(wù)的。
    覆蓋了Java下的幾乎所有Sun官方支持的核心技術(shù)。學(xué)習(xí)的過程很艱苦,不過看完后有一種功德圓滿的感覺。
    看完整本書,順便還能對(duì)英語有很大的提高。
  •   很好的書,很好的快遞服務(wù),很快的處理速度。
  •   一步一步交你了解JDK6中對(duì)webservice的支持
  •   基礎(chǔ),權(quán)威,翔實(shí),全面
  •   有例子入手,講的也細(xì)致
  •   這本書寫的挺詳細(xì)的。。很適合初學(xué)者。。不過竟然是英文版的。。
  •   例子精煉,講解清楚全面,非常好的一本書。
  •   英文,怕是看不懂了,
  •   不是本人想要的,是英文版的
  •   我現(xiàn)在就是在看這本書,英文版的,寫的很棒哦?。?!
  •   有貨倒不出。寫的那叫一個(gè)亂。重點(diǎn)非重點(diǎn)全揉雜在一起。
  •   卓越的計(jì)算機(jī)的新書總是最晚上貨并且總是最貴的,這難道是你們認(rèn)為的最合理的定價(jià)策略。對(duì)于讀者固定的計(jì)算機(jī)專業(yè)書,等到你們降價(jià)了的時(shí)候,還有多少人會(huì)買呢?
 

250萬本中文圖書簡介、評(píng)論、評(píng)分,PDF格式免費(fèi)下載。 第一圖書網(wǎng) 手機(jī)版

京ICP備13047387號(hào)-7