Home > Articles > Web Services > SOA

  • Print
  • + Share This
Like this article? We recommend

Web Service Proxy

Now let's work the other way around. We'll add the code to transform a CWE pickup request to a Euro-Ship request, as shown in Listing 3.

Workshop doesn't have the concept of a web service control inside an EJB. But a workaround exists to handle this inconvenience. A web service proxy object can be generated, which will make development almost as easy as using a control. This object will automatically connect to the Euro-Ship web service. How do you generate this proxy object? Open the Euro-Ship web service and execute it (Debug, Run). When the web service test page shows up, click the Overview tab. In the middle of the tab is an area where you can generate and download the proxy (see Figure 6).

Figure 6Figure 6 Generating the web service proxy.

Enter the package name cwe (see item 1 in Figure 6) and download the proxy library (item 2) to the application's libraries. This is in the folder GlobX/APP-INF/lib. Also download the web service support library (item 3) to that same location.

We're ready to invoke the proxy. Locate the //*** marker in the EJB code and insert the bold code from Listing 3.

Listing 3 Bridging the CWE and Euro-Ship Systems

if( (destinationAddress!=null) && destinationAddress.indexOf("USA") == -1 ) {
  //If the destination address is in Europe, forward to Euro-Ship here...

  GregorianCalendar cweCal = new GregorianCalendar();

  org.openuri.http://www.EuroShipReturn esReturn;
  try {
    EuroShipWS_Impl proxyFactory = new EuroShipWS_Impl();
    EuroShipWSSoap proxy = proxyFactory.getEuroShipWSSoap();
    esReturn = proxy.pickUp(
      cal, //Note: Workshop converted our Date to a Calendar
  } catch (Exception e) {
    System.out.println("Error processing Euro-Ship destination transfer");
    return null;

  result.setDescription("European shipment number: " + esReturn.getShipmentNumber());

  result.setSubtotal(result.getSubtotal() + esReturn.getSubtotal());
  result.setTax(result.getTax() + esReturn.getTax());

There are probably other ways to do this XML adaptation step. I'm sure some reader of this article will come up with an ingenious XML schema, XML mapping, or XQuery to do it automatically. If you know how, please tell me, as I'm not an expert in that area. I may revisit this point in a later article.

  • + Share This
  • 🔖 Save To Your Account