KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > myeis > customer > J2C_MyEIS_CustomerInfoProxy


1 package com.myeis.customer;
2 import org.apache.wsif.*;
3 import org.apache.wsif.base.*;
4
5 import com.myeis.services.Customer;
6
7 import javax.xml.namespace.QName JavaDoc;
8 /**
9  * J2C_MyEIS_CustomerInfoProxy
10  * Generated code. Only edit user code sections.
11  * @generated
12  */

13 public class J2C_MyEIS_CustomerInfoProxy {
14     /**
15      * @generated
16      */

17     private static final int INPUT_ONLY = 0;
18     /**
19      * @generated
20      */

21     private static final int REQUEST_RESPONSE = 1;
22     /**
23      * @generated
24      */

25     private WSIFPort fieldPort;
26     /**
27      * @generated
28      */

29     private WSIFService fieldService;
30     /**
31      * @generated
32      */

33     private static WSIFService fieldStaticService = null;
34     /**
35      * getPort
36      * @generated
37      */

38     public WSIFPort getPort() {
39         return fieldPort;
40     }
41     /**
42      * setPort
43      * @generated
44      */

45     public void setPort(WSIFPort newPort) {
46         fieldPort = newPort;
47     }
48     /**
49      * getService
50      * @generated
51      */

52     public WSIFService getService() {
53         return fieldService;
54     }
55     /**
56      * setService
57      * @generated
58      */

59     public void setService(WSIFService newService) {
60         fieldService = newService;
61     }
62     /**
63      * getCustomer
64      * @generated
65      */

66     public com.myeis.services.Customer getCustomer(java.lang.String JavaDoc argNumber) throws org.apache.wsif.WSIFException {
67
68         try {
69
70             // user code begin {pre_execution}
71
// user code end
72

73             WSIFDefaultMessage inputMessage = new WSIFDefaultMessage();
74             inputMessage.setObjectPart("number", argNumber);
75
76             WSIFMessage outputMessage = execute("getCustomer", "getCustomerRequest", "getCustomerResponse", inputMessage, REQUEST_RESPONSE);
77
78             // user code begin {post_execution}
79
// user code end
80

81             return (com.myeis.services.Customer) outputMessage.getObjectPart("result");
82
83         }
84         catch (Exception JavaDoc e) {
85             // user code begin {exception_handling}
86
// user code end
87
if (e instanceof org.apache.wsif.WSIFException)
88                 throw (org.apache.wsif.WSIFException) e;
89             throw new org.apache.wsif.WSIFException(e.getMessage(), e);
90         }
91     }
92     /**
93      * constructor
94      * @generated
95      */

96     public J2C_MyEIS_CustomerInfoProxy() throws WSIFException {
97
98         // user code begin {custom_initialization}
99
// user code end
100

101         if (this.fieldStaticService == null) {
102
103             this.fieldStaticService =
104                 WSIFServiceFactory.newInstance().getService("com/myeis/customer/CustomerInfoMYEISService.wsdl", this.getClass().getClassLoader(), "http://customer.myeis.com/", "CustomerInfoMYEISService", "http://customer.myeis.com/", "CustomerInfo");
105
106             if (this.fieldStaticService == null)
107                 return;
108
109             this.fieldStaticService.mapType(new QName JavaDoc("http://services.myeis.com/", "Customer"), com.myeis.services.Customer.class);
110
111             // user code begin {port_factory_setup}
112
// user code end
113
}
114     }
115     /**
116      * main method (for proxy unit testing)
117      * @generated
118      */

119     public static void main(String JavaDoc[] args) {
120
121         try {
122
123             J2C_MyEIS_CustomerInfoProxy aProxy = new J2C_MyEIS_CustomerInfoProxy();
124
125             // user code begin {proxy_method_calls}
126
String JavaDoc custNum = "33333";
127             Customer customer = aProxy.getCustomer(custNum);
128             System.out.println("Customer number: " + custNum);
129             System.out.println("Customer name: " + customer.getFirstName() + " " + customer.getLastName());
130             
131             // user code end
132

133         }
134         catch (Exception JavaDoc e) {
135
136             // user code begin {exception_handling}
137
e.printStackTrace();
138             // user code end
139
}
140     }
141     /**
142      * execute (base message-level execution)
143      * @generated
144      */

145     public WSIFMessage execute(String JavaDoc operationName, String JavaDoc inputName, String JavaDoc outputName, WSIFMessage aMessage, int operationType) throws WSIFException, Exception JavaDoc {
146
147         WSIFPort port;
148         if (this.fieldPort == null) {
149             if (this.fieldService == null)
150                 this.fieldService = fieldStaticService;
151             if (this.fieldService == null)
152                 throw new WSIFException("Failed to resolve WSIFService.");
153             port = this.fieldService.getPort("CustomerInfoMyEISPort");
154         }
155         else {
156             port = this.fieldPort;
157         }
158
159         WSIFOperation operation = port.createOperation(operationName, inputName, outputName);
160
161         WSIFMessage inputMessage = operation.createInputMessage();
162
163         String JavaDoc partName;
164         java.util.Iterator JavaDoc iterator = aMessage.getPartNames();
165         while (iterator.hasNext()) {
166             partName = (String JavaDoc) iterator.next();
167             inputMessage.setObjectPart(partName, aMessage.getObjectPart(partName));
168         }
169
170         WSIFMessage outputMessage = operation.createOutputMessage();
171         WSIFMessage faultMessage = operation.createFaultMessage();
172         boolean success = true;
173         if (operationType == INPUT_ONLY)
174             operation.executeInputOnlyOperation(inputMessage);
175         else if (operationType == REQUEST_RESPONSE)
176             success = operation.executeRequestResponseOperation(inputMessage, outputMessage, faultMessage);
177
178         if (this.fieldPort == null)
179             port.close();
180
181         if (!success) {
182             java.util.Iterator JavaDoc i = faultMessage.getParts();
183             if (i.hasNext()) {
184                 Object JavaDoc part = i.next();
185                 if (part instanceof Exception JavaDoc)
186                     throw (Exception JavaDoc) part;
187                 else
188                     throw new WSIFException(String.valueOf(part));
189             }
190         }
191
192         return outputMessage;
193     }
194 }
195
Popular Tags