1 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 javax.xml.namespace.QName ; 27 28 import org.apache.servicemix.tck.TestSupport; 29 import org.springframework.context.support.AbstractXmlApplicationContext; 30 import org.w3c.dom.Node ; 31 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; 32 33 36 public class HttpSoapWsTest extends TestSupport { 37 38 protected String quote = "SUNW"; 39 40 public void testWithURLConnection() throws Exception { 41 URLConnection connection = new URL ("http://localhost:8912").openConnection(); 42 connection.setDoOutput(true); 43 connection.setDoInput(true); 44 OutputStream os = connection.getOutputStream(); 45 46 InputStream fis = getClass().getResourceAsStream("soap-request.xml"); 48 int c; 49 while ((c = fis.read()) >= 0) { 50 os.write(c); 51 } 52 os.flush(); 53 os.close(); 54 fis.close(); 55 56 BufferedReader in = new BufferedReader (new InputStreamReader (connection.getInputStream())); 58 String inputLine; 59 while ((inputLine = in.readLine()) != null) { 60 System.out.println(inputLine); 61 } 62 in.close(); 63 } 64 65 protected AbstractXmlApplicationContext createBeanFactory() { 66 return new ClassPathXmlApplicationContext("org/apache/servicemix/components/http/ws-example.xml"); 67 } 68 } 69 | Popular Tags |