KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > clients > zipcode > ZIPCodeProxy


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "WSIF" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, 2002, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 /*
59  * The Apache Software License, Version 1.1
60  *
61  *
62  * Copyright (c) 2002 The Apache Software Foundation. All rights
63  * reserved.
64  *
65  * Redistribution and use in source and binary forms, with or without
66  * modification, are permitted provided that the following conditions
67  * are met:
68  *
69  * 1. Redistributions of source code must retain the above copyright
70  * notice, this list of conditions and the following disclaimer.
71  *
72  * 2. Redistributions in binary form must reproduce the above copyright
73  * notice, this list of conditions and the following disclaimer in
74  * the documentation and/or other materials provided with the
75  * distribution.
76  *
77  * 3. The end-user documentation included with the redistribution,
78  * if any, must include the following acknowledgment:
79  * "This product includes software developed by the
80  * Apache Software Foundation (http://www.apache.org/)."
81  * Alternately, this acknowledgment may appear in the software itself,
82  * if and wherever such third-party acknowledgments normally appear.
83  *
84  * 4. The names "WSIF" and "Apache Software Foundation" must
85  * not be used to endorse or promote products derived from this
86  * software without prior written permission. For written
87  * permission, please contact apache@apache.org.
88  *
89  * 5. Products derived from this software may not be called "Apache",
90  * nor may "Apache" appear in their name, without prior written
91  * permission of the Apache Software Foundation.
92  *
93  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
94  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
95  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
96  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
97  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
98  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
99  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
100  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
101  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
102  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
103  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
104  * SUCH DAMAGE.
105  * ====================================================================
106  *
107  * This software consists of voluntary contributions made by many
108  * individuals on behalf of the Apache Software Foundation and was
109  * originally based on software copyright (c) 2001, 2002, International
110  * Business Machines, Inc., http://www.apache.org. For more
111  * information on the Apache Software Foundation, please see
112  * <http://www.apache.org/>.
113  */

114
115 package clients.zipcode;
116
117 import javax.xml.namespace.QName JavaDoc;
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 /**
129  * interopLabProxy
130  * @generated
131  */

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 JavaDoc 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 JavaDoc e) {
166             e.printStackTrace();
167             throw new RuntimeException JavaDoc(e.getMessage());
168         }
169     }
170     /**
171     * Constructor
172     * @generated
173     */

174     public ZIPCodeProxy(String JavaDoc 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 JavaDoc("http://webservices.eraserver.net/", "ShortZipCode"),
201                 ShortZipCode.class);
202             ((WSIFServiceImpl) fieldService).mapType(
203                 new QName JavaDoc("http://webservices.eraserver.net/", "ShortZipCodeResponse"),
204                 ShortZipCodeResponse.class);
205
206             // provider reset now at end of ZIPCodeTest.doit()
207
//WSIFServiceImpl.setDynamicWSIFProvider(
208
// "http://schemas.xmlsoap.org/wsdl/soap/", null);
209

210         } catch (Exception JavaDoc e) {
211             e.printStackTrace();
212         }
213     }
214 }
215
Popular Tags