6.8 Perspectives

6.8.1 Highlights

  • Both EAI and Web Services technology provide similar capabilities of easier integration between systems, abstracting complex systems into simpler business services, good manageability of interfaces and infrastructure, preserving existing IT investments, and accommodating open technology standards evolution.

  • Integrating data from multiple data sources across heterogeneous database vendor environments and database technology can be done using Java Web Services and XML. Several database- related XML initiatives such as XQL and DADX Web Services are still evolving. However, major database vendors have now added SQL-to-XML mapping (for example, XML extender) and XML object store (storing XML as native format in the database) support to their databases.

  • We are seeing a growing trend in which many EAI vendors rebrand their legacy middleware products as Web Services. There are more choices for SOAP-JMS integration and workflow products. Needless to say, ebXML Web Services technology is becoming stronger in this space.

6.8.2 Best Practices and Pitfalls

Best Practices
  • Strong business proposition (and clearly defined requirements) for service integration.

  • Always start with a big picture and prioritized targets.

  • Use Open Standards (such as XML Web Services) wherever possible.

  • Keep the integration requirements and processes simple.

  • Decouple data contents or messages from the underlying transport to ease interoperability and integration.

Pitfalls
  • The integration approach and technology are too complex or too difficult to understand.

  • The integration architecture has a single point of failure.

  • The integration architecture is a proprietary black box.

  • It requires many system changes to accommodate integration, which then affect system stability.

  • It has so many point-to-point interfaces.

6.8.3 Challenge

An international investment bank, which is a key member of FXAll trading portal, is providing a private labeling online Foreign Exchange service for some small securities firms in Asia. The small securities firms do not have presence in Asia. By adapting the white labeling service, these securities firms can provide online FX trading services to their local customers using the international investment bank's infrastructure and delivery channels, but under the label of their own brands. The international investment bank has spent six months integrating with FXAll. The bank's IT management indicates to the securities firms that the white labeling integration service for the next securities firms should be three to five months.

The international investment bank is traditionally a legacy mainframe shop, with limited integration experience with Unix and external customers. Its FX trading platform is an off-the-shelf package implemented on a Unix platform using a proprietary publish-subscribe message-oriented middleware. Assuming most small-size securities firms are not sophisticated in technology and that they run either a Unix-based or a Windows-based application platform, what integration technology (EAI or Web Serv-ices) would you recommend to the international bank?

Hint: Use one of the Broker Patterns.

6.8.4 Paper and Pencil

Background

ebXML messaging is often used as the underlying technology for business process collaboration and reliable business transactions. This is particularly important to Business-to-Business integration. The following exercise will illustrate how to use JAXM to write simple ebXML messaging to place a Foreign Exchange option order.

Objective

To use the ebXML message provider using JAXM to send an XML message.

Exercise

Using the JAXM concept in Chapter 3, Web Services Technology Overview, you are to write a servlet to send an XML message (in fact, this is a Foreign Exchange option message using fpML). ebXML messaging using JAXM is almost identical to SOAP messaging using JAXM, except that ebXML messaging requires ensuring that the support profile is ebXML-based (that is, supportedProfiles[i].equals("ebxml") ). The XML message is listed in Figure 6-32 for reference:

Figure 6-32 Foreign Exchange Option Message in XML
 <?xml version="1.0" encoding = "UTF-8" ?> <!DOCTYPE trade   [     <! 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 > 

The source files ReceivingServlet.java and SendingServlet. java can be found in the CD-ROM accompanying this book under /labs/ch6. They are also listed here for reference (refer to the excerpts in Figures 6-33 through 6-39).

Figure 6-39. ebXML Message Provider Sent Log

graphics/06fig31.jpg

Step 1. Write the SendingServlet.java

The sender client SendingServlet.java (see Figure 6-33) creates a connection to the Message Factory using an ebXML support profile (highlighted as follows ). It uses standard JAXP to construct an ebXML Manifest, a SOAP header, and a body. The SOAP message contains the XML message from Figure 6-32.

Figure 6-33 SendingServlet.java Sends an XML Message in ebXML Using JAXM
 package myRemote.sender; import java.net.*; import java.io.*; import java.util.*; import javax.servlet.http.*; import javax.servlet.*; import javax.xml.messaging.*; import javax.xml.soap.*; import javax.activation.*; import com.sun.xml.messaging.jaxm.ebxml.*; import org.apache.commons.logging.*; public class SendingServlet extends HttpServlet {     private static Log logger = LogFactory.getLog("Samples/myRemote");     private String from ="http://www.wombats.com/remote/sender";     private String to = "http://www.wombats.com/remote/sender";     private String data = "http://127.0.0.1:8080/myRemote/index.html";     private ProviderConnectionFactory pcf;     private ProviderConnection pc;     private MessageFactory mf = null;     private static final String providerURI = "http://java.sun.com/xml/jaxm/provider";     public void init(ServletConfig servletConfig) throws ServletException {         super.init(servletConfig);         try {         pcf = ProviderConnectionFactory.newInstance();         pc = pcf.createConnection();         } catch(Exception e) {             logger.error("Unable to open connection to the provider", e);         }         InputStream in = servletConfig.getServletContext().                    getResourceAsStream("/WEB-INF/address.properties");         if (in != null) {             Properties props = new Properties();             try {                 props.load(in);           String from = props.getProperty("from");                 String to = props.getProperty("to");                 String data = props.getProperty("data");           if (from != null)               this.from = from;                 if (to != null)                     this.to = to;                 if (data != null)                     this.data = data;             } catch (IOException ex) {                 // Ignore             }         }     }     public void doGet(HttpServletRequest req, HttpServletResponse resp)         throws ServletException     {         try {             // Create a message factory.         if (mf == null) {             ProviderMetaData metaData = pc.getMetaData();             String[] supportedProfiles = metaData.getSupportedProfiles();             String profile = null;             for(int i=0; i < supportedProfiles.length; i++) {  if(supportedProfiles[i].equals("ebxml")) {   profile = supportedProfiles[i];   break;  }             }                 mf = pc.createMessageFactory(profile);         }             // Create a message from the message factory.  EbXMLMessageImpl ebxmlMsg = (EbXMLMessageImpl)mf.createMessage();  ebxmlMsg.setSender(new Party(from));         ebxmlMsg.setReceiver(new Party(to));         Service service = new Service("FXOrderProcessing");         ebxmlMsg.setRefToMessageId("20001209-133003-28572@example.com");         ebxmlMsg.setCPAId("http://www.nextfrontiers.com/cpas/ourcpawithyou.xml");         ebxmlMsg.setConversationId("20001209-133003-28572");         ebxmlMsg.setService(service);         ebxmlMsg.setAction("NewFXSpotOrder");  Manifest manifest = new Manifest("manifest", "1.0");  Reference ref = new Reference("pay01", "cid:pay01",                 "http://regrep.org/gci/fxOrder");         Schema schema = new Schema("http://regrep.org/gci/fpML.xsd",                   "1.0");         ref.setSchema(schema);         Description desc = new Description("en-us");         desc.setText("FX Spot Rate Order for Next Frontiers Ltd.");         ref.setDescription(desc);         manifest.addReference(ref);         ebxmlMsg.setManifest(manifest);         SOAPPart soapPart = ebxmlMsg.getSOAPPart();         SOAPEnvelope envelope = soapPart.getEnvelope();         Name name = envelope.createName("trade" , "fx",            "http://www.nextfrontiers.com/fxOption/");         SOAPBody body = envelope.getBody();         SOAPBodyElement trade = body.addBodyElement(name);         SOAPHeader header = envelope.getHeader();         SOAPHeaderElement headerElement = header.addHeaderElement(name);         // create tradeHeader         Name childName = envelope.createName("tradeHeader");         SOAPElement tradeHeader = trade.addChildElement(childName);         childName = envelope.createName("partyTradeIdentifier");         SOAPElement partyTradeIdentifier = tradeHeader.addChildElement(childName);         childName = envelope.createName("partyReference");         SOAPElement partyReference = partyTradeIdentifier.addChildElement(childName);         childName = envelope.createName("href");         partyReference.addAttribute(childName, "#XYZ");         Name childName2 = envelope.createName("partyTradeIdentifier");         SOAPElement partyTradeIdentifier2 = tradeHeader.addChildElement(childName2);         childName2 = envelope.createName("partyReference");         SOAPElement partyReference2 = partyTradeIdentifier2.addChildElement(childName2);         childName2 = envelope.createName("href");         partyReference2.addAttribute(childName2, "#ABC");         // create fxSimpleOption         Name childName3 = envelope.createName("fxSimpleOption");         SOAPElement fxSimpleOption = trade.addChildElement(childName3);         childName3 = envelope.createName("productType");         SOAPElement productType = fxSimpleOption.addChildElement(childName3);         productType.addTextNode("Nondeliverable options");         childName3 = envelope.createName("buyerPartyReference");         SOAPElement buyerPartyReference = fxSimpleOption.addChildElement(childName3);         childName3 = envelope.createName("href");         buyerPartyReference.addAttribute(childName3, "#XYZ");         childName3 = envelope.createName("sellerPartyReference");         SOAPElement sellerPartyReference = fxSimpleOption.addChildElement(childName3);         childName3 = envelope.createName("href");         sellerPartyReference.addAttribute(childName3, "#ABC");         childName3 = envelope.createName("expiryDateTime");         SOAPElement expiryDateTime = fxSimpleOption.addChildElement(childName3);         childName3 = envelope.createName("expiryDate");         SOAPElement expiryDate = expiryDateTime.addChildElement(childName3);         expiryDate.addTextNode("2002-04-09");         childName3 = envelope.createName("hourMinuteTime");         SOAPElement hourMinuteTime = expiryDateTime.addChildElement(childName3);         hourMinuteTime.addTextNode("1000");         childName3 = envelope.createName("businessCenter");         SOAPElement businessCenter = expiryDateTime.addChildElement(childName3);         businessCenter.addTextNode("USNY");         childName3 = envelope.createName("exerciseStyle");         SOAPElement exerciseStyle = fxSimpleOption.addChildElement(childName3);         exerciseStyle.addTextNode("European");         // create party information         Name childName4 = envelope.createName("party");         SOAPElement party = trade.addChildElement(childName4);         childName4 = envelope.createName("id");         party.addAttribute(childName4, "XYZ");         childName4 = envelope.createName("partyId");         SOAPElement partyId = party.addChildElement(childName4);         partyId.addTextNode("CHASUS33");         childName4 = envelope.createName("partyName");         SOAPElement partyName = party.addChildElement(childName4);         partyName.addTextNode("XYZ BUYER BANK");         Name childName5 = envelope.createName("party");         SOAPElement party2 = trade.addChildElement(childName5);         childName5 = envelope.createName("id");         party2.addAttribute(childName5, "ABCN");         childName5 = envelope.createName("partyId");         SOAPElement partyId2 = party2.addChildElement(childName5);         partyId2.addTextNode("ABCANL2A");         childName5 = envelope.createName("partyName");         SOAPElement partyName2 = party2.addChildElement(childName5);         partyName2.addTextNode("ABC Seller Bank");         URL url = new URL(data);         AttachmentPart ap =            ebxmlMsg.createAttachmentPart(new DataHandler(url));         ap.setContentType("text/html");         // Add the attachment part to the message.         // You can attach an EDI (UN/EDIFACT or ANSI X12) message, image or digital signature         ebxmlMsg.addAttachmentPart(ap);         System.err.println("Sending FX Spot Order in fpML to : "+ebxmlMsg.getTo());         System.err.println("Sent message is logged in \"sent.msg\"");         FileOutputStream sentFile = new FileOutputStream("sent.msg");         ebxmlMsg.writeTo(sentFile);         sentFile.close();         pc.send(ebxmlMsg);             String retval =           "<html> <H4> FX Spot Rate Order delivered to Broker Firm.</H4></html>";         OutputStream os = resp.getOutputStream();         os.write(retval.getBytes());         os.flush();         os.close();         } catch(Throwable e) {         e.printStackTrace();             logger.error("Error in constructing or sending message "                          +e.getMessage());         }     } } 

The recipient client ReceivingServlet.java creates a connection to the Message Factory class using an ebXML implementation. The underlying messaging is still using SOAP messaging via JAXM. The source code is shown in Figure 6-34:

Figure 6-34 ReceivingServlet.java Receives an XML Message Using JAXM
 package myRemote.receiver; import javax.xml.messaging.*; import javax.xml.soap.*; import javax.servlet.*; import javax.servlet.http.*; import javax.xml.transform.*; import java.io.*; import java.util.Enumeration; import org.apache.commons.logging.*; import com.sun.xml.messaging.jaxm.ebxml.*; public class ReceivingServlet extends JAXMServlet implements OnewayListener {     private static Log logger = LogFactory.getLog("Samples/myRemote");     private ProviderConnectionFactory pcf;     private ProviderConnection pc;     private static final String providerURI = "http://java.sun.com/xml/jaxm/provider";     //private MessageFactory messageFactory;     public void init(ServletConfig servletConfig) throws ServletException {         super.init(servletConfig);     try {  pcf = ProviderConnectionFactory.newInstance();   pc = pcf.createConnection();   setMessageFactory(new EbXMLMessageFactoryImpl());  }catch (Exception e) {         e.printStackTrace();         throw new ServletException("Couldn't initialize Receiving servlet " + e.getMessage());     }    }     public void onMessage(SOAPMessage message) {         System.out.println("On message called in receiving servlet");         try {             System.out.println("Here's the message: ");         message.saveChanges();             message.writeTo(System.out);         } catch(Exception e) {             logger.error("Error in processing or replying to a message", e);         }     } } 
Step 2. Write the build.xml File

An ANT build script (build.xml) is created to compile the Java source code (servlets) and deploy the servlets in war files under the Web Container. It reads in a property file jaxm.properties to set the variables and paths. The build.xml can be found under /opt/myRemote/build.xml.

Step 3. Compile Source Codes

To compile the source code (project name inside the build file is called myRemote), you may execute the following commands in a command prompt (Windows platform) or Unix terminal (Unix platform). Figure 6-35 shows the script and the result on a Windows platform.

Figure 6-35 Compile myRemote Source Codes
 D:\opt\myRemote>  ant  Buildfile: build.xml set.available: check.jaxm: check.saaj: check.appname: check.servlet: checks: build.dir.webapps: build.dir.local: init:      [echo]  ----  Building myRemote to /opt/temp prepare.build:     [mkdir] Created dir: D:\opt\temp\myRemote     [mkdir] Created dir: D:\opt\temp\myRemote\WEB-INF     [mkdir] Created dir: D:\opt\temp\myRemote\WEB-INF\src     [mkdir] Created dir: D:\opt\temp\myRemote\WEB-INF\classes      [copy] Copying 4 files to D:\opt\temp\myRemote prepare: compile:     [javac] Compiling 2 source files to \opt\temp\myRemote\WEB-INF\classes      [copy] Copying 2 files to D:\opt\temp\myRemote\WEB-INF      [copy] Copying 1 file to D:\opt\temp\myRemote\WEB-INF\classes main: BUILD SUCCESSFUL Total time: 7 seconds 
Step 4. Deploy as war Files

To deploy the compiled servlets (project name inside the build file is called myRemote), you may execute the following commands in a command prompt (Windows platform) or Unix terminal (Unix platform). Figure 6-36 shows the script and the result on a Windows platform.

The war file created is placed under D:\opt\temp\war\myRemote.war . This needs to be copied to the webapps directory of your Web Container (for example, D:\Dev\WSDP\webapps).

Figure 6-36 Deploy myRemote Servlets
 D:\opt\myRemote>  ant war  Buildfile: build.xml set.available: check.jaxm: check.saaj: check.appname: check.servlet: checks: build.dir.webapps: build.dir.local: init:      [echo]  ----  Building myRemote to /opt/temp prepare.build: prepare: compile: main: war:       [jar] Building jar: D:\opt\temp\war\myRemote.war BUILD SUCCESSFUL Total time: 2 seconds 
Step 5. Test Run

The Tomcat engine needs to be started. On a Windows platform, start the Tomcat server by clicking Start Java Web Services Developer Pack 1_0_01 Start Tomcat on the desktop. On a Unix platform, start by issuing the command /startup.sh from your Java Web Services Developer Pack installation location (for example, /opt/jwsdp/bin ).

From a Web browser, issue the URL http://localhost:8080/myRemote/index.html . You should see the following screens in Figure 6-37 and Figure 6-38.

Figure 6-37. User Interface to Send XML Message Using ebXML With JAXM

graphics/06fig29.gif

Figure 6-38. Confirmation of Receipt of the XML Message Using ebXML With JAXM

graphics/06fig30.gif

Step 6. Verify Sent Log

The ebXML message provider has sent and received logs. If the XML message is not yet received due to potential system unavailability of the recipient, the ebXML message provider will resend the message when the recipient resumes operations. Figure 6-39 shows the sent log of the ebXML message provider. The receive log is similar.

6.8.5 References

Web Services and EAI

Mikhail Genkin and Jin Li. " Web Services and J2EE Connectors for B2B Integration. " http://www-106.ibm.com/developerworks/library/j-conn/index.html

Matjaz B. Juric, Jeelani Basha, Rick Leander, and Ramesh Nagappan. Professional J2EE EAI . Birmingham, UK: Wrox, 2001.

Matjaz B. Juric and Marjan Hericko. "J2EE, EAI and Web Services: New Challenges for your Information Systems." Web Services Journal , May 2002.

J. P. Morgenthal. "Web Services for Enterprise Application Integration: What Solutions are Offered for the Enterprise Today." Web Services Journal , May 2002.

Carol Murphy. "Will Web Services Mean the End for EAI?" Web Services Journal , May 2002.

Gunjan Samtani and Dimple Sadhwani. "J2EE-based Application Servers, Web Services and EAI." Web Services Journal , May 2002.

Andre Yee and Atul Apte. Integrating Your e-Business Enterprise . Indianapolis, IN: SAMS, 2001.

Emerging Technologies
Java Connector Architecture

Dale Green and Beth Stearns. "J2EE Connector Architecture." J2EE Tutorial .

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Connector.html

J2EE Connector Architecture version 1.5 specification.

http://java.sun.com/j2ee/download.html#connectorspec

Phil Wakelin, Martin Keen, Richard Johnson, and Daniel Cerecedo Diaz. Java Connectors for CICS: Featuring the J2EE Connector Architecture . San Jose, CA: IBM Redbooks, March 2002.

http://publib-b.boulder.ibm.com/Redbooks.nsf/RedbookAbstracts/sg246401.html

ebXML-based Web Services

ebXML technical specification. http://www.ebxml.org/ specs /index.htm#technical_specifications

A list of ebXML products and implementation. http://www.ebxml.org/ implementations /index.htm

Paul Milo, Dan Malks, and John MacDonald. "Architecting and Delivering ebXML-based Collaborative Web Services." SunNetwork Conference, 2003.

SOAP-JMS Integration

Kal Ahmed et al. Professional Java XML . Birmingham, UK: Wrox, 2001.

Database and XML Web Services

Joan Hagarty. "XML and WebSphere Studio Application Developer ”Part 3: SQL and XML Together." IBM WebSphere Developer Technical Journal , February 2002. http://www7b.software.ibm.com/wsdd/techjournal/0202_haggarty/haggarty.html

Brian C. Reed. "Data ”a Key Part of Web Services." Web Services Journal , May 2002.



J2EE Platform Web Services
J2EE Platform Web Services
ISBN: 0131014021
EAN: 2147483647
Year: 2002
Pages: 127
Authors: Ray Lai

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net