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 ; 8 13 public class J2C_MyEIS_CustomerInfoProxy { 14 17 private static final int INPUT_ONLY = 0; 18 21 private static final int REQUEST_RESPONSE = 1; 22 25 private WSIFPort fieldPort; 26 29 private WSIFService fieldService; 30 33 private static WSIFService fieldStaticService = null; 34 38 public WSIFPort getPort() { 39 return fieldPort; 40 } 41 45 public void setPort(WSIFPort newPort) { 46 fieldPort = newPort; 47 } 48 52 public WSIFService getService() { 53 return fieldService; 54 } 55 59 public void setService(WSIFService newService) { 60 fieldService = newService; 61 } 62 66 public com.myeis.services.Customer getCustomer(java.lang.String argNumber) throws org.apache.wsif.WSIFException { 67 68 try { 69 70 73 WSIFDefaultMessage inputMessage = new WSIFDefaultMessage(); 74 inputMessage.setObjectPart("number", argNumber); 75 76 WSIFMessage outputMessage = execute("getCustomer", "getCustomerRequest", "getCustomerResponse", inputMessage, REQUEST_RESPONSE); 77 78 81 return (com.myeis.services.Customer) outputMessage.getObjectPart("result"); 82 83 } 84 catch (Exception e) { 85 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 96 public J2C_MyEIS_CustomerInfoProxy() throws WSIFException { 97 98 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 ("http://services.myeis.com/", "Customer"), com.myeis.services.Customer.class); 110 111 } 114 } 115 119 public static void main(String [] args) { 120 121 try { 122 123 J2C_MyEIS_CustomerInfoProxy aProxy = new J2C_MyEIS_CustomerInfoProxy(); 124 125 String 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 133 } 134 catch (Exception e) { 135 136 e.printStackTrace(); 138 } 140 } 141 145 public WSIFMessage execute(String operationName, String inputName, String outputName, WSIFMessage aMessage, int operationType) throws WSIFException, Exception { 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 partName; 164 java.util.Iterator iterator = aMessage.getPartNames(); 165 while (iterator.hasNext()) { 166 partName = (String ) 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 i = faultMessage.getParts(); 183 if (i.hasNext()) { 184 Object part = i.next(); 185 if (part instanceof Exception ) 186 throw (Exception ) part; 187 else 188 throw new WSIFException(String.valueOf(part)); 189 } 190 } 191 192 return outputMessage; 193 } 194 } 195 | Popular Tags |