Author: asankha
Date: Wed Nov 22 05:12:30 2006
New Revision: 478157

URL: http://svn.apache.org/viewvc?view=rev&rev=478157
Log:
fix http://issues.apache.org/jira/browse/SYNAPSE-41 and ass documentation and a 
sample

Added:
    incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml
Modified:
    
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
    incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html

Modified: 
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java?view=diff&rev=478157&r1=478156&r2=478157
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
 (original)
+++ 
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
 Wed Nov 22 05:12:30 2006
@@ -31,6 +31,7 @@
 import org.apache.axis2.description.*;

 import org.apache.axis2.engine.AxisConfiguration;

 import org.apache.axis2.util.UUIDGenerator;

+import org.apache.axis2.util.Utils;

 import org.apache.axis2.wsdl.WSDLConstants;

 import org.apache.commons.logging.Log;

 import org.apache.commons.logging.LogFactory;

@@ -75,19 +76,19 @@
         boolean separateListener,

         org.apache.synapse.MessageContext synapseOutMessageContext) throws 
AxisFault {

 

-       log.debug("sending [add = "+wsAddressingEnabled+"] [sec = 
"+wsSecurityEnabled + "] [ rm = "+wsRMEnabled+"] [ to 
"+synapseOutMessageContext.getTo()+"]");

-       

-        MessageContext axisOutMsgCtx =

-            ((Axis2MessageContext) 
synapseOutMessageContext).getAxis2MessageContext();

-

-        Object addDisabled = axisOutMsgCtx.getProperty(

-            AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);

-        if (wsAddressingEnabled && addDisabled != null && 
Boolean.TRUE.equals(addDisabled)) {

+        log.debug("sending [add = "+wsAddressingEnabled+"] [sec = 
"+wsSecurityEnabled + "] [ rm = "+wsRMEnabled+"] [ to 
"+synapseOutMessageContext.getTo()+"]");

+

+        // save the original message context wihout altering it, so we can tie 
the response

+        MessageContext originalInMsgCtx = ((Axis2MessageContext) 
synapseOutMessageContext).getAxis2MessageContext();

+

+        // create a new MessageContext to be sent out as this should not 
corrupt the original

+        // we need to create the response to the original message later on

+        MessageContext axisOutMsgCtx = cloneForSend(originalInMsgCtx);

+

+        if (wsAddressingEnabled) {

             
axisOutMsgCtx.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
 Boolean.FALSE);

         }

 

-        TransportOutDescription savedTransportOut = 
axisOutMsgCtx.getTransportOut();

-

         ConfigurationContext axisCfgCtx = 
axisOutMsgCtx.getConfigurationContext();

         AxisConfiguration axisCfg       = axisCfgCtx.getAxisConfiguration();

 

@@ -98,16 +99,6 @@
             axisCfgCtx, (AxisServiceGroup) anoymousService.getParent());

         ServiceContext serviceCtx = sgc.getServiceContext(anoymousService);

 

-        if (axisOutMsgCtx.getMessageID() != null) {

-            axisOutMsgCtx.setMessageID(String.valueOf("uuid:" + 
UUIDGenerator.getUUID()));

-        }

-

-        
axisOutMsgCtx.setConfigurationContext(serviceCtx.getConfigurationContext());

-        axisOutMsgCtx.setServerSide(false); // this will become a client

-

-        // set SOAP envelope on the message context, removing WS-A headers

-        axisOutMsgCtx.setEnvelope(removeAddressingHeaders(axisOutMsgCtx));

-

         // get a reference to the DYNAMIC operation of the Anonymous Axis2 
service

         AxisOperation axisAnonymousOperation = anoymousService.getOperation(

             new QName(AnonymousServiceFactory.DYNAMIC_OPERATION));

@@ -137,8 +128,6 @@
                     getPolicy(synapseOutMessageContext, wsSecPolicyKey));

             }

         }

-        OperationContext originalOpCtx = axisOutMsgCtx.getOperationContext();

-        

         OperationClient mepClient = axisAnonymousOperation.createClient(

             serviceCtx, clientOptions);

         mepClient.addMessageContext(axisOutMsgCtx);

@@ -154,34 +143,39 @@
 

             mepClient.execute(true);

 

-            MessageContext response = mepClient.getMessageContext(

-                WSDLConstants.MESSAGE_LABEL_IN_VALUE);

+            MessageContext responseReceived =

+                
mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

 

-            response.setOperationContext(originalOpCtx);

-            response.setAxisMessage(

-                
originalOpCtx.getAxisOperation().getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));

+            MessageContext response = 
Utils.createOutMessageContext(originalInMsgCtx);

+            response.setEnvelope(removeAddressingHeaders(responseReceived));

 

-            // set properties on response

             response.setServerSide(true);

             response.setProperty(Constants.ISRESPONSE_PROPERTY, Boolean.TRUE);

-            response.setProperty(MessageContext.TRANSPORT_OUT,

-                axisOutMsgCtx.getProperty(MessageContext.TRANSPORT_OUT));

-            response.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO,

-                
axisOutMsgCtx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO));

-            response.setProperty(

-                    org.apache.synapse.Constants.PROCESSED_MUST_UNDERSTAND,

-                    axisOutMsgCtx.getProperty(

-                            
org.apache.synapse.Constants.PROCESSED_MUST_UNDERSTAND));

-            response.setTransportIn(axisOutMsgCtx.getTransportIn());

-            response.setTransportOut(savedTransportOut);

-

-            // If request is REST assume that the response is REST too

-            response.setDoingREST(axisOutMsgCtx.isDoingREST());

 

             return response;

         }

     }

 

+    private static MessageContext cloneForSend(MessageContext ori) throws 
AxisFault {

+        MessageContext newMC = new MessageContext();

+

+        // do not copy options from the original

+        newMC.setConfigurationContext(ori.getConfigurationContext());

+        newMC.setMessageID("uuid:" + UUIDGenerator.getUUID());

+        newMC.setTo(ori.getTo());

+

+        
newMC.setProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING,

+                
ori.getProperty(org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING));

+        

+        newMC.setDoingREST(ori.isDoingREST());

+        newMC.setDoingMTOM(ori.isDoingMTOM());

+        newMC.setServerSide(false);

+

+        // set SOAP envelope on the message context, removing WS-A headers

+        newMC.setEnvelope(removeAddressingHeaders(ori));

+        return newMC;

+    }

+    

     /**

      * Get the Policy object for the given name from the Synapse configuration 
at runtime

      * @param synCtx the current synapse configuration to get to the synapse 
configuration


Added: incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml?view=auto&rev=478157
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml 
(added)
+++ incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_50.xml 
Wed Nov 22 05:12:30 2006
@@ -0,0 +1,46 @@
+<!--

+  ~  Licensed to the Apache Software Foundation (ASF) under one

+  ~  or more contributor license agreements.  See the NOTICE file

+  ~  distributed with this work for additional information

+  ~  regarding copyright ownership.  The ASF licenses this file

+  ~  to you under the Apache License, Version 2.0 (the

+  ~  "License"); you may not use this file except in compliance

+  ~  with the License.  You may obtain a copy of the License at

+  ~

+  ~   http://www.apache.org/licenses/LICENSE-2.0

+  ~

+  ~  Unless required by applicable law or agreed to in writing,

+  ~  software distributed under the License is distributed on an

+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+  ~  KIND, either express or implied.  See the License for the

+  ~  specific language governing permissions and limitations

+  ~  under the License.

+  -->

+

+<synapse xmlns="http://ws.apache.org/ns/synapse";>

+

+    <!-- illustration of simple properties, and reusable endpoints and 
sequences -->

+    <definitions>

+               <set-property name="sec_policy" 
src="file:repository/conf/sample/resources/policy/policy_3.xml"/>

+               

+        <endpoint name="secure" 
address="http://localhost:9001/axis2/services/SecureStockQuoteService3";>

+               <enableSec policy="sec_policy"/>

+               <enableAddressing/>

+        </endpoint>

+    </definitions>

+

+    <rules>

+       <in>

+               <header name="To" 
value="http://localhost:9000/axis2/services/SecureStockQuoteService3"/>

+        <send>

+               <endpoint ref="secure"/>

+        </send>

+      </in>

+      <out>

+             <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/>

+      </out>

+    </rules>

+

+</synapse> 
\ No newline at end of file

Modified: incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html?view=diff&rev=478157&r1=478156&r2=478157
==============================================================================
--- incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html 
(original)
+++ incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html Wed 
Nov 22 05:12:30 2006
@@ -62,8 +62,6 @@
   <li>SimpleStockQuoteService1 - This has the same functionality as the
     SimpleStockQuoteService service, but exists to make available a different
     service instance/EPR to demonstrating routing</li>
-  <li>SimpleStockQuoteService2 - Same as the SimpleStockQuoteService2 (Refer
-    above)</li>
   <li>SecureStockQuoteService1 - Simple stock quote service using WS-Security
     with timestamps and username token authentication</li>
   <li>SecureStockQuoteService3 - Stock quote service using WS-Security
@@ -449,6 +447,42 @@
 detected so that changes could be reloaded without restarting the Synapse
 instance.</p>
 
+<p></p>
+
+<h2>Sample 50:</h2>
+
+<p><strong>Objective: Connecting to endpoints with WS-Security for outgoing
+messages</strong></p>
+
+<p><strong>Pre-Requisites:</strong><br>
+Download and copy the BouncyCastle JAR file into your Synapse lib directory.
+(Note: the exact JAR you need to install depends on your JDK - for JDK 1.4 I
+have used bcprov-jdk13-132.jar)<br>
+Start the Synapse configuration numbered 50: i.e. synapse -sample 50<br>
+Copy the Apache Rampart module (e.g. rampart-1.1-SNAPSHOT.mar) into the
+modules directory of the sample Axis2 server
+samples/axis2Server/repository/modules. The Rampart module could be found at
+repository\modules and is not duplicated within the distributions due to its
+large file size.<br>
+Start the Axis2 server and deploy the SecureStockQuoteService3 (Refer steps
+above)</p>
+
+<p></p>
+
+<p>Use the stock quote client to send a request without WS-Security. Synapse
+is configured to enable WS-Security policy 'policy_3.xml' to the outgoing
+message when sent to the SecureStockQuoteService3 service endpoint hosted on
+the Axis2 instance. The debug log messages on Synapse shows the encrypted
+message flowing to the service and the encrypted response being received by
+Synapse. The wsse:Security header is then removed from the decrypted message
+and the response is delivered back to the client as it expects.</p>
+
+<p></p>
+
+<p></p>
+
+<p></p>
+
 <h1>Proxy services</h1>
 
 <h2>Sample 100:</h2>
@@ -614,22 +648,26 @@
 Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps
 above)</p>
 
-<p>This configuration creates a proxy service with the name StockQuoteProxy. 
This proxy service
-specifies both inSequence and the outSequence for that service. This will add 
a proxy level out
-sequence to be used for the response message mediation of that particular 
proxy service. You could
-leave the whole target element not specified or one of the sequences of in and 
out unspecified,
-so that the corresponding message will be mediated using main mediator.</p>
-
-<p>You could send a stock quote request to this proxy services and receive the 
reply generated
-by the actual service hosted on the Axis2 instance. Use the -Durl=&lt;EPR&gt; 
property when
-executing the client as per example 100, to request on this proxy service.</p>
-
-<p>You can observe the synapse log to see the response message mediation using 
the specified
-outSequence, unlike using MainMediator in the sample 100 case. The log should 
be as follows
+<p>This configuration creates a proxy service with the name StockQuoteProxy.
+This proxy service specifies both inSequence and the outSequence for that
+service. This will add a proxy level out sequence to be used for the response
+message mediation of that particular proxy service. You could leave the whole
+target element not specified or one of the sequences of in and out
+unspecified, so that the corresponding message will be mediated using main
+mediator.</p>
+
+<p>You could send a stock quote request to this proxy services and receive
+the reply generated by the actual service hosted on the Axis2 instance. Use
+the -Durl=&lt;EPR&gt; property when executing the client as per example 100,
+to request on this proxy service.</p>
+
+<p>You can observe the synapse log to see the response message mediation
+using the specified outSequence, unlike using MainMediator in the sample 100
+case. The log should be as follows</p>
 <pre>DEBUG SequenceMediator - Sequence mediator &lt;proxy_out&gt; :: mediate()
 DEBUG AbstractListMediator - Implicit Sequence &lt;SequenceMediator&gt; :: 
mediate()
 DEBUG LogMediator - Log mediator :: mediate()
-INFO  LogMediator - message = Executing inside the out sequence</pre></p>
+INFO  LogMediator - message = Executing inside the out sequence</pre>
 
 <h2>Sample 110:</h2>
 
@@ -651,8 +689,9 @@
 the Axis2 documentation on setting up JMS for more details
 (http://ws.apache.org/axis2/1_1/jms-transport.html). You will also need to
 copy the ActiveMQ client jar files activeio-core-3.0-beta1.jar,
-activemq-core-4.0-RC2.jar, geronimo-jms_1.1_spec-1.0.jar and 
geronimo-j2ee-management_1.0_spec-1.0.jar into
-the lib directory to allow Synapse to connect to the JMS provider.</p>
+activemq-core-4.0-RC2.jar, geronimo-jms_1.1_spec-1.0.jar and
+geronimo-j2ee-management_1.0_spec-1.0.jar into the lib directory to allow
+Synapse to connect to the JMS provider.</p>
 
 <p>For a default ActiveMQ v4.0 installation, you may uncomment the Axis2
 transport listener configuration found at repository/conf/axis2.xml as</p>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to