1 /***
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18 package org.codehaus.activesoap.examples.snowboard;
19
20 import org.apache.xmlbeans.XmlObject;
21 import org.codehaus.activesoap.RestClient;
22 import org.codehaus.activesoap.RestService;
23 import org.codehaus.activesoap.SoapClient;
24 import org.codehaus.activesoap.SoapService;
25 import org.codehaus.activesoap.TestSupport;
26 import org.codehaus.activesoap.handler.xmlbeans.XMLBeansHelper;
27 import org.codehaus.activesoap.handler.xmlbeans.XMLBeansRegistry;
28 import org.codehaus.activesoap.schema.snowboard.GetEndorsingBoarderDocument;
29 import org.codehaus.activesoap.transport.http.HttpTransportClient;
30 import org.codehaus.activesoap.transport.http.HttpTransportConnector;
31
32 /***
33 * @version $Revision: 1.1 $
34 */
35 public class SnowboardDynamicTest extends TestSupport {
36
37 public void testRestClientUsingDynamicAPI() throws Exception {
38
39 XMLBeansRegistry registry = new XMLBeansRegistry();
40 registry.registerService(SnowboardServiceImpl.class);
41
42 RestService service = new RestService(registry);
43
44
45 HttpTransportConnector connector = new HttpTransportConnector("localhost", 8180, service);
46 connector.start();
47
48
49
50 RestClient client = XMLBeansHelper.createRestClient(new HttpTransportClient("http://localhost:8180"));
51
52 GetEndorsingBoarderDocument request = GetEndorsingBoarderDocument.Factory.newInstance();
53 GetEndorsingBoarderDocument.GetEndorsingBoarder endorsingBoarder = request.addNewGetEndorsingBoarder();
54 endorsingBoarder.setManufacturer("Burton");
55 request.getGetEndorsingBoarder().setModel("Custom 167");
56
57 XmlObject response = (XmlObject) client.invokeRequestReply(request);
58 System.out.println("Got response: " + response);
59
60 }
61
62 public void testSoapClientUsingDynamicAPI() throws Exception {
63
64 XMLBeansRegistry registry = new XMLBeansRegistry();
65 registry.registerService(SnowboardServiceImpl.class);
66
67 SoapService service = new SoapService(registry);
68
69
70 HttpTransportConnector connector = new HttpTransportConnector("localhost", 8080, service);
71 connector.start();
72
73
74
75 SoapClient client = XMLBeansHelper.createSoapClient(new HttpTransportClient("http://localhost:8080"));
76
77 GetEndorsingBoarderDocument request = GetEndorsingBoarderDocument.Factory.newInstance();
78 GetEndorsingBoarderDocument.GetEndorsingBoarder endorsingBoarder = request.addNewGetEndorsingBoarder();
79 endorsingBoarder.setManufacturer("Burton");
80 request.getGetEndorsingBoarder().setModel("Custom 167");
81
82 XmlObject response = (XmlObject) client.invokeRequestReply(request);
83 System.out.println("Got response: " + response);
84
85 }
86 }