01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.servicemix.components.http;
18:
19: import java.io.BufferedReader;
20: import java.io.InputStream;
21: import java.io.InputStreamReader;
22: import java.io.OutputStream;
23: import java.net.URL;
24: import java.net.URLConnection;
25:
26: import org.apache.commons.logging.Log;
27: import org.apache.commons.logging.LogFactory;
28: import org.apache.servicemix.tck.TestSupport;
29: import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
30: import org.springframework.context.support.AbstractXmlApplicationContext;
31:
32: /**
33: * @version $Revision: 359186 $
34: */
35: public class HttpSoapWsTest extends TestSupport {
36: private static transient Log log = LogFactory
37: .getLog(HttpSoapWsTest.class);
38:
39: protected String quote = "SUNW";
40:
41: public void testWithURLConnection() throws Exception {
42: URLConnection connection = new URL("http://localhost:8912")
43: .openConnection();
44: connection.setDoOutput(true);
45: connection.setDoInput(true);
46: OutputStream os = connection.getOutputStream();
47:
48: // Post the request file.
49: InputStream fis = getClass().getResourceAsStream(
50: "soap-request.xml");
51: int c;
52: while ((c = fis.read()) >= 0) {
53: os.write(c);
54: }
55: os.flush();
56: os.close();
57: fis.close();
58:
59: // Read the response.
60: BufferedReader in = new BufferedReader(new InputStreamReader(
61: connection.getInputStream()));
62: String inputLine;
63: while ((inputLine = in.readLine()) != null) {
64: log.info(inputLine);
65: }
66: in.close();
67: }
68:
69: protected AbstractXmlApplicationContext createBeanFactory() {
70: return new ClassPathXmlApplicationContext(
71: "org/apache/servicemix/components/http/ws-example.xml");
72: }
73: }
|