001: package com.myeis.customer;
002:
003: import org.apache.wsif.*;
004: import org.apache.wsif.base.*;
005:
006: import com.myeis.services.Customer;
007:
008: import javax.xml.namespace.QName;
009:
010: /**
011: * J2C_MyEIS_CustomerInfoProxy
012: * Generated code. Only edit user code sections.
013: * @generated
014: */
015: public class J2C_MyEIS_CustomerInfoProxy {
016: /**
017: * @generated
018: */
019: private static final int INPUT_ONLY = 0;
020: /**
021: * @generated
022: */
023: private static final int REQUEST_RESPONSE = 1;
024: /**
025: * @generated
026: */
027: private WSIFPort fieldPort;
028: /**
029: * @generated
030: */
031: private WSIFService fieldService;
032: /**
033: * @generated
034: */
035: private static WSIFService fieldStaticService = null;
036:
037: /**
038: * getPort
039: * @generated
040: */
041: public WSIFPort getPort() {
042: return fieldPort;
043: }
044:
045: /**
046: * setPort
047: * @generated
048: */
049: public void setPort(WSIFPort newPort) {
050: fieldPort = newPort;
051: }
052:
053: /**
054: * getService
055: * @generated
056: */
057: public WSIFService getService() {
058: return fieldService;
059: }
060:
061: /**
062: * setService
063: * @generated
064: */
065: public void setService(WSIFService newService) {
066: fieldService = newService;
067: }
068:
069: /**
070: * getCustomer
071: * @generated
072: */
073: public com.myeis.services.Customer getCustomer(
074: java.lang.String argNumber)
075: throws org.apache.wsif.WSIFException {
076:
077: try {
078:
079: // user code begin {pre_execution}
080: // user code end
081:
082: WSIFDefaultMessage inputMessage = new WSIFDefaultMessage();
083: inputMessage.setObjectPart("number", argNumber);
084:
085: WSIFMessage outputMessage = execute("getCustomer",
086: "getCustomerRequest", "getCustomerResponse",
087: inputMessage, REQUEST_RESPONSE);
088:
089: // user code begin {post_execution}
090: // user code end
091:
092: return (com.myeis.services.Customer) outputMessage
093: .getObjectPart("result");
094:
095: } catch (Exception e) {
096: // user code begin {exception_handling}
097: // user code end
098: if (e instanceof org.apache.wsif.WSIFException)
099: throw (org.apache.wsif.WSIFException) e;
100: throw new org.apache.wsif.WSIFException(e.getMessage(), e);
101: }
102: }
103:
104: /**
105: * constructor
106: * @generated
107: */
108: public J2C_MyEIS_CustomerInfoProxy() throws WSIFException {
109:
110: // user code begin {custom_initialization}
111: // user code end
112:
113: if (this .fieldStaticService == null) {
114:
115: this .fieldStaticService = WSIFServiceFactory
116: .newInstance()
117: .getService(
118: "com/myeis/customer/CustomerInfoMYEISService.wsdl",
119: this .getClass().getClassLoader(),
120: "http://customer.myeis.com/",
121: "CustomerInfoMYEISService",
122: "http://customer.myeis.com/",
123: "CustomerInfo");
124:
125: if (this .fieldStaticService == null)
126: return;
127:
128: this .fieldStaticService.mapType(new QName(
129: "http://services.myeis.com/", "Customer"),
130: com.myeis.services.Customer.class);
131:
132: // user code begin {port_factory_setup}
133: // user code end
134: }
135: }
136:
137: /**
138: * main method (for proxy unit testing)
139: * @generated
140: */
141: public static void main(String[] args) {
142:
143: try {
144:
145: J2C_MyEIS_CustomerInfoProxy aProxy = new J2C_MyEIS_CustomerInfoProxy();
146:
147: // user code begin {proxy_method_calls}
148: String custNum = "33333";
149: Customer customer = aProxy.getCustomer(custNum);
150: System.out.println("Customer number: " + custNum);
151: System.out.println("Customer name: "
152: + customer.getFirstName() + " "
153: + customer.getLastName());
154:
155: // user code end
156:
157: } catch (Exception e) {
158:
159: // user code begin {exception_handling}
160: e.printStackTrace();
161: // user code end
162: }
163: }
164:
165: /**
166: * execute (base message-level execution)
167: * @generated
168: */
169: public WSIFMessage execute(String operationName, String inputName,
170: String outputName, WSIFMessage aMessage, int operationType)
171: throws WSIFException, Exception {
172:
173: WSIFPort port;
174: if (this .fieldPort == null) {
175: if (this .fieldService == null)
176: this .fieldService = fieldStaticService;
177: if (this .fieldService == null)
178: throw new WSIFException(
179: "Failed to resolve WSIFService.");
180: port = this .fieldService.getPort("CustomerInfoMyEISPort");
181: } else {
182: port = this .fieldPort;
183: }
184:
185: WSIFOperation operation = port.createOperation(operationName,
186: inputName, outputName);
187:
188: WSIFMessage inputMessage = operation.createInputMessage();
189:
190: String partName;
191: java.util.Iterator iterator = aMessage.getPartNames();
192: while (iterator.hasNext()) {
193: partName = (String) iterator.next();
194: inputMessage.setObjectPart(partName, aMessage
195: .getObjectPart(partName));
196: }
197:
198: WSIFMessage outputMessage = operation.createOutputMessage();
199: WSIFMessage faultMessage = operation.createFaultMessage();
200: boolean success = true;
201: if (operationType == INPUT_ONLY)
202: operation.executeInputOnlyOperation(inputMessage);
203: else if (operationType == REQUEST_RESPONSE)
204: success = operation.executeRequestResponseOperation(
205: inputMessage, outputMessage, faultMessage);
206:
207: if (this .fieldPort == null)
208: port.close();
209:
210: if (!success) {
211: java.util.Iterator i = faultMessage.getParts();
212: if (i.hasNext()) {
213: Object part = i.next();
214: if (part instanceof Exception)
215: throw (Exception) part;
216: else
217: throw new WSIFException(String.valueOf(part));
218: }
219: }
220:
221: return outputMessage;
222: }
223: }
|