cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r529510 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/interceptor/ systests/src/test/java/org/apache/cxf/systest/jaxws/ testutils/ testutils/src/main/java/org/apache/hello_world_soap_http/any_types/ testutils/src/main/reso...
Date Tue, 17 Apr 2007 07:04:25 GMT
Author: ffang
Date: Tue Apr 17 00:04:24 2007
New Revision: 529510

URL: http://svn.apache.org/viewvc?view=rev&rev=529510
Log:
[CXF-526] fix untime will fail if element has minOccurs="0" maxOccurs="unbounded" attribute
[CXF-497] system test to show how to get xs:any type works


Added:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/AnyClientServerTest.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/any_types/
    incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/any_types/GreeterImpl.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/any.wsdl   (with props)
Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
    incubator/cxf/trunk/testutils/pom.xml

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java?view=diff&rev=529510&r1=529509&r2=529510
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
Tue Apr 17 00:04:24 2007
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.interceptor;
 
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -116,10 +118,7 @@
                 }
 
                 // loop through each child element
-                while (StaxUtils.toNextElement(xmlReader) && itr.hasNext()) {
-                    MessagePartInfo part = itr.next();
-                    parameters.add(dr.read(part, xmlReader));
-                }
+                getPara(xmlReader, dr, parameters, itr);
             }
 
         } else {
@@ -194,6 +193,42 @@
             message.setContent(List.class, parameters);
         }
     }
+    
+    private void getPara(DepthXMLStreamReader xmlReader,
+                         DataReader<XMLStreamReader> dr,
+                         List<Object> parameters,
+                         Iterator<MessagePartInfo> itr) {
+
+        boolean isListPara = false;
+        List<Object> list = new ArrayList<Object>();
+        MessagePartInfo part = null;
+        while (StaxUtils.toNextElement(xmlReader)) {
+            if (itr.hasNext()) {
+                part = itr.next();
+                if (part.getTypeClass().getName().startsWith("[L")) {
+                    //it's List Para
+                    isListPara = true;
+                    Type genericType = (Type) part.getProperty("generic.type");
+                    ParameterizedType pt = (ParameterizedType) genericType;
+                    part.setTypeClass((Class<?>)pt.getActualTypeArguments()[0]);
+                } 
+            } 
+            if (part == null) {
+                break;
+            }
+            list.add(dr.read(part, xmlReader));
+
+        }
+        if (isListPara) {
+            parameters.add(list);
+        } else {
+            for (Object obj : list) {
+                parameters.add(obj);
+            }
+
+        }
+    }
+
 
     private MessageInfo setMessage(Message message, BindingOperationInfo operation,
                                    boolean requestor, ServiceInfo si) {

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/AnyClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/AnyClientServerTest.java?view=auto&rev=529510
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/AnyClientServerTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/AnyClientServerTest.java
Tue Apr 17 00:04:24 2007
@@ -0,0 +1,127 @@
+/**
+ * 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.jaxws;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+
+
+
+
+
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.hello_world_soap_http.any.Greeter;
+import org.apache.hello_world_soap_http.any.SOAPService;
+import org.apache.hello_world_soap_http.any_types.GreeterImpl;
+import org.apache.hello_world_soap_http.any_types.SayHi.Port;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public final class AnyClientServerTest extends AbstractBusClientServerTestBase {
+
+    static final Logger LOG = Logger.getLogger(AnyClientServerTest.class.getName());
+    private final QName serviceName = new QName("http://apache.org/hello_world_soap_http/any",

+                                                "SOAPService");
+
+    public static class MyServer extends AbstractBusTestServerBase {
+
+        protected void run() {
+            Object implementor = new GreeterImpl();
+            String address = "http://localhost:9000/SoapContext/SoapPort";
+            Endpoint.publish(address, implementor);
+
+        }
+
+        public static void main(String[] args) {
+            try {
+                MyServer s = new MyServer();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                LOG.info("done!");
+            }
+        }
+    }
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", launchServer(MyServer.class));
+    }
+
+    @Test
+    //@Ignore
+    public void testAny() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/any.wsdl");
+        assertNotNull(wsdl);
+
+        SOAPService ss = new SOAPService(wsdl, serviceName);
+        Greeter port = ss.getSoapPort();
+
+        List<Port> any = new ArrayList<Port>();
+        Port anyPort = new Port();
+        Port anyPort1 = new Port();
+        JAXBElement<String> ele1 = new JAXBElement<String>(
+            new QName("http://apache.org/hello_world_soap_http/other", "port"), 
+            String.class, "hello");
+        
+        anyPort.setAny(ele1);
+        JAXBElement<String> ele2 = new JAXBElement<String>(
+            new QName("http://apache.org/hello_world_soap_http/other", "port"), 
+            String.class, "Bon");
+        anyPort1.setAny(ele2);
+        
+        any.add(anyPort);
+        any.add(anyPort1);
+        String rep = port.sayHi(any);
+        assertEquals(rep, "helloBon");
+    }
+    
+    @Test
+    @Ignore
+    public void testList() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/any.wsdl");
+        assertNotNull(wsdl);
+
+        SOAPService ss = new SOAPService(wsdl, serviceName);
+        Greeter port = ss.getSoapPort();
+        List<org.apache.hello_world_soap_http.any_types.SayHi1.Port> list = 
+                new ArrayList<org.apache.hello_world_soap_http.any_types.SayHi1.Port>();
+        org.apache.hello_world_soap_http.any_types.SayHi1.Port port1 = 
+            new org.apache.hello_world_soap_http.any_types.SayHi1.Port();
+        port1.setRequestType("hello");
+        org.apache.hello_world_soap_http.any_types.SayHi1.Port port2 = 
+            new org.apache.hello_world_soap_http.any_types.SayHi1.Port();
+        port2.setRequestType("Bon");
+        list.add(port1);
+        list.add(port2);
+        String rep = port.sayHi1(list);
+        assertEquals(rep, "helloBon");
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/AnyClientServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/AnyClientServerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/testutils/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/pom.xml?view=diff&rev=529510&r1=529509&r2=529510
==============================================================================
--- incubator/cxf/trunk/testutils/pom.xml (original)
+++ incubator/cxf/trunk/testutils/pom.xml Tue Apr 17 00:04:24 2007
@@ -362,8 +362,10 @@
                                 <wsdlOption>
                                     <wsdl>${basedir}/src/main/resources/wsdl/header_rpc_lit.wsdl</wsdl>
                                 </wsdlOption>
-
-                            </wsdlOptions>
+				<wsdlOption>
+		                    <wsdl>${basedir}/src/main/resources/wsdl/any.wsdl</wsdl>
+                		</wsdlOption>
+		            </wsdlOptions>
                         </configuration>
                         <goals>
                             <goal>wsdl2java</goal>

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/any_types/GreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/any_types/GreeterImpl.java?view=auto&rev=529510
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/any_types/GreeterImpl.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/any_types/GreeterImpl.java
Tue Apr 17 00:04:24 2007
@@ -0,0 +1,58 @@
+/**
+ * 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.hello_world_soap_http.any_types;
+
+import java.util.List;
+
+import javax.jws.WebService;
+
+import org.w3c.dom.Element;
+
+import org.apache.hello_world_soap_http.any.Greeter;
+import org.apache.hello_world_soap_http.any_types.SayHi.Port;
+
+@WebService(serviceName = "SOAPService",
+            portName = "SoapPort",
+            endpointInterface = "org.apache.hello_world_soap_http.any.Greeter",
+            targetNamespace = "http://apache.org/hello_world_soap_http/any")
+public class GreeterImpl implements Greeter {
+
+    public String sayHi(List<Port> port) {
+        String ret = null;
+        if (port.get(0).getAny() instanceof Element) {
+            Element ele = (Element)port.get(0).getAny();
+            ret =  ele.getFirstChild().getTextContent();
+        }
+        if (port.get(1).getAny() instanceof Element) {
+            Element ele = (Element)port.get(1).getAny();
+            ret +=  ele.getFirstChild().getTextContent();
+        }
+        return ret;
+    }
+
+    public String sayHi1(List<org.apache.hello_world_soap_http.any_types.SayHi1.Port>
port) {
+        return port.get(0).getRequestType() + port.get(1).getRequestType();
+        
+    }
+
+    
+    
+
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/any_types/GreeterImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/any_types/GreeterImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/resources/wsdl/any.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/any.wsdl?view=auto&rev=529510
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/any.wsdl (added)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/any.wsdl Tue Apr 17 00:04:24 2007
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:tns="http://apache.org/hello_world_soap_http/any"
+    xmlns:x1="http://apache.org/hello_world_soap_http/any_types"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    targetNamespace="http://apache.org/hello_world_soap_http/any" name="HelloWorld">
+    <wsdl:types>
+        <schema targetNamespace="http://apache.org/hello_world_soap_http/any_types" xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:x1="http://apache.org/hello_world_soap_http/any_types" xmlns:xs="http://www.w3.org/2001/XMLSchema"

+	xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" elementFormDefault="qualified">
+            <element name="sayHi">
+		<xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="port" minOccurs="0" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:any namespace="##other" processContents="lax"><!--
minOccurs="0" maxOccurs="unbounded"-->
+                                    </xs:any>
+				    <!--element name="requestType" type="string"/-->
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                
+                </xs:complexType>
+            </element>
+	    <element name="sayHi1">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element name="port" minOccurs="0" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <element name="requestType" type="string"/>
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+
+                </xs:complexType>
+            </element>
+	    
+
+
+            <element name="sayHiResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="string"/>
+                    </sequence>
+                </complexType>
+            </element>
+        </schema>
+    </wsdl:types>
+    <wsdl:message name="sayHiRequest">
+        <wsdl:part name="in" element="x1:sayHi"/>
+    </wsdl:message>
+    <wsdl:message name="sayHi1Request">
+        <wsdl:part name="in" element="x1:sayHi1"/>
+    </wsdl:message>
+
+    <wsdl:message name="sayHiResponse">
+        <wsdl:part name="out" element="x1:sayHiResponse"/>
+    </wsdl:message>
+    <wsdl:portType name="Greeter">
+        <wsdl:operation name="sayHi">
+            <wsdl:input name="sayHiRequest" message="tns:sayHiRequest"/>
+            <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"/>
+        </wsdl:operation>
+        <wsdl:operation name="sayHi1">
+            <wsdl:input name="sayHi1Request" message="tns:sayHi1Request"/>
+            <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+
+    <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="sayHi">
+            <soap:operation style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+	<wsdl:operation name="sayHi1">
+            <soap:operation style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+
+    </wsdl:binding>
+
+    <wsdl:service name="SOAPService">
+	<wsdl:port name="SoapPort" binding="tns:Greeter_SOAPBinding">
+            <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+        </wsdl:port>
+    </wsdl:service>
+
+</wsdl:definitions>

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/any.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/any.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/any.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message