October 21, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

A Dynamic e-Business Application Using Web Services

  • May 22, 2003
  • By Simon John
  • Send Email »
  • More Articles »

Various functional controller objects use data access objects and JDBC for database operation. The application uses the Pointbase database bundled with the application server for data persistence.

The manufacturer discovers and interacts with parts vendors to procure computer accessories. The manufacturer application searches a UDDI business registry (UBR) for organizations matching the search classification using the JAXR API. The ServiceProviderLocator object actually performs the search for vendor organizations based on the classification and search criteria. The ProviderClent object then performs dynamic binding with the received endpoints and invokes services on the part vendors using appropriate call agents depending on the binding type. It may use Dynamic Invocation Interface, JAX-RPC (DII), or use JAXM messages. Below is the code snippet showing the ProviderClient getting quotes from all vendors.

try {
  Enumeration e= orgTable.elements();

  // iterate thrugh the cached service providers
  while(e.hasMoreElements()) {

    ServiceProviderInfo spi = (ServiceProviderInfo)e.nextElement();

    // get the endpoint for the specified service
    String[] endpoint = spi.getService(service).
                            getServiceEndpoint();
    if(endpoint == null) throw new Exception(
                         "No Organisation endpoints found !");

    // Assuming 'JAXRPC' and 'SOAPNET' are the only two types of
    // service bindings.
    // Using 'JAXRPC' as default
    // create a call agent suitable for the endpoint
    ICallAgent ca = CallAgentFactory.newCallAgent(endpoint);

    // invoke the Web service method on the endpoint
    String quote = ca.getQuote(type, size);
    if(quote != null) allQuotes.put(spi.getProviderName(), quote);
  }
  if(allQuotes.isEmpty()) throw new Exception(
               "No Vendors with matching specifications !");
} catch (Throwable t) {
  System.out.println("Exception : In Provider-getAllQuotes>> " );
  throw new Exception(t.getMessage());
}
// return the quote collection from all vendors
return allQuotes;

The application uses the reference UDDI implementation provided as a part of the JWSDK pack for the UBR. Figure 9 illustrates the manufacturer application and its interaction with part vendors.



Click here for a larger image.

Figure 9: The Vendor-Manufacturer Interactions

The parts vendor services are published to the UDDI test registry using the JAXR publishing APIs. They host Web services with the same service names and signatures to return product details and price quotes. One vendor is implemented as a WAR application deployed on the Tomcat servlet engine. The second vendor, also a Java application on the Apache/Axis platform, uses a Java:RPC provider to communicate with the manufacturer. Both of them use JAXP APIs to process data from an XML document that holds parts information. The third vendor is implemented using C# on the Microsoft .NET platform, which communicates with the manufacturer using synchronous JAXM. Below are the messages exchanged between the manufacturer and a vendor implemented on .NET while invoking the getQuote() method, captured using the 'tcpmon' utility from Apache/Axis.

Listen Port: 9003
Target Host: localhost
Target Port: 80
==== Request ====
POST /SymphonyQS/QuoteService/QuoteService.asmx HTTP/1.1
SOAPAction: http://tempuri.org/getQuote
Content-Type: text/xml; charset="utf-8"
Content-Length: 266
User-Agent: Java1.4.0_02
Host: localhost
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

<?xml version="1.0" encoding="UTF-8"?>
 <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap-env:Header/>
  <soap-env:Body>
   <getQuote xmlns="http://tempuri.org/">
    <size>40</size>
    <type>IDE</type>
   </getQuote>
  </soap-env:Body>
 </soap-env:Envelope>

==== Response ====
HTTP/1.1 100 Continue

Server: Microsoft-IIS/5.0
Date: Tue, 18 Mar 2003 20:45:01 GMT
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 18 Mar 2003 20:45:09 GMT
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 350

<?xml version="1.0" encoding="utf-8"?>
 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
   <getQuoteResponse xmlns="http://tempuri.org/">
    <getQuoteResult>225.00</getQuoteResult>
   </getQuoteResponse>
  </soap:Body>
 </soap:Envelope>

Working with the Application

  • Download the application and other required software
  • Follow the instructions in the readme.txt file of eTrade.zip to install and deploy the application. (Important: Remember to place the struts.jar file in the /src/lib folder as mentioned in readme.txt; otherwise, the project will fail to compile.)
  • Make sure the Sun-ONE App Server is started and the Manufacturer application is up and running. You should see the message "INFO: CORE5053: Application on Ready complete." on the application server console on successful startup.
  • Test to see whether the manufacturer Web service has been installed by pointing the browser to http://localhost:81/manufacturer/jaxrpc/TradingWebServicesIF. If successfully installed, you should see a message to that effect.
  • Modify the customer.properties file if required, in particular the WSDL_URL and JMS_PROVIDER_URL properties. Execute the run-client.bat file to start the Customer Client (swing based application).

    Log in using JOHNS and any password.

    On successful login, you should see the application come up with the customer information on the first of the four tab pages. The second tab page, View Products, lists product details of the one chosen from the list box. The third tab page, Create Order, is for customers to prepare and place orders. Use the buttons provided at the bottom. When an order is placed, it will be removed from this page and available as an ordered item in the last tab page Order Details. This last page shows previous orders, their status and details. The status of orders on this page is updated automatically when the administrator approves it from the manufacturer application.

  • Test to see whether the vendor Web service has been installed by pointing the browser to:

  • To run the manufacturer application point the browser to http://localhost:81/manufacturer/index.jsp . Use IE 5.0 or higher as other browsers may not render some pages properly. Select one of the options from the menu. The customer and product management options allow you to create, update, or delete items in the database. The view/approve order option allows you to selectively retrieve orders, view, and approve pending orders. On approval of an order, the invoice document is sent to the customer and order status updated both at the customer and the manufacturer application. Quote for parts is an option to retrieve all vendors registered in the global registry for a particular service. Once the parts vendors are located you can get the part information by clicking on any one of them. You can also locate the vendor that quotes the least for a particular part item. For example, enter 'IDE' for type and '40' for size and select the 'Get Best Quote' option to select the best quote vendor for an IDE HDD of size 40 GB. You can delete a vendor from the UDDI registry entry using the JAXR Registry browser and re-run the 'Get Best Quote' and expect a different result.
  • You can use the tcpmon utility that comes with Apache-Axis to view the SOAP messages that go back and forth between the Manufacturer and customer as well as those between manufacturer and the vendors.
  • The Web application response may be slow the first time you access a jsp resource as they are first converted to servlets. It should be much better on subsequent invocations of the same resource.




Page 5 of 6



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel