cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r634510 - /incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java
Date Fri, 07 Mar 2008 03:25:49 GMT
Author: ffang
Date: Thu Mar  6 19:25:46 2008
New Revision: 634510

URL: http://svn.apache.org/viewvc?rev=634510&view=rev
Log:
[CXF-1468] JBIWrapperOutInterceptor miss message type attribute for JBI binding

Modified:
    incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java

Modified: incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java?rev=634510&r1=634509&r2=634510&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/jbi/src/main/java/org/apache/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java
Thu Mar  6 19:25:46 2008
@@ -22,6 +22,7 @@
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
+import javax.xml.XMLConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
@@ -33,6 +34,7 @@
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
 
@@ -58,7 +60,7 @@
             xmlWriter.writeStartElement(JBIConstants.NS_JBI_WRAPPER, 
                                         JBIConstants.JBI_WRAPPER_MESSAGE.getLocalPart());
             xmlWriter.writeNamespace("jbi", JBIConstants.NS_JBI_WRAPPER);
-            
+            setTypeAttr(xmlWriter, message);
             List<MessagePartInfo> parts = null;
             if (!isRequestor(message)) {
                 parts = bop.getOutput().getMessageParts();
@@ -98,5 +100,37 @@
             throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE),
e);
         }
     }
+    
+    private void setTypeAttr(XMLStreamWriter xmlWriter, Message message) throws XMLStreamException
{
+        BindingOperationInfo wsdlOperation = getOperation(message);
+        BindingMessageInfo wsdlMessage = isRequestor(message)
+            ? wsdlOperation.getInput() : wsdlOperation.getOutput();
+        
+        String typeNamespace = wsdlMessage.getMessageInfo().getName().getNamespaceURI();
+        if (typeNamespace == null || typeNamespace.length() == 0) {
+            throw new IllegalArgumentException("messageType namespace is null or empty");
+        }
+        xmlWriter.writeAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":" + "msg",
+                          typeNamespace);
+        String typeLocalName = wsdlMessage.getMessageInfo().getName().getLocalPart();
+        if (typeLocalName == null || typeLocalName.length() == 0) {
+            throw new IllegalArgumentException("messageType local name is null or empty");
+        }
+        xmlWriter.writeAttribute("type", "msg" + ":" + typeLocalName);
+        
+    }
+    
+    protected BindingOperationInfo getOperation(Message message) {
+        BindingOperationInfo operation = message.getExchange().get(BindingOperationInfo.class);
+        if (operation == null) {
+            throw new Fault(new Exception("Operation not bound on this message"));
+        }
+        return operation;
+    }
+    
+    protected boolean isRequestor(org.apache.cxf.message.Message message) {
+        return Boolean.TRUE.equals(message.containsKey(
+            org.apache.cxf.message.Message.REQUESTOR_ROLE));
+    }  
 
 }



Mime
View raw message