Web Service is an emerging technology to address integration and proprietary technology silos.
Java™, XML, SOAP, and UDDI are the typical technologies used.
There is much market hype surrounding Web Services.
Many technology vendors and vertical solutions have already embedded Web Services into their products and solutions.
Web Services provides a service-based infrastructure with intelligent and reusable components.
Web Services addresses technology issues of high implementation cost, legacy systems integration, and cross-platform interoperability.
There are competitive advantages to implementing Web Services. Web Services technology provides a low-cost alternative to integrating with multiple trading partners using open standards. It is platform independent, and provides better flexibility to customers and trading partners, because it can accommodate local data formats, and can reuse existing infrastructure and business functionality from the legacy systems.
Select a reasonably rich set of functionality that can be implemented within three to six months.
The candidate should be able to demonstrate the benefits immediately. A Total Cost of Ownership (TCO) model is required.
Involve leading Web Services vendors for technology skill transfer, for example:
Customize a Web Services training workshop using the pilot requirements.
Assess the Web Services solution architecture.
Do not be too ambitious with too many dependencies or items that require longer lead time (for example, SOAP-enabling a mainframe platform).
Do not start implementation without support from senior management.
Do not start a pilot using a mission-critical functionality.
Do not involve a big team in the pilot. Start with a small team.
A medium-size listed financial institution in Hong Kong wants to reduce its operating costs associated with supporting legacy systems on the mainframe. The corporation has been innovative and reputable in providing securities trading, retail banking, and credit card services to the local market.
The CEO is concerned about implementing new technology for technology's sake and believes that not all legacy systems need to be migrated to Unix, as they are fairly stable.
Is it relevant to introduce Web Service technology to meet its challenge?
Exercise 1 XML to DTD
Your trading partner, XYZ investment bank, provides you with an XML document with real data. They support DTD, not an XML Schema, but they do not have a DTD.
The following XML document (an fpML example) describes an FX option bought by XYZ from ABC traded on January 15, 2002.
Exercise 1.1 Could you check whether this is a well-formed XML? You may use XMLSpy 4.3 Suite (evaluation copy) to validate it.
Note: What information (for example, attributes) do you need before you can validate a well-formed XML document?
Exercise 1.2 Could you reverse-engineer the XML into a DTD? If you generate a sample XML from the DTD, could you get the identical XML?
<?XML version="1.0" " encoding = "UTF-8"?> <!DOCTYPE trade PUBLIC "-//FpML//DTD 3-0//EN" "" > [ <!- DTD declarations omitted --> ]> <trade> <tradeHeader> <partyTradeIdentifier> <partyReference href = "#XYZ"/> </partyTradeIdentifier> <partyTradeIdentifier> <partyReference href = "#ABC"/> </partyTradeIdentifier> <tradeDate>2002-01-15</tradeDate> </tradeHeader> <fxSimpleOption> <productType>Nondeliverable Option</productType> <buyerPartyReference href = "#XYZ"/> <sellerPartyReference href = "#ABC"/> <expiryDateTime> <expiryDate>2002-04-09</expiryDate> <hourMinuteTime>1000</hourMinuteTime> <businessCenter>USNY</businessCenter> </expiryDateTime> <exerciseStyle>European</exerciseStyle> </fxSimpleOption> <party id = "XYZ"> <partyId>CHASUS33</partyId> <partyName>XYZ BUYER BANK</partyName> </party> <party id = "ABCN"> <partyId>ABCANL2A</partyId> <partyName>ABC Seller Bank</partyName> </party> </trade> <!- end of DTDs —>
To assist your understanding, the fxOption XML is depicted in Figure 3-34:
<!— Name: 'trade.dtd' —> <!— Description: sample fpML FX option —> <!ELEMENT trade (tradeHeader, fxSimpleOption, party) > <!ELEMENT tradeHeader (partyTradeIdentifier) > <!ELEMENT fxSimpleOption (productType, buyerPartyReference, sellerPartyReference, expiryDateTime, exerciseStyle) > <!ELEMENT party (partyID, partyName) > <!ELEMENT partyTradeIdentifier (partyReference) > <!ELEMENT partyReference EMPTY > <!ATTLIST partyReference href CDATA #REQUIRED > <!ELEMENT productType (#PCDATA) > <!ELEMENT buyerPartyReference EMPTY > <!ATTLIST buyerPartyReference href CDATA #REQUIRED > <!ELEMENT sellerPartyReference EMPTY > <!ATTLIST sellerPartyReference href CDATA #REQUIRED > <!ELEMENT expiryDateTime (expiryDate, hourMinuteTime, businessCenter) > <!ELEMENT expiryDate (#PCDATA) > <!ELEMENT hourMinuteTime (#PCDATA) > <!ELEMENT businessCenter (#PCDATA) > <!ELEMENT exerciseStyle (#PCDATA) > <!ELEMENT partyID (#PCDATA) > <!ELEMENT partyName (#PCDATA) >
Figure 3-35 shows an example using XMLSPy to validate the DTD in this exercise.
Exercise 2 Writing the First JAXM Program
You are going to install Java Web Services Developer Pack and write your first JAXM-SOAP program.
Exercise 2.1 Download the Java Web Services Developer Pack from http://java.sun.com. Install and configure it according to the Installation Guide.
Exercise 2.2 Based on the sample sniplet in the text, write your first JAXM-SOAP program to send the following XML message:
<?XML version="1.0" " encoding = "UTF-8"?> <!DOCTYPE trade PUBLIC "-//FpML//DTD 3-0//EN" "" > [ <!- DTD declarations omitted --> ]> <trade> <tradeHeader> <partyTradeIdentifier> <partyReference href = "#XYZ"/> </partyTradeIdentifier> <partyTradeIdentifier> <partyReference href = "#ABC"/> </partyTradeIdentifier> <tradeDate>2002-01-15</tradeDate> </tradeHeader> <fxSimpleOption> <productType>Nondeliverable Option</productType> <buyerPartyReference href = "#XYZ"/> <sellerPartyReference href = "#ABC"/> <expiryDateTime> <expiryDate>2002-04-09</expiryDate> <hourMinuteTime>1000</hourMinuteTime> <businessCenter>USNY</businessCenter> </expiryDateTime> <exerciseStyle>European</exerciseStyle> </fxSimpleOption> <party id = "XYZ"> <partyId>CHASUS33</partyId> <partyName>XYZ BUYER BANK</partyName> </party> <party id = "ABCN"> <partyId>ABCANL2A</partyId> <partyName>ABC Seller Bank</partyName> </party> </trade> <!- end of DTDs —>Exercise 3 Creating a New Web Service With JWSDP
You are going to expose an existing Foreign Exchange currency rate conversion functionality as a Web Services call using JWSDP. The following sections show the procedures to define, implement, and deploy a new Web Services call using JWSDP. The procedures can be found in section “Four Steps to Web Services-Enable Your Applications” found previously in this chapter. The sample code in this exercise can be found on the CD-ROM accompanying this book under Chapter 3 labs. They are also reusable for Chapter 8 Web Services in Action: Case Study chapter.
Step 1. | Define Service Description Start with the business service you would like to expose. In this example, you are going to define a Web Services call to get a Foreign Exchange rate quote given the Sell and Buy currency codes. You need to define an interface file that defines the method and the parameters (refer to Figure 3-36). This interface file will be used to generate a service description (WSDL) file. Figure 3-36. FXProviderIF.java Program
| |||||
Step 2. | Implement Web Services Description Language (WSDL) A sample implementation of the business service is listed below in Figure 3-37. The getPrice method simply returns an exchange rate in String format, when given a Sell/Buy currency pair (such as USD to HKD). Please note that the “getPrice” method can be a remote Web Services call or functionality abstracted from any legacy backoffice system. Figure 3-37. FXProviderImpl.java Program
For web.xml, specify the display name of the Web Services and the session time-out parameters (in this case, 60 seconds). Refer to the excerpt in Figure 3-38: Figure 3-38. web.xml Contents
Figure 3-39. config.xml Contents
Figure 3-40. jaxrpc-ri.xml Contents
The utility wscompile (from JWSDP) will generate the stubs using the config.xml that are necessary to build the client proxy. The WSDL file will be generated during the process, and it will be deleted afterward unless the -keep option is specified. The following excerpt in Figure 3-41 depicts how wscompile is used in the build.xml script: Figure 3-41. Use of wscompile in build.xml
D:Devmydemomyws>ant build
Buildfile: build.xml
clean:
[delete] Deleting directory D:Devmydemomywsuild
clean-wars:
[delete] Deleting: D:Devmydemomywsdistmyws-portable.war
[delete] Deleting: D:Devmydemomywsdistmyws.war
prepare:
[echo] Creating the required directories....
[mkdir] Created dir: D:Devmydemomywsuildclientmyws
[mkdir] Created dir: D:Devmydemomywsuildservermyws
[mkdir] Created dir: D:Devmydemomywsuildsharedmyws
[mkdir] Created dir: D:Devmydemomywsuildwsdeploy-generated
[mkdir] Created dir: D:DevmydemomywsuildWEB-INFclassesmyws
compile-server:
[echo] Compiling the server-side source code....
[javac] Compiling 2 source files to D:Devmydemomywsuildshared
setup-web-inf:
[echo] Setting up build/WEB-INF....
[delete] Deleting directory D:DevmydemomywsuildWEB-INF
[copy] Copying 2 files to D:DevmydemomywsuildWEB-INFclassesmyws
[copy] Copying 1 file to D:DevmydemomywsuildWEB-INF
[copy] Copying 1 file to D:DevmydemomywsuildWEB-INF
package:
[echo] Packaging the WAR....
[jar] Building jar: D:Devmydemomywsdistmyws-portable.war
set-ws-scripts:
process-war:
[echo] Running wsdeploy....
[exec] info: created temporary directory: D:Devmydemomywsuildwsdeploy
-generatedjaxrpc-deploy-de5ada
[exec] info: processing endpoint: myws
[exec] Note: sun.tools.javac.Main has been deprecated.
[exec] 1 warning
[exec] info: created output war file: D:Devmydemomywsdistmyws.war
[exec] info: removed temporary directory: D:Devmydemomywsuildwsdeploy
-generatedjaxrpc-deploy-de5ada
build-service:
build:
BUILD SUCCESSFUL
Total time: 16 seconds
Next, you need to deploy the Web Services under the context “/myws.” This enables any remote client to invoke the Web Services via RPC. D:Devmydemomyws>ant deploy
Buildfile: build.xml
deploy:
[deploy] OK - Installed application at context path /myws
[deploy]
BUILD SUCCESSFUL
Total time: 4 seconds
You may want to ensure that the context (in this example, myws) is not created before. Otherwise, you need to either use a new context name, or to undeploy the context (for example, ant undeploy). Upon successful deployment of the Web Services call, you may like to verify the WSDL by entering the URL http://localhost:8080/myws/FXProvider, as in Figure 3-42: Figure 3-42. Verifying Web Services Deployment With JWSDPYou should be able to validate the WSDL by clicking from the WSDL URL (refer to Figure 3-43). Figure 3-43. WSDL Generated From JWSDP | |||||
Step 3. | Publish to Registry This step is required if you want to publish to a Service Registry. In this example, we do not require the Web Services to publish to the UDDI Service Registry. Please refer to Chapter 8, Web Services in Action: Case Study, for an example of publishing to the UDDI Service Registry with JAXR. | |||||
Step 4. | Invoke Web Services SOAP-Lite is used here to illustrate that Web Services can be invoked from a non-Java client. A SOAP-Lite client reads in a Web Services service description (a URI pointing to the WSDL, which is http://localhost:8080/myws/FXProvider?WSDL in this case) and invokes the remote method “getPrice” via RPC. The script is written in Perl and can be executed from a Windows command prompt or a Unix terminal. #!perl -w #!d:perlinperl.exe BEGIN { warn "SOAP-Lite is started... " } # import interface. All methods from loaded service are imported by default use SOAP::Lite service => 'http://localhost:8080/myws/FXProvider?WSDL', ; warn "Invoking a remote Web Service... "; print 'The currency exchange for USD-to-HKD is '; print getPrice('USD', 'HKD'), " "; Execute the SOAP-Lite script (in this example, myFX.pl) as follows: D:Devmydemo>perl myFX.pl
SOAP-Lite is started...
Invoking a remote Web Service...
The currency exchange for USD-to-HKD is 7.78
|
John Hagel III and John Seely Brown . “Your Next IT Strategy.” Harvard Business Review, October 2001. IBM Web Services Overview Team. “Web Services Architecture Overview” IBM, September 2000. http://www-106.ibm.com/developerworks/library/w-ovr/
Lawrence Wilkes . “Web Services—Right Here, Right Now.” IBM, 2002. http://www-3.ibm.com/software/solutions/webservices/pdf/cbdi.pdf
SOAP Builders Interoperability Test Lab. http://www.xmethods.net/ilab/
White Mesa—for SOAP interoperability testing. http://www.whitemesa.net/
109Web Services Technology Overview 109 References Bibliography Some Web Services Resource Web Sites [ch03biblio04div01entry01] http //www webservices org [ch03biblio04div01entry02] http //www theserverside com/home/index jsp Web Services Overview [ch03biblio04div02entry01] John Hagel III and John Seely Brown "Your Next IT Strategy " Harvard Business Review October 2001 IBM Web Services Overview Team "Web Services Ar chitecture Overview" IBM September 2000 http //www 106 ibm com/developerworks/li brary/w ovr/ [ch03biblio04div02entry02] Lawrence Wilkes "Web Services--Right Here Right Now " IBM 2002 http //www 3 ibm com/software/solutions/webservices/pdf/cbdi pdf SOAP Interoperability Organization [ch03biblio04div03entry01] SOAP Builders Interoperability Test Lab http //www xmethods net/ilab/
Business Process Execution Language for Web Services (BPEL4WS). http://www-106.ibm.com/developerworks/webservices/library/ws-bpel/
Web Services Choreography Interface (WSCI). http://wwws.sun.com/software/xml/developers/wsci/wsci-spec-10.pdf
Alur Deepak, John Crupi, and Dan Malks . Core J2EE Patterns. Prentice Hall, 2001.
Judith M. Myerson . “Web Services Architecture.” Tech, 2002. http://www.webservicesarchitect.com/content/articles/webservicesarchitectures.pdf
Sun Professional Services. Dot-com and Beyond: Breakthrough Internet-Based Architectures and Methodologies. Prentice Hall, 2001.
110Web Services Technology Overview [ch03biblio04div03entry02] White Mesa--for SOAP interoperability testing http //www white 110 mesa net/ Web Services Standards [ch03biblio04div04entry01] Business Process Execution Language for Web Services BPEL4WS http //www 106 ibm com/developerworks/webservices/library/ws bpel/ [ch03biblio04div04entry02] Web Services Choreography Interface WSCI http //wwws sun com/ software/xml/developers/wsci/wsci spec 10 pdf Others [ch03biblio04div05entry01] Alur Deepak John Crupi and Dan Malks Core J2EE Patterns Prentice Hall 2001 [ch03biblio04div05entry02] Judith M Myerson "Web Services Architecture " Tech 2002 http // www webservicesarchitect com/content/articles/webservicesarchitectures pdf [ch03biblio04div05entry03] Sun Professional Services Dot com and Beyond Breakthrough Inter net Based Architectures and Methodologies Prentice Hall 2001
3.142.36.231