cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r545220 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/service/model/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/core/src/main/java/org/apache/cxf/binding/ rt/core/src/main/java/org/apache/cxf/wsdl11/ tools/...
Date Thu, 07 Jun 2007 15:44:42 GMT
Author: jliu
Date: Thu Jun  7 08:44:41 2007
New Revision: 545220

URL: http://svn.apache.org/viewvc?view=rev&rev=545220
Log:
CXF-602: If a type that should be passed in the SOAP header is defined in its own message
rather than the request message, then CXF does not generate a parameter for that 
type in the interface.

Added:
    incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza.wsdl   (with
props)
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java?view=diff&rev=545220&r1=545219&r2=545220
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java Thu
Jun  7 08:44:41 2007
@@ -89,9 +89,17 @@
     }
     
     public Map<QName, MessageInfo> getMessages() {
-        if (messages != null) {
-            return messages;            
+        if (messages == null) {
+            initMessagesMap();           
         }
+        return messages;
+    }
+    
+    public MessageInfo getMessage(QName qname) {
+        return getMessages().get(qname);
+    }
+    
+    private void initMessagesMap() {
         messages = new ConcurrentHashMap<QName, MessageInfo>();
         for (OperationInfo operation : getInterface().getOperations()) {
             if (operation.getInput() != null) {
@@ -100,12 +108,18 @@
             if (operation.getOutput() != null) {
                 messages.put(operation.getOutput().getName(), operation.getOutput());
             }
-        }
-        return messages;
+        }       
     }
     
-    public MessageInfo getMessage(QName qname) {
-        return getMessages().get(qname);
+    public void setMessages(Map<QName, MessageInfo> msgs) {
+        messages = msgs;
+    }
+    
+    public void addMessage(MessageInfo msg) {
+        if (messages == null) {
+            initMessagesMap();           
+        }
+        messages.put(msg.getName(), msg);
     }
     
     public void addSchema(SchemaInfo schemaInfo) {

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?view=diff&rev=545220&r1=545219&r2=545220
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Thu Jun  7 08:44:41 2007
@@ -19,12 +19,16 @@
 
 package org.apache.cxf.binding.soap;
 
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+
 import javax.wsdl.BindingInput;
 import javax.wsdl.BindingOutput;
+import javax.wsdl.Definition;
+import javax.wsdl.Part;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.ExtensionRegistry;
@@ -82,7 +86,10 @@
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transport.MultipleEndpointObserver;
 import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.cxf.wsdl11.WSDLServiceBuilder;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
 
+import static org.apache.cxf.helpers.CastUtils.cast;
 
 public class SoapBindingFactory extends AbstractBindingFactory {
 
@@ -365,7 +372,43 @@
 
         return sb;
     }
+    
+    protected void addMessageFromBinding(ExtensibilityElement ext, ServiceInfo serviceInfo)
{
+        SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
+
+        if (header != null && serviceInfo.getMessage(header.getMessage()) == null)
{
+            Definition def = (Definition)serviceInfo.getProperty(WSDLServiceBuilder.WSDL_DEFINITION);
+            XmlSchemaCollection schemas = (XmlSchemaCollection)serviceInfo
+            .getProperty(WSDLServiceBuilder.WSDL_SCHEMA_LIST);
+            
+            if (def != null && schemas != null) {
+                javax.wsdl.Message msg = def.getMessage(header.getMessage());
 
+                MessageInfo minfo = new MessageInfo(null, msg.getQName());
+                buildMessage(minfo, msg, schemas);
+                
+                serviceInfo.addMessage(minfo);
+            }
+        }
+    }
+    
+    private void buildMessage(MessageInfo minfo, javax.wsdl.Message msg,
+                              XmlSchemaCollection schemas) {
+        for (Part part : cast(msg.getParts().values(), Part.class)) {
+            MessagePartInfo pi = minfo.addMessagePart(new QName(minfo.getName().getNamespaceURI(),
part
+                .getName()));
+            if (part.getTypeName() != null) {
+                pi.setTypeQName(part.getTypeName());
+                pi.setElement(false);
+                pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName()));
+            } else {
+                pi.setElementQName(part.getElementName());
+                pi.setElement(true);
+                pi.setXmlSchema(schemas.getElementByQName(part.getElementName()));
+            }
+        }
+    }
+   
     public BindingInfo createBindingInfo(ServiceInfo service, javax.wsdl.Binding binding,
String ns) {
         SoapBindingInfo bi = new SoapBindingInfo(service, ns);
         // Copy all the extensors
@@ -373,6 +416,7 @@
     
         SoapBinding wSoapBinding
             = SOAPBindingUtil.getSoapBinding(bi.getExtensors(ExtensibilityElement.class));
+       
         
         bi.setTransportURI(wSoapBinding.getTransportURI());
         bi.setStyle(wSoapBinding.getStyle());
@@ -383,6 +427,7 @@
     
         return bi;
     }
+    
     private void initializeBindingOperation(SoapBindingInfo bi, BindingOperationInfo boi)
{
         SoapOperationInfo soi = new SoapOperationInfo();
 

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java?view=diff&rev=545220&r1=545219&r2=545220
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java
Thu Jun  7 08:44:41 2007
@@ -100,7 +100,7 @@
 
     protected BindingInfo initializeBindingInfo(ServiceInfo service, Binding binding, BindingInfo
bi) {
         bi.setName(binding.getQName());
-        copyExtensors(bi, binding.getExtensibilityElements());
+        copyExtensors(bi, binding.getExtensibilityElements(), service);
 
         for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class))
{
             String inName = null;
@@ -122,30 +122,36 @@
                 }
             }
             if (bop2 != null) {
-                copyExtensors(bop2, bop.getExtensibilityElements());
+                copyExtensors(bop2, bop.getExtensibilityElements(), service);
                 if (bop.getBindingInput() != null) {
-                    copyExtensors(bop2.getInput(), bop.getBindingInput().getExtensibilityElements());
+                    copyExtensors(bop2.getInput(), bop.getBindingInput().getExtensibilityElements(),
service);
                 }
                 if (bop.getBindingOutput() != null) {
-                    copyExtensors(bop2.getOutput(), bop.getBindingOutput().getExtensibilityElements());
+                    copyExtensors(bop2.getOutput(), bop.getBindingOutput().getExtensibilityElements(),
+                                  service);
                 }
                 for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class))
{
                     copyExtensors(bop2.getFault(new QName(service.getTargetNamespace(), f.getName())),
-                                  bop.getBindingFault(f.getName()).getExtensibilityElements());
+                                  bop.getBindingFault(f.getName()).getExtensibilityElements(),
service);
                 }
             }
         }
         return bi;
     }
 
-    private void copyExtensors(AbstractPropertiesHolder info, List<?> extList) {
+    private void copyExtensors(AbstractPropertiesHolder info, List<?> extList, ServiceInfo
service) {
         if (info != null) {
             for (ExtensibilityElement ext : cast(extList, ExtensibilityElement.class)) {
                 info.addExtensor(ext);
+                addMessageFromBinding(ext, service);
             }
         }
     }
-
+    
+    protected void addMessageFromBinding(ExtensibilityElement ext, ServiceInfo serviceInfo)
{
+        
+    }
+    
     public void addListener(Destination d, Endpoint e) {
         ChainInitiationObserver observer = new ChainInitiationObserver(e, bus);
         

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=545220&r1=545219&r2=545220
==============================================================================
--- 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
Thu Jun  7 08:44:41 2007
@@ -241,7 +241,7 @@
                 service = new ServiceInfo();
                 service.setDescription(description);
                 description.getDescribed().add(service);
-                service.setProperty(WSDL_DEFINITION, def);
+                service.setProperty(WSDL_DEFINITION, def);               
                 service.setProperty(WSDL_SERVICE, serv);
 
                 XmlSchemaCollection schemas = getSchemas(def, service);

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java?view=diff&rev=545220&r1=545219&r2=545220
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
Thu Jun  7 08:44:41 2007
@@ -485,6 +485,7 @@
             // different message
             // other than messages used in porttype operation
             ParameterProcessor processor = new ParameterProcessor(context);
+           
             MessagePartInfo exPart = service.getMessage(soapHeader.getMessage())
                 .getMessagePart(new QName(soapHeader.getMessage().getNamespaceURI(),
                                           soapHeader.getPart()));

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?view=diff&rev=545220&r1=545219&r2=545220
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Thu Jun  7 08:44:41 2007
@@ -78,7 +78,68 @@
         processor = null;
         env = null;
     }
+    
+    @Test
+    public void testHeaderFromAnotherNamespace() throws Exception {
 
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/pizza.wsdl"));
+        env.put(ToolConstants.CFG_EXTRA_SOAPHEADER, "TRUE");
+        processor.setContext(env);
+        processor.execute();
+
+        assertNotNull(output);
+
+        Class clz = classLoader.loadClass("com.mypizzaco.pizza.PizzaPortType");      
+        
+        Method meths[] = clz.getMethods();
+        for (Method m : meths) {
+            if ("orderPizzaBroken".equals(m.getName())) {
+                Annotation annotations[][] = m.getParameterAnnotations();
+                assertEquals(2, annotations.length);
+                for (int i = 0; i < 2; i++) {
+                    assertTrue(annotations[i][0] instanceof WebParam);
+                    WebParam parm = (WebParam)annotations[i][0];
+                    if ("OrderPizza".equals(parm.name())) {
+                        assertEquals("http://mypizzaco.com/pizza/types", parm.targetNamespace());
+                        assertEquals("OrderPizza", parm.name());
+                        assertTrue(!parm.header());                       
+                    } else if ("CallerIDHeader".equals(parm.name())) {
+                        assertEquals("http://mypizzaco.com/pizza/types", parm.targetNamespace());
+                        assertEquals("callerID", parm.partName());
+                        assertEquals("CallerIDHeader", parm.name());
+                        assertTrue(parm.header());                       
+                    } else {
+                        fail("No WebParam found!");
+                    }
+                }
+           
+            }
+            if ("orderPizza".equals(m.getName())) {
+                Annotation annotations[][] = m.getParameterAnnotations();
+                assertEquals(2, annotations.length);
+                for (int i = 0; i < 2; i++) {
+                    assertTrue(annotations[i][0] instanceof WebParam);
+                    WebParam parm = (WebParam)annotations[i][0];
+                    if ("OrderPizza".equals(parm.name())) {
+                        assertEquals("http://mypizzaco.com/pizza/types", parm.targetNamespace());
+                        assertEquals("OrderPizza", parm.name());
+                        assertTrue(!parm.header());                       
+                    } else if ("CallerIDHeader".equals(parm.name())) {
+                        assertEquals("http://mypizzaco.com/pizza/types", parm.targetNamespace());
+                        assertEquals("callerID", parm.partName());
+                        assertEquals("CallerIDHeader", parm.name());
+                        assertTrue(parm.header());                       
+                    } else {
+                        fail("No WebParam found!");
+                    }
+                }
+           
+            } 
+        }
+
+
+    }
+    
     @Test
     public void testRPCLit() throws Exception {
 

Added: incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza.wsdl?view=auto&rev=545220
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza.wsdl (added)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza.wsdl Thu
Jun  7 08:44:41 2007
@@ -0,0 +1,109 @@
+<?xml version="1.0" ?>
+<wsdl:definitions 
+        name="PizzaService"
+        targetNamespace="http://mypizzaco.com/pizza"
+        xmlns:tns="http://mypizzaco.com/pizza"
+        xmlns:types="http://mypizzaco.com/pizza/types"
+        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+            
+  <wsdl:types>
+    <xsd:schema targetNamespace="http://mypizzaco.com/pizza/types"
+               xmlns:tns="http://mypizzaco.com/pizza/types"
+			   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+			   elementFormDefault="qualified"
+			   version="1.0">
+
+      <xsd:element name="CallerIDHeader" type="tns:CallerIDHeaderType" />
+	  
+      <xsd:complexType name="CallerIDHeaderType">
+        <xsd:sequence>
+          <xsd:element name="Name" type="xsd:string" />
+          <xsd:element name="PhoneNumber" type="xsd:string" />
+        </xsd:sequence>
+      </xsd:complexType>
+      
+	  <xsd:element name="OrderPizza" type="tns:OrderPizzaType" />
+	  
+      <xsd:complexType name="OrderPizzaType">
+        <xsd:sequence>
+          <xsd:element name="Toppings" type="tns:ToppingsListType" />
+        </xsd:sequence>
+      </xsd:complexType>
+	  
+      <xsd:element name="OrderPizzaResponse" type="tns:OrderPizzaResponseType" />
+
+      <xsd:complexType name="OrderPizzaResponseType">
+        <xsd:sequence>
+          <xsd:element name="MinutesUntilReady" type="xsd:int" /> 
+        </xsd:sequence>
+      </xsd:complexType>
+
+      <xsd:complexType name="ToppingsListType">
+        <xsd:sequence>
+          <xsd:element name="Topping" type="xsd:string" minOccurs="0" maxOccurs="unbounded"
/>
+        </xsd:sequence>
+      </xsd:complexType>
+
+    </xsd:schema>
+  </wsdl:types>
+
+  <wsdl:message name="CallerIDHeader">
+    <wsdl:part name="callerID" element="types:CallerIDHeader"/>
+  </wsdl:message>	
+  <wsdl:message name="OrderPizzaBrokenRequest">
+    <wsdl:part name="body" element="types:OrderPizza"/>
+  </wsdl:message>	
+  <wsdl:message name="OrderPizzaBrokenResponse">
+    <wsdl:part name="body" element="types:OrderPizzaResponse"/>
+  </wsdl:message>
+  <wsdl:message name="OrderPizzaRequest">
+    <wsdl:part name="body" element="types:OrderPizza"/>
+    <wsdl:part name="callerID" element="types:CallerIDHeader"/>
+  </wsdl:message>	
+  <wsdl:message name="OrderPizzaResponse">
+    <wsdl:part name="body" element="types:OrderPizzaResponse"/>
+  </wsdl:message>
+  	
+  <wsdl:portType name="PizzaPortType">
+    <wsdl:operation name="OrderPizzaBroken">
+      <wsdl:input message="tns:OrderPizzaBrokenRequest" />
+      <wsdl:output message="tns:OrderPizzaBrokenResponse" />
+    </wsdl:operation>
+    <wsdl:operation name="OrderPizza">
+      <wsdl:input message="tns:OrderPizzaRequest" />
+      <wsdl:output message="tns:OrderPizzaResponse" />
+    </wsdl:operation>
+  </wsdl:portType>
+  
+  <wsdl:binding name="PizzaPortBinding" type="tns:PizzaPortType">
+    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+    <wsdl:operation name="OrderPizzaBroken">
+      <soap:operation soapAction=""/>
+      <wsdl:input>
+        <soap:header message="tns:CallerIDHeader" part="callerID" use="literal" />
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="OrderPizza">
+      <soap:operation soapAction=""/>
+      <wsdl:input>
+        <soap:header message="tns:OrderPizzaRequest" part="callerID" use="literal" />
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  
+  <wsdl:service name="PizzaService">
+    <wsdl:port name="PizzaPort" binding="tns:PizzaPortBinding">
+      <soap:address location="http://localhost:8080/pizza_service/services/PizzaService"/>
+    </wsdl:port>
+  </wsdl:service>
+
+</wsdl:definitions>
\ No newline at end of file

Propchange: incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message