You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2006/12/08 21:28:07 UTC

svn commit: r484748 - in /webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing: MessageHeaders.java soap/Messages.properties soap/SimpleSoapClient.java soap/SoapClient.java

Author: danj
Date: Fri Dec  8 12:28:01 2006
New Revision: 484748

URL: http://svn.apache.org/viewvc?view=rev&rev=484748
Log:
Fix for MUSE-144 and MUSE-145

Modified:
    webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/MessageHeaders.java
    webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/Messages.properties
    webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java
    webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapClient.java

Modified: webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/MessageHeaders.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/MessageHeaders.java?view=diff&rev=484748&r1=484747&r2=484748
==============================================================================
--- webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/MessageHeaders.java (original)
+++ webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/MessageHeaders.java Fri Dec  8 12:28:01 2006
@@ -77,13 +77,8 @@
     /**
      * 
      * Creates a valid set of WS-A message headers from the given SOAP Header. 
-     * If the WS-A headers are using an old namespace, they are first converted 
-     * to use the most current namespace (WsaUtils.NAMESPACE_URI) before being 
-     * processed to maximize interoperability.
-     * <br><br>
-     * The wsa:To URI is transformed into an EPR. If there are non-WS-A 
-     * headers in the SOAP Header, these are tranformed into reference 
-     * properties for the wsa:To EPR.
+     * The wsa:To URI and reference parameter elements become an EPR; this 
+     * EPR can be used to determine which WS-resource is being targeted. 
      * <br><br>
      * An appropriate set of reply headers can be generated with the 
      * createReplyHeaders(URI) and createFaultHeaders() methods, assuming the 

Modified: webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/Messages.properties?view=diff&rev=484748&r1=484747&r2=484748
==============================================================================
--- webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/Messages.properties Fri Dec  8 12:28:01 2006
@@ -1,5 +1,6 @@
-#Wed Aug 16 21:49:58 EDT 2006
-NullActionURI=The WS-A Action URI (wsa\:Action) is null.
-InvalidPort=Port numbers must be positive integers between 0 and 65535. You provided XXX.
-NullTraceWriter=The PrintWriter for tracing is null. If you want to stop tracing, call setTrace(false). If you need to close the PrintWriter and don't have a reference to it, you can call getTraceWriter().
-NullDestinationEPR=The destination EPR is null.
+NullDestinationEPR = The destination EPR is null.
+NullActionURI = The WS-A Action URI (wsa:Action) is null.
+NullSOAPBody = The array of SOAP Body elements is null.
+NullTraceWriter = The PrintWriter for tracing is null. If you want to stop tracing, call setTrace(false). If you need to close the PrintWriter and don't have a reference to it, you can call getTraceWriter().
+InvalidPort = Port numbers must be positive integers between 0 and 65535. You provided XXX.
+DuplicateAddressingHeader = The SOAP header element 'XXX' has the WS-Addressing namespace 'XXX'. SOAP headers added via SoapClient.send() must be outside of the WS-Addressing namespace to avoid conflicts with the data in the WS-A endpoint references.

Modified: webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java?view=diff&rev=484748&r1=484747&r2=484748
==============================================================================
--- webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java (original)
+++ webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java Fri Dec  8 12:28:01 2006
@@ -31,6 +31,7 @@
 import org.apache.muse.util.xml.XmlUtils;
 import org.apache.muse.ws.addressing.EndpointReference;
 import org.apache.muse.ws.addressing.MessageHeaders;
+import org.apache.muse.ws.addressing.WsaConstants;
 import org.apache.muse.ws.addressing.soap.SoapClient;
 
 /**
@@ -50,10 +51,9 @@
     //
     // Used to lookup all exception messages
     //
-    private static Messages _MESSAGES = 
-        MessagesFactory.get(SimpleSoapClient.class);
+    private static Messages _MESSAGES = MessagesFactory.get(SimpleSoapClient.class);
     
-    private static final Element[] _EMPTY_BODY = new Element[0];
+    private static final Element[] _EMPTY_ARRAY = new Element[0];
     
     //
     // Set to 0...65535 if TCP/SOAP monitor is in use
@@ -74,12 +74,15 @@
      * 
      * Creates a valid SOAP message, including WS-A headers that specify 
      * the destination and operation (action). The WS-A headers include 
-     * proper return/fault information for the recipient to use in response.
+     * proper return/fault information for the recipient to use in response. 
+     * The 'extra headers' are SOAP header elements that do not belong to 
+     * the WS-A namespace.
      * 
      * @param source
      * @param destination
      * @param action
      * @param bodyElements
+     * @param extraHeaders
      * 
      * @return A valid SOAP message that can be sent to the destination.
      *
@@ -87,7 +90,8 @@
     protected Element createMessage(EndpointReference source, 
                                     EndpointReference destination, 
                                     String action, 
-                                    Element[] bodyElements)
+                                    Element[] bodyElements, 
+                                    Element[] extraHeaders)
     {
         Document doc = XmlUtils.createDocument();
         Element soapXML = XmlUtils.createElement(doc, SoapConstants.ENVELOPE_QNAME);
@@ -107,6 +111,21 @@
         soapXML.appendChild(headersXML);
         
         //
+        // add all of the non-WS-A SOAP headers
+        //
+        for (int n = 0; n < extraHeaders.length; ++n)
+        {
+            if (extraHeaders[n].getNamespaceURI().equals(WsaConstants.NAMESPACE_URI))
+            {
+                Object[] filler = { XmlUtils.getElementQName(extraHeaders[n]), WsaConstants.NAMESPACE_URI };
+                throw new RuntimeException(_MESSAGES.get("DuplicateAddressingHeader", filler));
+            }
+            
+            extraHeaders[n] = (Element)doc.importNode(extraHeaders[n], true);
+            headersXML.appendChild(extraHeaders[n]);
+        }
+        
+        //
         // copy data into SOAP body
         //
         Element bodyXML = XmlUtils.createElement(doc, SoapConstants.BODY_QNAME);
@@ -114,9 +133,7 @@
         
         for (int n = 0; n < bodyElements.length; ++n)
         {
-            if (bodyElements[n].getOwnerDocument() != doc)
-                bodyElements[n] = (Element)doc.importNode(bodyElements[n], true);
-            
+            bodyElements[n] = (Element)doc.importNode(bodyElements[n], true);
             bodyXML.appendChild(bodyElements[n]);
         }
         
@@ -198,6 +215,15 @@
                           String wsaAction, 
                           Element[] body)
     {
+        return send(src, dest, wsaAction, body, _EMPTY_ARRAY);
+    }
+    
+    public Element[] send(EndpointReference src, 
+                          EndpointReference dest,
+                          String wsaAction, 
+                          Element[] body, 
+                          Element[] extraHeaders)
+    {
         if (dest == null)
             throw new NullPointerException(_MESSAGES.get("NullDestinationEPR"));
 
@@ -205,12 +231,15 @@
             throw new NullPointerException(_MESSAGES.get("NullActionURI"));
 
         if (body == null)
-            body = _EMPTY_BODY;
+            body = _EMPTY_ARRAY;
+        
+        if (extraHeaders == null)
+            extraHeaders = _EMPTY_ARRAY;
         
         //
         // create the request message and turn it into bytes
         //
-        Element soapRequest = createMessage(src, dest, wsaAction, body);
+        Element soapRequest = createMessage(src, dest, wsaAction, body, extraHeaders);
         byte[] soapBytes = XmlUtils.toString(soapRequest).getBytes();
         
         if (isUsingTrace())

Modified: webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapClient.java?view=diff&rev=484748&r1=484747&r2=484748
==============================================================================
--- webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapClient.java (original)
+++ webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapClient.java Fri Dec  8 12:28:01 2006
@@ -62,4 +62,37 @@
      *
      */
     Element[] send(EndpointReference src, EndpointReference dest, String wsaAction, Element[] body);
+
+    /**
+     * 
+     * Sends a SOAP envelope with the given body to the given destination. 
+     * The SOAP header will include WS-A headers, one of which will be the 
+     * WS-A Action specified in the third parameter. This method is not 
+     * asynchronous - it will wait for a response and return the contents 
+     * of the SOAP body.
+     *
+     * @param src
+     *        The EPR of the service sending the message.
+     * 
+     * @param dest
+     *        The EPR of the service that will receive the message.
+     * 
+     * @param wsaAction
+     *        The WS-A Action that specifies the operation to be invoked on 
+     *        the destination service.
+     * 
+     * @param body
+     *        The contents of the SOAP body.
+     *        
+     * @param extraHeaders
+     *        SOAP header elements that should be added to the outgoing message. 
+     *        These headers <b>must not</b> use the WS-Addressing namespace.
+     * 
+     * @return The contents of the SOAP body in the response message. If 
+     *         the request resulted in a fault, the contents will include 
+     *         the fault XML. Note that such faults are not related to 
+     *         basic networking/SOAP faults.
+     *
+     */
+    Element[] send(EndpointReference src, EndpointReference dest, String wsaAction, Element[] body, Element[] extraHeaders);
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org