1 57 58 114 115 package clients.zipcode; 116 117 import javax.xml.namespace.QName ; 118 119 import org.apache.wsif.WSIFMessage; 120 import org.apache.wsif.WSIFOperation; 121 import org.apache.wsif.WSIFPort; 122 import org.apache.wsif.WSIFService; 123 import org.apache.wsif.WSIFServiceFactory; 124 import org.apache.wsif.base.WSIFServiceImpl; 125 import org.apache.wsif.providers.soap.apachesoap.WSIFDynamicProvider_ApacheSOAP; 126 import org.apache.wsif.util.WSIFPluggableProviders; 127 128 132 public class ZIPCodeProxy { 133 private WSIFService fieldService; 134 135 public ShortZipCodeResponse getShortZipCodeResponse(ShortZipCode input) { 136 return getShortZipCodeResponse(input, null); 137 } 138 139 public ShortZipCodeResponse getShortZipCodeResponse( 140 ShortZipCode input, 141 String portName) { 142 143 try { 144 145 WSIFPort port = null; 146 if (portName != null) 147 port = fieldService.getPort(portName); 148 else 149 port = fieldService.getPort(); 150 151 WSIFOperation operation = port.createOperation("ShortZipCode", null, null); 152 153 WSIFMessage inputMessage = operation.createInputMessage(); 154 inputMessage.setName("ShortZipCodeSoapIn"); 155 156 WSIFMessage outputMessage = operation.createOutputMessage(); 157 outputMessage.setName("ShortZipCodeSoapOut"); 158 159 inputMessage.setObjectPart("parameters", input); 160 161 operation.executeRequestResponseOperation(inputMessage, outputMessage, null); 162 163 return (ShortZipCodeResponse) outputMessage.getObjectPart("parameters"); 164 165 } catch (Exception e) { 166 e.printStackTrace(); 167 throw new RuntimeException (e.getMessage()); 168 } 169 } 170 174 public ZIPCodeProxy(String wsdl) { 175 super(); 176 177 try { 178 179 WSIFDynamicProvider_ApacheSOAP apacheSoapProvider = 180 new WSIFDynamicProvider_ApacheSOAP(); 181 apacheSoapProvider.setPartSerializerName("clients.zipcode.LiteralSerializer"); 182 183 WSIFPluggableProviders.overrideDefaultProvider( 184 "http://schemas.xmlsoap.org/wsdl/soap/", 185 apacheSoapProvider); 186 187 if (fieldService == null) { 188 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 189 fieldService = 190 factory.getService( 191 wsdl, 192 this.getClass().getClassLoader(), 193 "http://webservices.eraserver.net/", 194 "ZipCodeResolver", 195 "http://webservices.eraserver.net/", 196 "ZipCodeResolverSoap"); 197 } 198 199 ((WSIFServiceImpl) fieldService).mapType( 200 new QName ("http://webservices.eraserver.net/", "ShortZipCode"), 201 ShortZipCode.class); 202 ((WSIFServiceImpl) fieldService).mapType( 203 new QName ("http://webservices.eraserver.net/", "ShortZipCodeResponse"), 204 ShortZipCodeResponse.class); 205 206 210 } catch (Exception e) { 211 e.printStackTrace(); 212 } 213 } 214 } 215 | Popular Tags |