KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > docoriented > client > attachmentposervice > AttachmentPOServiceBD


1 /* Copyright 2005 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at:
2  http://developer.sun.com/berkeley_license.html
3  $Id: AttachmentPOServiceBD.java,v 1.12 2005/08/12 19:43:04 smitha Exp $ */

4
5 package com.sun.j2ee.blueprints.docoriented.client.attachmentposervice;
6
7 import java.rmi.*;
8 import java.io.*;
9 import java.net.*;
10
11 import javax.xml.transform.*;
12 import javax.xml.transform.stream.*;
13
14 import com.sun.j2ee.blueprints.docoriented.client.*;
15
16 /**
17  * Implements the Business Delegate pattern for Web services.
18  * Handles making the exchange of messages with the Web service endpoint
19  */

20 public class AttachmentPOServiceBD {
21     
22     private ServiceLocator serviceLocator;
23     
24     public AttachmentPOServiceBD(){
25         serviceLocator = new ServiceLocator();
26     }
27     
28     public String JavaDoc submitPO(PurchaseOrder po) throws RequestHandlerException {
29         try {
30             AttachmentPurchaseOrderServiceSEI port = (AttachmentPurchaseOrderServiceSEI)
31             serviceLocator.getServicePort(JNDINames.ATTACHMENT_SERVICE_REF,
32                     AttachmentPurchaseOrderServiceSEI.class);
33             String JavaDoc xmlDoc = po.toXMLString();
34             Source src = new StreamSource(new StringReader(xmlDoc));
35             URI resp= port.submitPO(src);
36             return resp.getSchemeSpecificPart();
37         } catch(InvalidPOException ipe){
38             ipe.printStackTrace(System.err);
39             throw new RequestHandlerException("Request Handler Exception: Service Endpoint Application-Defined Exception "+ipe.getMessage(), ipe);
40         } catch(RemoteException re){
41             re.printStackTrace(System.err);
42             throw new RuntimeException JavaDoc("The web service you are trying to access is not available. A possible reason could be that the service has not been deployed yet. "+ re.getMessage(), re);
43         }
44     }
45 }
46
47
Popular Tags