1 4 5 package com.sun.j2ee.blueprints.swingclient; 6 import java.rmi.RemoteException ; 7 import java.net.URL ; 8 import javax.xml.rpc.ServiceException ; 9 import javax.xml.rpc.Call ; 10 import javax.xml.rpc.Stub ; 11 import javax.xml.rpc.ServiceFactory ; 12 import javax.xml.rpc.Service ; 13 import javax.xml.rpc.ParameterMode ; 14 import javax.xml.namespace.QName ; 15 16 22 public class POServiceBD { 23 24 25 private static final String NS_BODY = "urn:StringPurchaseOrderService"; 26 27 public POServiceBD(String serviceUrl) { 28 this.serviceUrl = serviceUrl; 29 } 30 31 32 public String submitPOUsingStubs(String xmlDocStr) throws InvalidPOException { 33 try { 34 com.sun.j2ee.blueprints.stringposervice.StringPurchaseOrderService_Impl svcimpl = new com.sun.j2ee.blueprints.stringposervice.StringPurchaseOrderService_Impl(); 35 com.sun.j2ee.blueprints.stringposervice.StringPurchaseOrderServiceSEI poservice = svcimpl.getStringPurchaseOrderServiceSEIPort(); 36 ((Stub )poservice)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, serviceUrl); 37 return poservice.submitPO(xmlDocStr); 38 } catch (com.sun.j2ee.blueprints.stringposervice.InvalidPOException e) { 39 throw new InvalidPOException(e); 40 } catch (RemoteException e) { 41 throw new RuntimeException (e); 42 } 43 } 44 45 46 public String submitPOUsingDynamicProxy(String xmlDocStr) throws InvalidPOException { 47 try { 48 ServiceFactory sf = ServiceFactory.newInstance(); 49 URL wsdlURL = new URL (serviceUrl + "?WSDL"); 50 QName serviceQname = new QName (NS_BODY, "StringPurchaseOrderService"); 51 Service s = sf.createService(wsdlURL, serviceQname); 52 QName portQname = new QName (NS_BODY, "StringPurchaseOrderServiceSEIPort"); 53 com.sun.j2ee.blueprints.stringposervice_wrapped.StringPurchaseOrderServiceSEI port = (com.sun.j2ee.blueprints.stringposervice_wrapped.StringPurchaseOrderServiceSEI) 54 s.getPort(portQname, com.sun.j2ee.blueprints.stringposervice_wrapped.StringPurchaseOrderServiceSEI.class); 55 com.sun.j2ee.blueprints.stringposervice_wrapped.SubmitPO param = new com.sun.j2ee.blueprints.stringposervice_wrapped.SubmitPO(xmlDocStr); 56 com.sun.j2ee.blueprints.stringposervice_wrapped.SubmitPOResponse response = port.submitPO(param); 57 return response.getResult(); 58 } catch (com.sun.j2ee.blueprints.stringposervice_wrapped.InvalidPOException e) { 59 throw new InvalidPOException(e); 60 } catch (ServiceException se) { 61 throw new InvalidPOException(se); 62 } catch (java.net.MalformedURLException mfue) { 63 throw new RuntimeException (mfue); 64 } catch (RemoteException e) { 65 throw new RuntimeException (e); 66 } 67 } 68 69 70 public String submitPOUsingDII(String xmlDocStr) throws InvalidPOException { 71 try { 72 ServiceFactory sf = ServiceFactory.newInstance(); 73 URL wsdlURL = new URL (serviceUrl + "?WSDL"); 74 QName serviceQname = new QName (NS_BODY, "StringPurchaseOrderService"); 75 Service s = sf.createService(wsdlURL, serviceQname); 76 QName portQname = new QName (NS_BODY, "StringPurchaseOrderServiceSEIPort"); 77 78 Call call = s.createCall(portQname); 79 call.setTargetEndpointAddress(serviceUrl); 80 call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean (true)); 81 call.setProperty(Call.SOAPACTION_URI_PROPERTY,""); 82 83 String ENCODING_STYLE_PROPERTY = "javax.xml.rpc.encodingstyle.namespace.uri"; 87 String URI_ENCODING = ""; 88 call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING); 89 call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document"); 90 91 95 QName requestQname = new QName (NS_BODY, "submitPO"); 98 QName responseQname = new QName (NS_BODY, "submitPOResponse"); 99 100 call.setReturnType(responseQname, com.sun.j2ee.blueprints.stringposervice_wrapped.SubmitPOResponse.class); 103 104 call.addParameter("parameters", requestQname, com.sun.j2ee.blueprints.stringposervice_wrapped.SubmitPO.class, ParameterMode.IN); 108 com.sun.j2ee.blueprints.stringposervice_wrapped.SubmitPO param = new com.sun.j2ee.blueprints.stringposervice_wrapped.SubmitPO(xmlDocStr); 109 Object [] params = {param}; 110 111 com.sun.j2ee.blueprints.stringposervice_wrapped.SubmitPOResponse response = (com.sun.j2ee.blueprints.stringposervice_wrapped.SubmitPOResponse) call.invoke(params); 113 114 return response.getResult(); 115 } catch (ServiceException e) { 116 throw new InvalidPOException(e); 117 } catch (java.net.MalformedURLException mfue) { 118 throw new RuntimeException (mfue); 119 } catch (RemoteException e) { 120 throw new RuntimeException (e); 121 } 122 } 123 124 private String serviceUrl; 125 } 126 | Popular Tags |