cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r440293 - in /incubator/cxf/trunk: api/src/test/java/org/apache/cxf/wsdl/ api/src/test/resources/wsdl/ rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/core/src/main/...
Date Tue, 05 Sep 2006 08:23:05 GMT
Author: tli
Date: Tue Sep  5 01:23:04 2006
New Revision: 440293

URL: http://svn.apache.org/viewvc?view=rev&rev=440293
Log:
refactor the extension, add xml bare in interceptor unit test

Added:
    incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_binding.wsdl   (with props)
Removed:
    incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_bare.wsdl
Modified:
    incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java

Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java?view=diff&rev=440293&r1=440292&r2=440293
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
(original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
Tue Sep  5 01:23:04 2006
@@ -71,7 +71,7 @@
                         "org.apache.cxf.bindings.xformat.XMLBindingMessageFormat", Thread.currentThread()
                                         .getContextClassLoader());
 
-        String file = this.getClass().getResource("/wsdl/hello_world_xml_bare.wsdl").getFile();
+        String file = this.getClass().getResource("/wsdl/hello_world_xml_binding.wsdl").getFile();
 
         wsdlReader.setExtensionRegistry(registry);
 

Added: incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_binding.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_binding.wsdl?view=auto&rev=440293
==============================================================================
--- incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_binding.wsdl (added)
+++ incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_binding.wsdl Tue Sep 
5 01:23:04 2006
@@ -0,0 +1,110 @@
+<?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 name="HelloWorld" targetNamespace="http://apache.org/hello_world_xml_http/bare"

+		  xmlns="http://schemas.xmlsoap.org/wsdl/"
+		  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+		  xmlns:xformat="http://cxf.apache.org/bindings/xformat" 
+		  xmlns:tns="http://apache.org/hello_world_xml_http/bare"
+		  xmlns:x1="http://apache.org/hello_world_xml_http/bare/types"
+		  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+		  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  
+  <wsdl:types>
+    <schema targetNamespace="http://apache.org/hello_world_xml_http/bare/types" 
+	    xmlns="http://www.w3.org/2001/XMLSchema" 
+	    elementFormDefault="qualified">
+
+      <element name="responseType" type="xsd:string"/>
+      <element name="requestType" type="xsd:string"/>
+
+      <complexType name="myComplexStruct">
+	<sequence>
+	  <element name="elem1" type="xsd:string"/>
+	  <element name="elem2" type="xsd:string"/>
+	  <element name="elem3" type="xsd:int"/>
+	</sequence>
+      </complexType>
+    </schema>
+  </wsdl:types>
+  
+  <wsdl:message name="sayHiRequest"/>
+  
+  <wsdl:message name="sayHiResponse">
+    <wsdl:part type="xsd:string" name="out"/>
+  </wsdl:message>
+  
+  <wsdl:message name="greetMeRequest">
+    <wsdl:part element="x1:requestType" name="me"/>
+  </wsdl:message>
+  
+  <wsdl:message name="greetMeResponse">
+    <wsdl:part element="x1:responseType" name="theResponse"/>
+  </wsdl:message>
+  
+  <wsdl:message name="sendReceiveDataRequest">
+    <wsdl:part type="x1:myComplexStruct" name="in"/>
+  </wsdl:message>
+  
+  <wsdl:message name="sendReceiveDataResponse">
+    <wsdl:part type="x1:myComplexStruct" name="out"/>
+  </wsdl:message>
+  
+  <wsdl:portType name="Greeter">
+    <wsdl:operation name="sayHi">
+      <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+      <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+    </wsdl:operation>
+    <wsdl:operation name="greetMe">
+      <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+      <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+    </wsdl:operation>
+    <wsdl:operation name="sendReceiveData">
+      <wsdl:input message="tns:sendReceiveDataRequest" name="SendReceiveDataRequest"/>
+      <wsdl:output message="tns:sendReceiveDataResponse" name="SendReceiveDataResponse"/>
+    </wsdl:operation>
+  </wsdl:portType>
+  
+  <wsdl:binding name="Greeter_XMLBinding" type="tns:Greeter">
+    <xformat:binding/>
+    <wsdl:operation name="sayHi">
+      <wsdl:input>
+	<xformat:body rootNode="sayHi"/>
+      </wsdl:input>
+      <wsdl:output/>
+    </wsdl:operation>
+    
+    <wsdl:operation name="greetMe">
+      <wsdl:input/>
+      <wsdl:output/>
+    </wsdl:operation>
+    
+    <wsdl:operation name="sendReceiveData">
+      <wsdl:input/>
+      <wsdl:output/>
+    </wsdl:operation>
+  </wsdl:binding>
+  
+  <wsdl:service name="XMLService">
+    <wsdl:port binding="tns:Greeter_XMLBinding" name="XMLPort">
+      <http:address location="http://localhost:9000/XMLService/XMLPort"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

Propchange: incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_binding.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_binding.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java?view=diff&rev=440293&r1=440292&r2=440293
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java
Tue Sep  5 01:23:04 2006
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.binding.xml.interceptor;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.ResourceBundle;
 
 import javax.xml.namespace.QName;
@@ -28,7 +26,6 @@
 
 import org.apache.cxf.bindings.xformat.XMLBindingMessageFormat;
 import org.apache.cxf.common.i18n.BundleUtils;
-import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
 import org.apache.cxf.interceptor.BareInInterceptor;
@@ -36,13 +33,14 @@
 import org.apache.cxf.interceptor.WrappedInInterceptor;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.staxutils.DepthXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
 
-public class XMLMessageInInterceptor
-                extends AbstractInDatabindingInterceptor {
+public class XMLMessageInInterceptor extends AbstractInDatabindingInterceptor {
 
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(WrappedInInterceptor.class);
 
@@ -53,33 +51,40 @@
         Endpoint ep = message.getExchange().get(Endpoint.class);
         BindingInfo service = ep.getEndpointInfo().getBinding();
 
-        List<Object> parameters = new ArrayList<Object>();
-        DataReader<XMLStreamReader> dr = getDataReader(message);
         // StaxUtils.nextEvent(xmlReader);
-        while (StaxUtils.toNextElement(dxsr)) {
-            Object o = dr.read(dxsr);
-            parameters.add(o);
-        }
         if (!StaxUtils.toNextElement(dxsr)) {
             throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OPERATION_ELEMENT",
BUNDLE));
         }
-        QName startQName = new QName(dxsr.getLocalName(), dxsr.getNamespaceURI());
+        QName startQName = new QName(dxsr.getNamespaceURI(), dxsr.getLocalName());
         for (BindingOperationInfo boi : service.getOperations()) {
             MessageInfo mi;
-            if (isRequestor(message)) {
+            BindingMessageInfo bmi;
+            if (!isRequestor(message)) {
                 mi = boi.getOperationInfo().getInput();
+                bmi = boi.getInput();
             } else {
                 mi = boi.getOperationInfo().getOutput();
+                bmi = boi.getOutput();
+            }
+            QName rootInModel = null;
+            Object ext = bmi.getExtensor(XMLBindingMessageFormat.class);
+            if (ext instanceof XMLBindingMessageFormat) {
+                // it's bare mode method, the root node exist for multi param
+                rootInModel = ((XMLBindingMessageFormat) ext).getRootNode();
+            } else {
+                // its wrap mode or bare-single-param mode, using operation name
+                rootInModel = boi.getName();
             }
-            QName rootInModel = ((XMLBindingMessageFormat) mi.getExtensor(XMLBindingMessageFormat.class))
-                            .getRootNode();
             if (rootInModel != null && rootInModel.equals(startQName)) {
                 if (mi.getMessageParts().size() != 1) {
+                    // handle multi param in bare mode
                     message.getExchange().put(BindingOperationInfo.class, boi);
+                    StaxUtils.nextEvent(dxsr);
+                    StaxUtils.toNextElement(dxsr);
                     new BareInInterceptor().handleMessage(message);
                     break;
                 } else {
-                    if (boi.isUnwrapped()) {
+                    if (!boi.isUnwrapped()) {
                         // it's bare with one part and part name equals
                         // operation name (not support yet)
                         QName paramName = mi.getMessagePartByIndex(0).getElementQName();
@@ -98,8 +103,18 @@
             } else {
                 // bare with one part and part name not equal operation name,
                 // check param match
-                if (boi.isUnwrapped()) {
-                    QName paramName = mi.getMessagePartByIndex(0).getElementQName();
+                if (!boi.isUnwrapped()) {
+                    if (mi.getMessageParts().size() != 1) {
+                        continue;
+                    }
+                    MessagePartInfo mpi = mi.getMessagePartByIndex(0);
+                    QName paramName;
+                    if (mpi.isElement()) {
+                        paramName = mpi.getElementQName();
+                    } else {
+                        // currently this has not been suppoerted by JAXBEncoderDecoder
+                        paramName = mpi.getTypeQName();
+                    }                    
                     if (paramName.equals(startQName)) {
                         message.getExchange().put(BindingOperationInfo.class, boi);
                         new BareInInterceptor().handleMessage(message);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java?view=diff&rev=440293&r1=440292&r2=440293
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
Tue Sep  5 01:23:04 2006
@@ -24,6 +24,7 @@
 import java.util.List;
 
 import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 
 import org.w3c.dom.Element;
@@ -57,10 +58,36 @@
         DataReader<XMLStreamReader> dr = getDataReader(message);
         List<Object> parameters = new ArrayList<Object>();
 
+        List<MessagePartInfo> piList = null;
+        if (operation != null) {
+            piList = operation.getOperationInfo().getInput().getMessageParts();
+        }
+        int seq = 1;
         while (StaxUtils.toNextElement(xmlReader)) {
-            Object o = dr.read(xmlReader);
-            
-            parameters.add(o);
+            QName streamParaQName = new QName(xmlReader.getNamespaceURI(), xmlReader.getLocalName());
+            Object o = null;
+            if (piList != null) {                
+                for (MessagePartInfo mpi : piList) {
+                    QName paraQName = null;
+                    if (mpi.isElement()) {
+                        paraQName = mpi.getElementQName();
+                    } else {
+                        paraQName = mpi.getTypeQName();
+                    }
+                    if (streamParaQName.equals(paraQName)) {
+                        o = dr.read(paraQName, xmlReader);
+                        break;
+                    }
+                }
+            } else {
+                o = dr.read(xmlReader);
+            }
+            if (o != null) {
+                parameters.add(o);
+                seq++;
+            } else {
+                throw new RuntimeException("Can't unmarshall parameter No." + seq);
+            }
         }
 
         Endpoint ep = exchange.get(Endpoint.class);
@@ -69,16 +96,13 @@
         if (message.get(Element.class) != null) {
             parameters.addAll(abstractParamsFromHeader(message.get(Element.class), ep, message));
         }
-        
+
         if (operation == null) {
-            
-            // If we didn't know the operation going into this, lets try to figure
+            // If we didn't know the operation going into this, lets try to
+            // figure
             // it out
-            
             OperationInfo op = findOperation(service.getServiceInfo().getInterface().getOperations(),
-                                             parameters, isRequestor(message));
-            
-
+                            parameters, isRequestor(message));
             for (BindingOperationInfo bop : ep.getEndpointInfo().getBinding().getOperations())
{
                 if (bop.getOperationInfo().equals(op)) {
                     operation = bop;
@@ -88,56 +112,52 @@
                 }
             }
         }
-        
-        
-        
+
         List<Object> newParameters = new ArrayList<Object>();
         for (Iterator iter = parameters.iterator(); iter.hasNext();) {
-            Object element = (Object)iter.next();
+            Object element = (Object) iter.next();
             if (element instanceof JAXBElement) {
-                element = ((JAXBElement)element).getValue();
+                element = ((JAXBElement) element).getValue();
             }
             newParameters.add(element);
-            
+
         }
-       
+
         message.setContent(List.class, newParameters);
     }
-    
-    private List<Object> abstractParamsFromHeader(Element headerElement, Endpoint ep,
 
-                                                  Message message) {
- 
+
+    private List<Object> abstractParamsFromHeader(Element headerElement, Endpoint ep,
Message message) {
+
         List<Object> paramInHeader = new ArrayList<Object>();
         List<MessagePartInfo> parts = null;
         for (BindingOperationInfo bop : ep.getEndpointInfo().getBinding().getOperations())
{
-           
+
             if (isRequestor(message)) {
                 parts = bop.getOutput().getMessageInfo().getMessageParts();
             } else {
                 parts = bop.getInput().getMessageInfo().getMessageParts();
             }
-                        
-            
+
             for (MessagePartInfo mpi : parts) {
                 if (mpi.isInSoapHeader()) {
                     NodeList nodeList = headerElement.getChildNodes();
                     if (nodeList != null) {
                         for (int i = 0; i < nodeList.getLength(); i++) {
                             if (nodeList.item(i).getNamespaceURI().equals(
-                                mpi.getElementQName().getNamespaceURI()) 
-                                && nodeList.item(i).getLocalName().equals(
-                                    mpi.getElementQName().getLocalPart())) {
-                                Element param = (Element)nodeList.item(i);
+                                            mpi.getElementQName().getNamespaceURI())
+                                            && nodeList.item(i).getLocalName().equals(
+                                                            mpi.getElementQName().getLocalPart()))
{
+                                Element param = (Element) nodeList.item(i);
                                 paramInHeader.add(getNodeDataReader(message).read(param));
                             }
                         }
-                        
+
                     }
-                    
+
                 }
             }
         }
-                            
+
         return paramInHeader;
     }
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?view=diff&rev=440293&r1=440292&r2=440293
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
Tue Sep  5 01:23:04 2006
@@ -267,6 +267,10 @@
     private void handleHeader(BindingMessageInfo bindingMessageInfo) {
         //mark all message part which should be in header
         List<ExtensibilityElement> extensiblilityElement = bindingMessageInfo.getWSDL11Extensors();
+        //for non-soap binding, the extensiblilityElement could be null
+        if (extensiblilityElement == null) {
+            return;
+        }
         for (ExtensibilityElement element : extensiblilityElement) {
             LOG.info("the extensibility is " + element.getClass().getName());
             if (element instanceof SOAPHeader) {



Mime
View raw message