cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r440307 [2/2] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/wsdl/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/core/src/main/java/org/ap...
Date Tue, 05 Sep 2006 09:41:06 GMT
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWStreamSourcePayloadProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWStreamSourcePayloadProvider.java?view=auto&rev=440307
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWStreamSourcePayloadProvider.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/HWStreamSourcePayloadProvider.java
Tue Sep  5 02:41:04 2006
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.provider;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
+
+
+
+//The following wsdl file is used.
+//wsdlLocation = "/trunk/testutils/src/main/resources/wsdl/hello_world_rpc_lit.wsdl"
+@WebServiceProvider(portName = "SoapPortRPCLit6", serviceName = "SOAPServiceRPCLit6",
+                targetNamespace = "http://apache.org/hello_world_rpclit",
+wsdlLocation = "/wsdl/hello_world_rpc_lit.wsdl")
+@ServiceMode(value = Service.Mode.PAYLOAD)
+public class HWStreamSourcePayloadProvider implements Provider<StreamSource> {
+    
+    private static QName sayHi = new QName("http://apache.org/hello_world_rpclit", "sayHi");
+    private static QName greetMe = new QName("http://apache.org/hello_world_rpclit", "greetMe");
+    private InputStream sayHiInputStream;
+    private InputStream greetMeInputStream;
+    private MessageFactory factory;
+
+    public HWStreamSourcePayloadProvider() {
+
+        try {
+            factory = MessageFactory.newInstance();
+            InputStream is = getClass().getResourceAsStream("resources/sayHiRpcLiteralResp.xml");
+            Document sayHiDocument = factory.createMessage(null, is).getSOAPBody().extractContentAsDocument();
+            sayHiInputStream = getSOAPBodyStream(sayHiDocument);
+            
+            InputStream is2 = getClass().getResourceAsStream("resources/GreetMeRpcLiteralResp.xml");
+            Document greetMeDocument = 
+                factory.createMessage(null, is2).getSOAPBody().extractContentAsDocument();
+            greetMeInputStream = getSOAPBodyStream(greetMeDocument);
+
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    public StreamSource invoke(StreamSource request) {
+        StreamSource response = new StreamSource();
+        try {
+            DOMResult domResult = new DOMResult();
+            Transformer transformer = TransformerFactory.newInstance().newTransformer();
+            transformer.transform(request, domResult);
+            Node n = domResult.getNode().getFirstChild();
+
+            while (n.getNodeType() != Node.ELEMENT_NODE) {
+                n = n.getNextSibling();
+            }
+            if (n.getLocalName().equals(sayHi.getLocalPart())) {
+                response.setInputStream(sayHiInputStream);
+            } else if (n.getLocalName().equals(greetMe.getLocalPart())) {
+                response.setInputStream(greetMeInputStream);
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return response;
+    }
+    
+    private InputStream getSOAPBodyStream(Document doc) throws Exception {
+        System.setProperty(DOMImplementationRegistry.PROPERTY,
+            "com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
+        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+        DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
+        LSOutput output = impl.createLSOutput();
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        output.setByteStream(byteArrayOutputStream);
+        LSSerializer writer = impl.createLSSerializer();
+        writer.write(doc, output);
+        byte[] buf = byteArrayOutputStream.toByteArray();
+        return new ByteArrayInputStream(buf);
+    }
+
+    
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java?view=auto&rev=440307
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java
Tue Sep  5 02:41:04 2006
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.provider;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.cxf.systest.common.ClientServerSetupBase;
+import org.apache.cxf.systest.common.ClientServerTestBase;
+import org.apache.cxf.systest.common.TestServerBase;
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.SOAPService;
+
+public class ProviderClientServerTest extends ClientServerTestBase {
+    public static class Server extends TestServerBase {
+
+        protected void run() {
+            Object implementor = new HWSoapMessageDocProvider();
+            String address = "http://localhost:9003/SoapContext/SoapProviderPort";
+            Endpoint.publish(address, implementor);
+                        
+//            implementor = new HWDOMSourceMessageProvider();
+//            address = new String("http://localhost:9002/SOAPServiceRPCLit/SoapPort1");
+//            Endpoint.publish(address, implementor);
+//            
+//            implementor = new HWDOMSourcePayloadProvider();
+//            address = new String("http://localhost:9002/SOAPServiceRPCLit/SoapPort2");
+//            Endpoint.publish(address, implementor); 
+//            
+//            implementor = new HWSAXSourceMessageProvider();
+//            address = new String("http://localhost:9002/SOAPServiceRPCLit/SoapPort3");
+//            Endpoint.publish(address, implementor); 
+//            
+//            implementor = new HWStreamSourceMessageProvider();
+//            address = new String("http://localhost:9002/SOAPServiceRPCLit/SoapPort4");
+//            Endpoint.publish(address, implementor); 
+//            
+//            implementor = new HWSAXSourcePayloadProvider();
+//            address = new String("http://localhost:9002/SOAPServiceRPCLit/SoapPort5");
+//            Endpoint.publish(address, implementor); 
+//            
+//            implementor = new HWStreamSourcePayloadProvider();
+//            address = new String("http://localhost:9002/SOAPServiceRPCLit/SoapPort6");
+//            Endpoint.publish(address, implementor);             
+        }
+
+        public static void main(String[] args) {
+            try {
+                Server s = new Server();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                System.out.println("done!");
+            }
+        }
+    }
+
+    public static Test suite() throws Exception {
+        TestSuite suite = new TestSuite(ProviderClientServerTest.class);
+        return new ClientServerSetupBase(suite) {
+            public void startServers() throws Exception {
+                assertTrue("server did not launch correctly", launchServer(Server.class));
+            }
+        };
+    }
+
+//    public void testSOAPMessageModeRPC() throws Exception {
+//        
+//        QName serviceName = 
+//            new QName("http://apache.org/hello_world_rpclit", "SOAPServiceRPCLit");
+//        QName portName = 
+//            new QName("http://apache.org/hello_world_rpclit", "SoapPortRPCLit");
+//
+//        URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl");
+//        assertNotNull(wsdl);
+//
+//        SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
+//        assertNotNull(service);
+//
+//        String response1 = new String("TestGreetMeResponse");
+//        String response2 = new String("TestSayHiResponse");
+//        try {
+//            GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
+//            for (int idx = 0; idx < 2; idx++) {
+//                String greeting = greeter.greetMe("Milestone-" + idx);
+//                assertNotNull("no response received from service", greeting);
+//                assertEquals(response1, greeting);
+//
+//                String reply = greeter.sayHi();
+//                assertNotNull("no response received from service", reply);
+//                assertEquals(response2, reply);
+//            }
+//        } catch (UndeclaredThrowableException ex) {
+//            throw (Exception)ex.getCause();
+//        }
+//    }
+
+    public void testSOAPMessageModeDocLit() throws Exception {
+        
+        QName serviceName = 
+            new QName("http://apache.org/hello_world_soap_http", "SOAPProviderService");
+        QName portName = 
+            new QName("http://apache.org/hello_world_soap_http", "SoapProviderPort");
+
+        URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
+        assertNotNull(wsdl);
+
+        SOAPService service = new SOAPService(wsdl, serviceName);
+        assertNotNull(service);
+
+        String response1 = new String("TestSOAPOutputPMessage");
+        String response2 = new String("Bonjour");
+        try {
+            Greeter greeter = service.getPort(portName, Greeter.class);
+            for (int idx = 0; idx < 2; idx++) {
+                String greeting = greeter.greetMe("Milestone-" + idx);
+                assertNotNull("no response received from service", greeting);
+                assertEquals(response1, greeting);
+
+                String reply = greeter.sayHi();
+                assertNotNull("no response received from service", reply);
+                assertEquals(response2, reply);
+            }
+        } catch (UndeclaredThrowableException ex) {
+            throw (Exception)ex.getCause();
+        }
+    }
+
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeDocLiteralReq.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeDocLiteralReq.xml?view=auto&rev=440307
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeDocLiteralReq.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeDocLiteralReq.xml
Tue Sep  5 02:41:04 2006
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8" ?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns4:greetMe
xmlns:ns4="http://objectweb.org/hello_world_soap_http/types"><ns4:requestType>TestSOAPInputPMessage</ns4:requestType></ns4:greetMe></SOAP-ENV:Body></SOAP-ENV:Envelope>

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeDocLiteralResp.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeDocLiteralResp.xml?view=auto&rev=440307
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeDocLiteralResp.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeDocLiteralResp.xml
Tue Sep  5 02:41:04 2006
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns4:greetMeResponse
xmlns:ns4="http://apache.org/hello_world_soap_http/types"><ns4:responseType>TestSOAPOutputPMessage</ns4:responseType></ns4:greetMeResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
\ No newline at end of file

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeRpcLiteralResp.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeRpcLiteralResp.xml?view=auto&rev=440307
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeRpcLiteralResp.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/GreetMeRpcLiteralResp.xml
Tue Sep  5 02:41:04 2006
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<SOAP-ENV:Envelope 
+    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <SOAP-ENV:Body>
+        <ns4:greetMeResponse xmlns:ns4="http://objectweb.org/hello_world_rpclit">
+            <out>TestGreetMeResponse</out>
+        </ns4:greetMeResponse>
+    </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiDocLiteralReq.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiDocLiteralReq.xml?view=auto&rev=440307
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiDocLiteralReq.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiDocLiteralReq.xml
Tue Sep  5 02:41:04 2006
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8" ?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns5:sayHi
xmlns:ns4="http://www.w3.org/2005/08/addressing/wsdl" xmlns:ns5="http://objectweb.org/hello_world_soap_http/types"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
\ No newline at end of file

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiDocLiteralResp.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiDocLiteralResp.xml?view=auto&rev=440307
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiDocLiteralResp.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiDocLiteralResp.xml
Tue Sep  5 02:41:04 2006
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns4:sayHiResponse
xmlns:ns4="http://apache.org/hello_world_soap_http/types" xmlns:ns5="http://www.w3.org/2005/08/addressing/wsdl"><ns4:responseType>Bonjour</ns4:responseType></ns4:sayHiResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
\ No newline at end of file

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiRpcLiteralResp.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiRpcLiteralResp.xml?view=auto&rev=440307
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiRpcLiteralResp.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/provider/resources/sayHiRpcLiteralResp.xml
Tue Sep  5 02:41:04 2006
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<SOAP-ENV:Envelope 
+    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:m1="http://objectweb.org/hello_world_rpclit">
+    <SOAP-ENV:Body>
+        <m1:sayHiResponse>
+           <out>TestSayHiResponse</out>
+        </m1:sayHiResponse>
+    </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
\ No newline at end of file

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl?view=diff&rev=440307&r1=440306&r2=440307
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl Tue Sep  5 02:41:04
2006
@@ -270,13 +270,21 @@
 
 
     <wsdl:service name="SOAPService">
-        <wsdl:port name="SoapPort" binding="tns:Greeter_SOAPBinding">
+	<wsdl:port name="SoapPort" binding="tns:Greeter_SOAPBinding">
             <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
         </wsdl:port>
+
 	<wsdl:port name="SoapPort1" binding="tns:Greeter_SOAPBinding">
             <soap:address location="http://localhost:7000/SoapContext/SoapPort"/>
         </wsdl:port>
     </wsdl:service>
+
+    <wsdl:service name="SOAPProviderService">
+        <wsdl:port name="SoapProviderPort" binding="tns:Greeter_SOAPBinding">
+            <soap:address location="http://localhost:9003/SoapContext/SoapProviderPort"/>
+        </wsdl:port>
+    </wsdl:service>
+
 
     <wsdl:service name="SOAPService_DocLitBare">
         <wsdl:port name="SoapPort2" binding="tns:Doc_Lit_Bare_SOAPBinding">



Mime
View raw message