You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2007/04/25 13:35:57 UTC

svn commit: r532323 - in /webservices/synapse/trunk/java: modules/core/src/main/java/org/apache/synapse/core/axis2/ modules/nhttp/src/org/apache/axis2/transport/nhttp/ repository/conf/sample/ src/site/resources/

Author: asankha
Date: Wed Apr 25 04:35:55 2007
New Revision: 532323

URL: http://svn.apache.org/viewvc?view=rev&rev=532323
Log:
Workaround for https://issues.apache.org/jira/browse/WSCOMMONS-197
Workaround to overcome issue where responses of content type text/xml without a SOAPAction are assumed to be REST
Fix Rampart breakage and fix sample 50 and 102, 103

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
    webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java
    webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_102.xml
    webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_103.xml
    webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml
    webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java?view=diff&rev=532323&r1=532322&r2=532323
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java Wed Apr 25 04:35:55 2007
@@ -26,9 +26,11 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.addressing.AddressingConstants;
@@ -53,6 +55,7 @@
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.statistics.impl.EndPointStatisticsStack;
 import org.apache.synapse.endpoints.utils.EndpointDefinition;
+import org.apache.rampart.handler.WSSHandlerConstants;
 
 /**
  * This is a simple client that handles both in only and in out
@@ -200,6 +203,12 @@
                 clientOptions.setProperty(
                     org.apache.synapse.config.xml.Constants.RAMPART_POLICY,
                     getPolicy(synapseOutMessageContext, wsSecPolicyKey));
+            }
+            // temporary workaround for https://issues.apache.org/jira/browse/WSCOMMONS-197
+            if (axisOutMsgCtx.getEnvelope().getHeader() == null) {
+                SOAPFactory fac = axisOutMsgCtx.isSOAP11() ?
+                    OMAbstractFactory.getSOAP11Factory() : OMAbstractFactory.getSOAP12Factory();
+                fac.createSOAPHeader(axisOutMsgCtx.getEnvelope());
             }
         }
         OperationClient mepClient = axisAnonymousOperation.createClient(

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java?view=diff&rev=532323&r1=532322&r2=532323
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java Wed Apr 25 04:35:55 2007
@@ -29,6 +29,11 @@
 import org.apache.synapse.endpoints.utils.EndpointDefinition;
 import org.apache.synapse.statistics.StatisticsUtils;
 import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.rampart.handler.WSSHandlerConstants;
 
 /**
  * This class helps the Axis2SynapseEnvironment implement the send method
@@ -72,6 +77,14 @@
             }
             Axis2FlexibleMEPClient.removeAddressingHeaders(messageContext);
             messageContext.setMessageID(UUIDGenerator.getUUID());
+
+            // temporary workaround for https://issues.apache.org/jira/browse/WSCOMMONS-197
+            if (messageContext.isEngaged(WSSHandlerConstants.SECURITY_MODULE_NAME) &&
+                messageContext.getEnvelope().getHeader() == null) {
+                SOAPFactory fac = messageContext.isSOAP11() ?
+                    OMAbstractFactory.getSOAP11Factory() : OMAbstractFactory.getSOAP12Factory();
+                fac.createSOAPHeader(messageContext.getEnvelope());
+            }
             ae.send(messageContext);
 
         } catch (AxisFault e) {

Modified: webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java?view=diff&rev=532323&r1=532322&r2=532323
==============================================================================
--- webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java (original)
+++ webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java Wed Apr 25 04:35:55 2007
@@ -131,10 +131,16 @@
                 responseMsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
                     MessageContext.DEFAULT_CHAR_SET_ENCODING);
             }
+            // workaround for Axis2 TransportUtils.createSOAPMessage() issue, where a response
+            // of content type "text/xml" is thought to be REST if !MC.isServerSide(). This
+            // question is still under debate and due to the timelines, I am commiting this
+            // workaround as Axis2 1.2 is about to be released and Synapse 1.0
+            responseMsgCtx.setServerSide(false);
             envelope = TransportUtils.createSOAPMessage(
                 responseMsgCtx,
                 in,
                 contentType);
+            responseMsgCtx.setServerSide(true);
             responseMsgCtx.setEnvelope(envelope);
 
         } catch (AxisFault af) {

Modified: webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_102.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_102.xml?view=diff&rev=532323&r1=532322&r2=532323
==============================================================================
--- webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_102.xml (original)
+++ webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_102.xml Wed Apr 25 04:35:55 2007
@@ -21,7 +21,7 @@
     <proxy name="StockQuoteProxy" transports="https">
         <target>
             <endpoint>
-                <address uri="http://localhost:9001/soap/SimpleStockQuoteService" format="pox"/>
+                <address uri="http://localhost:9000/soap/SimpleStockQuoteService" format="pox"/>
             </endpoint>
 			<outSequence>
 				<send/>

Modified: webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_103.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_103.xml?view=diff&rev=532323&r1=532322&r2=532323
==============================================================================
--- webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_103.xml (original)
+++ webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_103.xml Wed Apr 25 04:35:55 2007
@@ -16,43 +16,26 @@
   ~  specific language governing permissions and limitations
   ~  under the License.
   -->
-
-<definitions xmlns="http://ws.apache.org/ns/synapse">
 <!-- attaching service level WS-Security policies to proxy services -->
-
-        <localEntry key="proxy_wsdl"
-                      src="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
-        <localEntry key="sec_policy"
-                      src="file:repository/conf/sample/resources/policy/policy_3.xml"/>
-        <proxy name="StockQuoteProxy">
-            <target>
-                <inSequence>
-                    <header name="wsse:Security" action="remove"
-                            xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
-                    <send>
-                        <endpoint>
-                            <address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
-                        </endpoint>
-                    </send>
-                </inSequence>
-            </target>
-            <publishWSDL key="proxy_wsdl"/>
-            <policy key="sec_policy"/>
-            <enableSec/>
-        </proxy>
-
-        <in>
-            <header name="wsse:Security" action="remove"
-                    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
-            <send>
-                <endpoint>
-                    <address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
-                </endpoint>
-            </send>
-        </in>
-        <out>
-            <send/>
-        </out>
-
-
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+    <localEntry key="sec_policy" src="file:repository/conf/sample/resources/policy/policy_3.xml"/>
+    <proxy name="StockQuoteProxy">
+        <target>
+            <inSequence>
+                <header name="wsse:Security" action="remove"
+                        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
+                <send>
+                    <endpoint>
+                        <address uri="http://localhost:9001/soap/SimpleStockQuoteService"/>
+                    </endpoint>
+                </send>
+            </inSequence>
+			<outSequence>
+				<send/>
+			</outSequence>
+        </target>
+        <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
+        <policy key="sec_policy"/>
+        <enableSec/>
+    </proxy>
 </definitions>

Modified: webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml?view=diff&rev=532323&r1=532322&r2=532323
==============================================================================
--- webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml (original)
+++ webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml Wed Apr 25 04:35:55 2007
@@ -16,22 +16,18 @@
   ~  specific language governing permissions and limitations
   ~  under the License.
   -->
-
+<!-- Connecting to endpoints with WS-Security for outgoing messages -->
 <definitions xmlns="http://ws.apache.org/ns/synapse">
-
-    <!-- Connecting to endpoints with WS-Security for outgoing messages -->
     <localEntry key="sec_policy" src="file:repository/conf/sample/resources/policy/policy_3.xml"/>
 
-    <endpoint name="secure">
-        <address uri="http://localhost:9000/soap/SecureStockQuoteService3">
-            <enableSec policy="sec_policy"/>
-            <enableAddressing/>
-        </address>
-    </endpoint>
-
-    <in>
+	<in>
         <send>
-            <endpoint key="secure"/>
+			<endpoint name="secure">
+			    <address uri="http://localhost:9001/soap/SecureStockQuoteService">
+			        <enableSec policy="sec_policy"/>
+			        <enableAddressing/>
+			    </address>
+			</endpoint>
         </send>
     </in>
     <out>
@@ -39,5 +35,4 @@
                 xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
         <send/>
     </out>
-
 </definitions>

Modified: webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html?view=diff&rev=532323&r1=532322&r2=532323
==============================================================================
--- webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html (original)
+++ webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html Wed Apr 25 04:35:55 2007
@@ -1202,7 +1202,7 @@
     &lt;proxy name="StockQuoteProxy" transports="https"&gt;
         &lt;target&gt;
             &lt;endpoint&gt;
-                &lt;address uri="http://localhost:9001/soap/SimpleStockQuoteService" format="pox"/&gt;
+                &lt;address uri="http://localhost:9000/soap/SimpleStockQuoteService" format="pox"/&gt;
             &lt;/endpoint&gt;
             &lt;outSequence&gt;
                 &lt;send/&gt;
@@ -1233,11 +1233,12 @@
 
 <p></p>
 
-<p>Accessing this over https causes the proxy service to access the
-SimpleStockQuoteService on the sample Axis2 server using REST/POX. This could
-be seen if the message exchange was captured using TCPMon as follows. The
-REST/POX response is now transformed back into a SOAP message and returned to
-the client.</p>
+<p>Accessing this over https (ant stockquote
+-Dtrpurl=http://asankha:8080/soap/StockQuoteProxy) causes the proxy service
+to access the SimpleStockQuoteService on the sample Axis2 server using
+REST/POX. This could be seen if the message exchange was captured using
+TCPMon as follows. The REST/POX response is now transformed back into a SOAP
+message and returned to the client.</p>
 <pre>POST http://localhost:9001/soap/SimpleStockQuoteService HTTP/1.1
 Host: 127.0.0.1
 SOAPAction: urn:getQuote



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