cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r677402 - in /cxf/branches/2.0.x-fixes: ./ api/src/main/java/org/apache/cxf/service/model/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/
Date Wed, 16 Jul 2008 20:04:19 GMT
Author: dkulp
Date: Wed Jul 16 13:04:19 2008
New Revision: 677402

URL: http://svn.apache.org/viewvc?rev=677402&view=rev
Log:
Merged revisions 677385 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r677385 | dkulp | 2008-07-16 15:23:05 -0400 (Wed, 16 Jul 2008) | 2 lines
  
  [CXF-1696] Fix problems occuring when a wsdl is used that has out of band headers using
the same part names as parts in the real message.
........

Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractMessageContainer.java
    cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/MessagePartInfo.java
    cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza_wrapped.wsdl

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 16 13:04:19 2008
@@ -1 +1 @@
-/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048
+/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractMessageContainer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractMessageContainer.java?rev=677402&r1=677401&r2=677402&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractMessageContainer.java
(original)
+++ cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/AbstractMessageContainer.java
Wed Jul 16 13:04:19 2008
@@ -33,6 +33,7 @@
     private OperationInfo operation;
     private Map<QName, MessagePartInfo> messageParts 
         = new LinkedHashMap<QName, MessagePartInfo>(4);
+    private List<MessagePartInfo> outOfBandParts;
     
     /**
      * Initializes a new instance of the <code>MessagePartContainer</code>.
@@ -103,6 +104,12 @@
             }
             i++;
         }
+        for (MessagePartInfo p : getOutOfBandParts()) {
+            if (part == p) {
+                return i;
+            }
+            i++;
+        }
         return -1;
     }
 
@@ -112,6 +119,11 @@
                 return p;
             }
         }
+        for (MessagePartInfo p : getOutOfBandParts()) {
+            if (p.getIndex() == i) {
+                return p;
+            }
+        }
         return null;
     }
 
@@ -142,6 +154,12 @@
                 }
             }
         }
+        for (MessagePartInfo mpi2 : getOutOfBandParts()) {
+            if (name.equals(mpi2.getName())
+                || name.equals(mpi2.getConcreteName())) {
+                return mpi2;
+            }
+        }
         return mpi;
     }
     
@@ -155,7 +173,7 @@
         if (n == -1) {
             return null;
         }
-        for (MessagePartInfo mpi : messageParts.values()) {
+        for (MessagePartInfo mpi : getMessageParts()) {
             if (n == 0) {
                 return mpi;
             }
@@ -164,17 +182,42 @@
         return null;
     }    
     
+    
+    public MessagePartInfo addOutOfBandMessagePart(QName name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Invalid name [" + name + "]");
+        }
+
+        MessagePartInfo part = new MessagePartInfo(name, this);
+        if (outOfBandParts == null) {
+            outOfBandParts = new ArrayList<MessagePartInfo>(1);
+        }
+        part.setIndex(messageParts.size() + outOfBandParts.size());
+        outOfBandParts.add(part);
+        return part;
+    }
+
+    
+    
     /**
      * Returns all message parts for this message.
      *
      * @return all message parts.
      */
     public List<MessagePartInfo> getMessageParts() {
-        return Collections.unmodifiableList(new ArrayList<MessagePartInfo>(messageParts.values()));
+        List<MessagePartInfo> parts = new ArrayList<MessagePartInfo>(messageParts.values());
+        parts.addAll(getOutOfBandParts());
+        return Collections.unmodifiableList(parts);
+    }
+    public List<MessagePartInfo> getOutOfBandParts() {
+        if (outOfBandParts == null) {
+            return Collections.emptyList();
+        }
+        return Collections.unmodifiableList(outOfBandParts);
     }
     
     public int size() {
-        return messageParts.size();
+        return messageParts.size() + getOutOfBandParts().size();
     }
     
 

Modified: cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/MessagePartInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/MessagePartInfo.java?rev=677402&r1=677401&r2=677402&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/MessagePartInfo.java
(original)
+++ cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/MessagePartInfo.java
Wed Jul 16 13:04:19 2008
@@ -41,6 +41,10 @@
         mInfo = info;
         pname = n;
     }
+    
+    public void setMessageContainer(AbstractMessageContainer info) {
+        mInfo = info;
+    }
 
     /**
      * @return Returns the name.

Modified: cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=677402&r1=677401&r2=677402&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Wed Jul 16 13:04:19 2008
@@ -493,8 +493,13 @@
             if (StringUtils.isEmpty(partNameFilter)
                 || part.getName().equals(partNameFilter)) {
             
-                MessagePartInfo pi = minfo.addMessagePart(new QName(minfo.getName().getNamespaceURI(),
part
-                                                                    .getName()));
+                QName pqname = new QName(minfo.getName().getNamespaceURI(), part.getName());
+                MessagePartInfo pi = minfo.addOutOfBandMessagePart(pqname);
+                
+                if (!minfo.getName().equals(msg.getQName())) {
+                    pi.setMessageContainer(new MessageInfo(minfo.getOperation(), null, msg.getQName()));
+                }
+                
                 if (part.getTypeName() != null) {
                     pi.setTypeQName(part.getTypeName());
                     pi.setElement(false);
@@ -570,8 +575,19 @@
             for (SoapHeader header : headers) {
                 SoapHeaderInfo headerInfo = new SoapHeaderInfo();
                 headerInfo.setUse(header.getUse());
-                MessagePartInfo part = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
header
-                                .getPart()));
+                MessagePartInfo part = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),

+                                                                    header.getPart()));
+                if (part != null && header.getMessage() != null
+                    && !part.getMessageInfo().getName().equals(header.getMessage()))
{
+                    part = null;
+                    //out of band, let's find it
+                    for (MessagePartInfo mpi : msg.getOutOfBandParts()) {
+                        if (mpi.getName().getLocalPart().equals(header.getPart())
+                            && mpi.getMessageInfo().getName().equals(header.getMessage()))
{
+                            part = mpi;
+                        }
+                    }
+                }
                 if (part != null) {
                     headerInfo.setPart(part);
                     messageParts.remove(part);
@@ -602,54 +618,9 @@
             List<MessagePartInfo> bodyParts = new ArrayList<MessagePartInfo>();
             for (Iterator itr = parts.iterator(); itr.hasNext();) {
                 Object part = itr.next();
-                String partName = null;
                 if (part instanceof MIMEPart) {
                     MIMEPart mpart = (MIMEPart) part;
-                    if (mpart.getExtensibilityElements().size() < 1) {
-                        throw new RuntimeException("MIMEPart should at least contain one
element!");
-                    }
-                    for (Object content : mpart.getExtensibilityElements()) {
-                        if (content instanceof MIMEContent) {
-                            MIMEContent mc = (MIMEContent)content;
-                            partName = mc.getPart();
-
-                            if (attParts == null) {
-                                attParts = new LinkedList<MessagePartInfo>();
-                            }
-
-                            MessagePartInfo mpi =
-                                msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
-                                                             partName));
-                            mpi.setProperty(Message.CONTENT_TYPE, mc.getType());
-                            attParts.add(mpi);
-                            // Attachments shouldn't be part of the body message
-                            bmsg.getMessageParts().remove(mpi);
-                        } else if (SOAPBindingUtil.isSOAPBody(content)) {
-                            SoapBody sb = SOAPBindingUtil.getSoapBody(content);
-                            if (sb.getParts() != null && sb.getParts().size() ==
1) {
-                                partName = (String) sb.getParts().get(0);
-                            }
-
-                            // We can have a list of empty part names here.
-                            if (partName != null) {
-                                addSoapBodyPart(msg, bodyParts, partName);
-                            }
-                        } else if (SOAPBindingUtil.isSOAPHeader(content)) {
-                            SoapHeader header = SOAPBindingUtil.getSoapHeader(content);
-
-                            SoapHeaderInfo headerInfo = new SoapHeaderInfo();
-                            headerInfo.setUse(header.getUse());
-                            MessagePartInfo mpi =
-                                msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
header
-                                            .getPart()));
-                            if (mpi != null) {
-                                headerInfo.setPart(mpi);
-                                messageParts.remove(part);
-                                bmsg.getMessageParts().remove(mpi);
-                                bmsg.addExtensor(headerInfo);
-                            }
-                        }
-                    }
+                    attParts = handleMimePart(mpart, attParts, msg, bmsg, bodyParts, messageParts);
                 } else {
                     addSoapBodyPart(msg, bodyParts, (String)part);
                 }
@@ -662,6 +633,75 @@
 
         bmsg.addExtensor(bodyInfo);
     }
+    
+    private List<MessagePartInfo> handleMimePart(MIMEPart mpart, 
+                                                 List<MessagePartInfo> attParts,
+                                                 MessageInfo msg,
+                                                 BindingMessageInfo bmsg,
+                                                 List<MessagePartInfo> bodyParts,
+                                                 List<MessagePartInfo> messageParts)
{
+        if (mpart.getExtensibilityElements().size() < 1) {
+            throw new RuntimeException("MIMEPart should at least contain one element!");
+        }
+        String partName = null;
+        for (Object content : mpart.getExtensibilityElements()) {
+            if (content instanceof MIMEContent) {
+                MIMEContent mc = (MIMEContent)content;
+                partName = mc.getPart();
+
+                if (attParts == null) {
+                    attParts = new LinkedList<MessagePartInfo>();
+                }
+
+                MessagePartInfo mpi =
+                    msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
+                                                 partName));
+                mpi.setProperty(Message.CONTENT_TYPE, mc.getType());
+                attParts.add(mpi);
+                // Attachments shouldn't be part of the body message
+                bmsg.getMessageParts().remove(mpi);
+            } else if (SOAPBindingUtil.isSOAPBody(content)) {
+                SoapBody sb = SOAPBindingUtil.getSoapBody(content);
+                if (sb.getParts() != null && sb.getParts().size() == 1) {
+                    partName = (String) sb.getParts().get(0);
+                }
+
+                // We can have a list of empty part names here.
+                if (partName != null) {
+                    addSoapBodyPart(msg, bodyParts, partName);
+                }
+            } else if (SOAPBindingUtil.isSOAPHeader(content)) {
+                SoapHeader header = SOAPBindingUtil.getSoapHeader(content);
+
+                SoapHeaderInfo headerInfo = new SoapHeaderInfo();
+                headerInfo.setUse(header.getUse());
+                MessagePartInfo mpi =
+                    msg.getMessagePart(new QName(msg.getName().getNamespaceURI(), header
+                                .getPart()));
+                
+                if (mpi != null && header.getMessage() != null
+                    && !mpi.getMessageInfo().getName().equals(header.getMessage()))
{
+                    mpi = null;
+                    //out of band, let's find it
+                    for (MessagePartInfo mpi2 : msg.getOutOfBandParts()) {
+                        if (mpi2.getName().getLocalPart().equals(header.getPart())
+                            && mpi2.getMessageInfo().getName().equals(header.getMessage()))
{
+                            mpi = mpi2;
+                        }
+                    }
+                }
+
+                if (mpi != null) {
+                    headerInfo.setPart(mpi);
+                    messageParts.remove(mpart);
+                    bmsg.getMessageParts().remove(mpi);
+                    bmsg.addExtensor(headerInfo);
+                }
+            }
+        }
+        return attParts;
+    }
+    
     private void addSoapBodyPart(MessageInfo msg, List<MessagePartInfo> bodyParts,
String partName) {
         MessagePartInfo mpi = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
                                                            partName));

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza_wrapped.wsdl
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza_wrapped.wsdl?rev=677402&r1=677401&r2=677402&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza_wrapped.wsdl
(original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/pizza_wrapped.wsdl
Wed Jul 16 13:04:19 2008
@@ -73,14 +73,14 @@
     </wsdl:portType>
 
     <wsdl:message name="CallerIDHeader">
-      <wsdl:part name="callerID" element="types:CallerIDHeader"/>
+      <wsdl:part name="parameters" element="types:CallerIDHeader"/>
     </wsdl:message>
 
     <wsdl:message name="OrderPizzaRequest">
-      <wsdl:part name="body" element="types:OrderPizza"/>
+      <wsdl:part name="parameters" element="types:OrderPizza"/>
     </wsdl:message>
     <wsdl:message name="OrderPizzaResponse">
-      <wsdl:part name="body" element="types:OrderPizzaResponse"/>
+      <wsdl:part name="parameters" element="types:OrderPizzaResponse"/>
     </wsdl:message>
 
   <wsdl:binding name="PizzaPortBinding" type="tns:Pizza">
@@ -88,7 +88,7 @@
     <wsdl:operation name="OrderPizza">
       <soap:operation soapAction=""/>
       <wsdl:input>
-        <soap:header message="tns:CallerIDHeader" part="callerID" use="literal" />
+        <soap:header message="tns:CallerIDHeader" part="parameters" use="literal" />
         <soap:body use="literal"/>
       </wsdl:input>
       <wsdl:output>



Mime
View raw message