You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ja...@apache.org on 2004/05/06 21:03:45 UTC
cvs commit: ws-fx/sandesha/src/org/apache/sandesha/ws/rm/handlers RMClientRequestHandler.java RMClientResponseHandler.java RMHandler.java RMServerRequestHandler.java
jaliya 2004/05/06 12:03:45
Modified: sandesha/src/org/apache/sandesha/ws/rm/handlers
RMClientRequestHandler.java
RMClientResponseHandler.java RMHandler.java
RMServerRequestHandler.java
Log:
Modified Code with Formatting
Revision Changes Path
1.6 +158 -177 ws-fx/sandesha/src/org/apache/sandesha/ws/rm/handlers/RMClientRequestHandler.java
Index: RMClientRequestHandler.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/ws/rm/handlers/RMClientRequestHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RMClientRequestHandler.java 4 May 2004 11:38:30 -0000 1.5
+++ RMClientRequestHandler.java 6 May 2004 19:03:45 -0000 1.6
@@ -17,191 +17,172 @@
package org.apache.sandesha.ws.rm.handlers;
-import org.apache.axis.AxisFault;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.Call;
-import org.apache.axis.message.SOAPEnvelope;
-import org.apache.sandesha.Constants;
-
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
+import org.apache.axis.AxisFault;
+import org.apache.axis.MessageContext;
+import org.apache.axis.client.Call;
+import org.apache.axis.message.SOAPEnvelope;
+import org.apache.sandesha.Constants;
+
/**
- * class RMClientRequestHandler
- *
- * @author Amila Navarathna
- * @author Jaliya Ekanayaka
- * @author Sudar Nimalan
+ * @author
+ * Amila Navarathna<br>
+ * Jaliya Ekanayaka<br>
+ * Sudar Nimalan<br>
+ * (Apache Sandesha Project)
+ *
*/
-public class RMClientRequestHandler extends RMHandler {
- /**
+
+public class RMClientRequestHandler extends RMHandler {
+
+ /**
* Method invoke
- *
- * @param messageContext
- * @throws AxisFault
- * @see org.apache.axis.Handler#invoke(org.apache.axis.MessageContext)
- */
- public void invoke(MessageContext messageContext) throws AxisFault {
-
- // Get the options from the client-config.wsdd.
- // Client should specify the URL of the client host and the port number of the Tomcat sever
- // e.g. http://127.2.5.3:8080
- String sourceURI = (String) getOption("sourceURI");
-
- // Directroy path is still not used.
- String dirPath = (String) getOption("dirPath");
-
- /*
- * Test the the values of the options.
- * System.out.println(sourceURI);
- * System.out.println(dirPath);
- */
-
- // Get the properties set by the client by accessing the call object using the message context.
- Call call = (Call) messageContext.getProperty(MessageContext.CALL);
-
- // Three parameters: sequenceIdentifier, isOneWay and isLastMessage.
- String sequenceID = null;
- if (call.getProperty(Constants.CLIENT_SEQUENCE_IDENTIFIER) != null) {
- sequenceID = (String) call.getProperty(Constants.CLIENT_SEQUENCE_IDENTIFIER);
- }
-
- boolean isOneWay = false;
- boolean isLastMessage = false;
- boolean isCreateSequence = false;
- boolean isResponseExpected = false;
-
- if (call.getProperty(Constants.CLIENT_ONE_WAY_INVOKE) != null) {
- isOneWay = ((Boolean) (call.getProperty(Constants.CLIENT_ONE_WAY_INVOKE))).booleanValue();
- }
- if (call.getProperty(Constants.CLIENT_LAST_MESSAGE) != null) {
- isLastMessage = ((Boolean) (call.getProperty(Constants.CLIENT_LAST_MESSAGE))).booleanValue();
- }
- if (call.getProperty(Constants.CLIENT_CREATE_SEQUENCE) != null) {
- isCreateSequence = ((Boolean) (call.getProperty(Constants.CLIENT_CREATE_SEQUENCE))).booleanValue();
- }
- if (call.getProperty(Constants.CLIENT_RESPONSE_EXPECTED) != null) {
- isResponseExpected = ((Boolean) (call.getProperty(Constants.CLIENT_RESPONSE_EXPECTED))).booleanValue();
- }
-
-
- // Get the SOAP envelop of the request message and send it as a string parameter to the
- // clientService
- SOAPEnvelope requestSOAPEnvelop =
- messageContext.getCurrentMessage().getSOAPEnvelope();
-
- requestSOAPEnvelop.setSchemaVersion(messageContext.getSchemaVersion());
- requestSOAPEnvelop.setSoapConstants(messageContext.getSOAPConstants());
-
- // Convert the SOAP envelop to string.
- String strRequestSOAPEnvelop = requestSOAPEnvelop.toString();
-
- // Get the destination URL from the message context.
- String destinationURL =
- (String) messageContext.getProperty(MessageContext.TRANS_URL);
-
- // System.out.println("destinationURL :" + destinationURL);
- // Set the destination URL of the message context to the
- String toClientServiceURL =
- sourceURI + org.apache.sandesha.Constants.AXIS_SERVICES
- + org.apache.sandesha.Constants.RM_CLIENT_SERVICE
- + org.apache.sandesha.Constants.QUESTION_WSDL;
-
- // System.out.println("sourceURI : " + sourceURI);
- String clientReferanceURL =
- sourceURI + org.apache.sandesha.Constants.AXIS_SERVICES
- + org.apache.sandesha.Constants.CLIENT_REFERANCE
- + org.apache.sandesha.Constants.QUESTION_WSDL;
-
- messageContext.setProperty(MessageContext.TRANS_URL,
- toClientServiceURL);
-
- try {
-
- // to the envelploe with CALL String
- SOAPEnvelope soapEnvelope =
- messageContext.getCurrentMessage().getSOAPEnvelope();
- SOAPBody soapBody = soapEnvelope.getBody();
-
- soapEnvelope.clearBody();
- soapEnvelope.removeHeaders();
-
- Name name = soapEnvelope.createName(org.apache.sandesha.Constants.CLIENT_METHOD, "ns1",
- org.apache.sandesha.Constants.RM_CLIENT_SERVICE);
- SOAPBodyElement soapBodyElement = soapBody.addBodyElement(name);
-
- // Add the SOAP envelop as a string parameter.
- SOAPElement soapElement = soapBodyElement.addChildElement("arg1",
- "");
-
- soapElement.addTextNode(strRequestSOAPEnvelop);
-
- // Add the sequenceIdnetifier
- soapElement = soapBodyElement.addChildElement("arg2", "");
-
- soapElement.addTextNode(sequenceID);
-
- // Add the destination URL
- soapElement = soapBodyElement.addChildElement("arg3", "");
-
- soapElement.addTextNode(destinationURL);
-
- // Add the toClientServiceURL. This can be used by the asynchronous server to reference the Client Service
- soapElement = soapBodyElement.addChildElement("arg4", "");
-
- soapElement.addTextNode(clientReferanceURL);
-
- // Add the isOneWay as a string value.
- soapElement = soapBodyElement.addChildElement("arg5", "");
-
- if (isOneWay == true) {
- soapElement.addTextNode("true");
- } else {
- soapElement.addTextNode("false");
- }
-
- // Add the isLastMessage as a string value
- soapElement = soapBodyElement.addChildElement("arg6", "");
-
- if (isLastMessage == true) {
- soapElement.addTextNode("true");
- } else {
- soapElement.addTextNode("false");
- }
-
- // Add the isCreateSequence as a string value
- soapElement = soapBodyElement.addChildElement("arg7", "");
-
- if (isCreateSequence == true) {
- soapElement.addTextNode("true");
- } else {
- soapElement.addTextNode("false");
- }
-
- // Add the isLastMessage as a string value
- soapElement = soapBodyElement.addChildElement("arg8", "");
-
- if (isResponseExpected == true) {
- soapElement.addTextNode("true");
- } else {
- soapElement.addTextNode("false");
- }
-
- // soapElement = soapBodyElement.addChildElement("arg5", "");
- // soapElement.addTextNode(dirPath);
- System.out.println("This is the end of the RMClientRequesthandler Following is the SOAP MEssage >>");
-
- // System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
- messageContext.getCurrentMessage().getSOAPEnvelope();
-
- // System.out.println( messageContext.getCurrentMessage().getSOAPEnvelope().toString());
- // System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
- } catch (SOAPException soapException) {
- throw AxisFault.makeFault(soapException);
- }
- }
+ *
+ * @param messageContext
+ * @throws AxisFault
+ * @see org.apache.axis.Handler#invoke(org.apache.axis.MessageContext)
+ */
+
+ public void invoke(MessageContext messageContext) throws AxisFault {
+
+ //Get the options from the client-config.wsdd.
+ //Client should specify the URL of the client host and the port number of the Tomcat sever
+
+ String sourceURI = (String) getOption("sourceURI");
+ String action = (String) getOption("action");
+ String replyTo = (String) getOption("replyTo");
+ String isSynchronized = (String) getOption("synchronized");
+
+ //Get the properties set by the client by accessing the call object using the message context.
+ Call call = (Call) messageContext.getProperty(MessageContext.CALL);
+
+ String sequenceID=null;// = call.getSequenceIdentifier();
+ if(call.getProperty(Constants.CLIENT_SEQUENCE_IDENTIFIER)!=null){
+ sequenceID=(String) call.getProperty(Constants.CLIENT_SEQUENCE_IDENTIFIER);
+ }else{
+ sequenceID="";
+ }
+
+ boolean isLastMessage = false;
+
+ boolean isResponseExpected = false;
+
+
+ if (call.getProperty(Constants.CLIENT_LAST_MESSAGE) != null) {
+ isLastMessage=((Boolean) (call.getProperty(Constants.CLIENT_LAST_MESSAGE))).booleanValue();
+ }
+
+ if (call.getProperty(Constants.CLIENT_RESPONSE_EXPECTED) != null) {
+ isResponseExpected=((Boolean) (call.getProperty(Constants.CLIENT_RESPONSE_EXPECTED))).booleanValue();
+ }
+
+ //Get the SOAP envelop of the request message and send it as a string parameter to the
+ //clientService
+ SOAPEnvelope requestSOAPEnvelop =
+ messageContext.getCurrentMessage().getSOAPEnvelope();
+ requestSOAPEnvelop.setSchemaVersion(messageContext.getSchemaVersion());
+ requestSOAPEnvelop.setSoapConstants(messageContext.getSOAPConstants());
+
+ //Convert the SOAP envelop to string.
+ String strRequestSOAPEnvelop = requestSOAPEnvelop.toString();
+
+ //Get the destination URL from the message context.
+ String destinationURL =
+ (String) messageContext.getProperty(MessageContext.TRANS_URL);
+
+ //Set the destination URL of the message context to the Client Endpoint Manager (Re-directing)
+ String toClientServiceURL =
+ sourceURI
+ + org.apache.sandesha.Constants.AXIS_SERVICES
+ + org.apache.sandesha.Constants.RM_CLIENT_SERVICE
+ + org.apache.sandesha.Constants.QUESTION_WSDL;
+
+ //Set the URL of the client side reference that can be used to send the asynchronous responses
+ //by the services.
+ String clientReferanceURL =
+ sourceURI
+ + org.apache.sandesha.Constants.AXIS_SERVICES
+ + org.apache.sandesha.Constants.CLIENT_REFERANCE
+ + org.apache.sandesha.Constants.QUESTION_WSDL;
+
+ messageContext.setProperty(
+ MessageContext.TRANS_URL,
+ toClientServiceURL);
+ try {
+ //to the envelploe with CALL String
+ SOAPEnvelope soapEnvelope =
+ messageContext.getCurrentMessage().getSOAPEnvelope();
+ SOAPBody soapBody = soapEnvelope.getBody();
+
+ soapEnvelope.clearBody();
+ soapEnvelope.removeHeaders();
+
+ Name name =
+ soapEnvelope.createName(
+ org.apache.sandesha.Constants.CLIENT_METHOD,
+ "ns1",
+ org.apache.sandesha.Constants.RM_CLIENT_SERVICE);
+ SOAPBodyElement soapBodyElement = soapBody.addBodyElement(name);
+
+ //Add the SOAP envelop as a string parameter.
+ SOAPElement soapElement =
+ soapBodyElement.addChildElement("arg1", "");
+ soapElement.addTextNode(strRequestSOAPEnvelop);
+
+ //Add the sequenceIdnetifier
+ soapElement = soapBodyElement.addChildElement("arg2", "");
+ soapElement.addTextNode(sequenceID);
+
+ //Add the destination URL
+ soapElement = soapBodyElement.addChildElement("arg3", "");
+ soapElement.addTextNode(destinationURL);
+
+ //Add the toClientServiceURL. This can be used by the asynchronous server to reference the Client Service
+ soapElement = soapBodyElement.addChildElement("arg4", "");
+ soapElement.addTextNode(clientReferanceURL);
+
+ //Add the isOneWay as a string value.
+ soapElement = soapBodyElement.addChildElement("arg5", "");
+ soapElement.addTextNode(isSynchronized);
+
+
+ //Add the isLastMessage as a string value
+ soapElement = soapBodyElement.addChildElement("arg6", "");
+ if (isLastMessage == true) {
+ soapElement.addTextNode("true");
+ } else {
+ soapElement.addTextNode("false");
+
+ //Add the isCreateSequence as a string value
+ }
+
+ soapElement = soapBodyElement.addChildElement("arg7", "");
+ if (isResponseExpected == true) {
+ soapElement.addTextNode("true");
+ } else {
+ soapElement.addTextNode("false");
+
+ }
+ soapElement = soapBodyElement.addChildElement("arg8", "");
+ soapElement.addTextNode(action);
+
+ String strReplyTo=replyTo+ org.apache.sandesha.Constants.AXIS_SERVICES
+ + org.apache.sandesha.Constants.CLIENT_REFERANCE
+ + org.apache.sandesha.Constants.QUESTION_WSDL;
+
+ soapElement = soapBodyElement.addChildElement("arg9", "");
+ soapElement.addTextNode(strReplyTo);
+
+ } catch (SOAPException soapException) {
+ throw AxisFault.makeFault(soapException);
+ }
+
+ }
+
}
1.6 +52 -55 ws-fx/sandesha/src/org/apache/sandesha/ws/rm/handlers/RMClientResponseHandler.java
Index: RMClientResponseHandler.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/ws/rm/handlers/RMClientResponseHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RMClientResponseHandler.java 2 May 2004 16:53:00 -0000 1.5
+++ RMClientResponseHandler.java 6 May 2004 19:03:45 -0000 1.6
@@ -14,107 +14,104 @@
* limitations under the License.
*
*/
+
package org.apache.sandesha.ws.rm.handlers;
+import java.util.Iterator;
+
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.message.MessageElement;
import org.apache.axis.message.SOAPEnvelope;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPBodyElement;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import java.util.Iterator;
/**
- * class RMClientResponseHandler
- *
- * @author Amila Navarathna
- * @author Jaliya Ekanayaka
- * @author Sudar Nimalan
+ * @author
+ * Amila Navarathna<br>
+ * Jaliya Ekanayaka<br>
+ * Sudar Nimalan<br>
+ * (Apache Sandesha Project)
+ *
*/
public class RMClientResponseHandler extends RMHandler {
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.apache.axis.Handler#invoke(org.apache.axis.MessageContext)
*/
-
- /**
- * Method invoke
- *
- * @param messageContext
- * @throws AxisFault
- */
+
+ /**
+ * Method invoke
+ *
+ * @param messageContext
+ * @throws AxisFault
+ */
+
public void invoke(MessageContext messageContext) throws AxisFault {
-
try {
-
- // System.out.println("WSRMClientResponseHandler");
- // //System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
- // System.out.println(messageContext.getCurrentMessage().getSOAPPartAsString());
- // messageContext.getCurrentMessage()
- SOAPEnvelope soapEnvelope =
- messageContext.getResponseMessage().getSOAPEnvelope();
+
+ SOAPEnvelope soapEnvelope = messageContext.getResponseMessage().
+ getSOAPEnvelope();
SOAPBody soapBody = soapEnvelope.getBody();
- // System.out.println("In the response handler" );
- // System.out.println(soapEnvelope.toString());
+
+
if (soapBody.getValue() == null) {
- System.out.println("This is what i get");
+
} else {
-
- // System.out.println("In the response handlerrrr" );
+
Iterator iterator = soapBody.getChildElements();
SOAPBodyElement soapBodyElement;
while (iterator.hasNext()) {
soapBodyElement = (SOAPBodyElement) iterator.next();
-
- // System.out.println(soapBodyElement.getLocalName());
- if (soapBodyElement.getLocalName().equals("clientMethodResponse")) {
-
- // System.out.println("clientMethodResponse");
+
+ if (soapBodyElement.getLocalName().equals(
+ "clientMethodResponse")) {
+
Iterator ite = soapBodyElement.getChildElements();
MessageElement sbe;
-
while (ite.hasNext()) {
sbe = (MessageElement) ite.next();
-
if (sbe.getName().equals("clientMethodReturn")) {
- messageContext.setCurrentMessage(new Message(sbe.getValue()));
- // System.out.println(sbe.getValue());
+ if (sbe.getValue() != null) {
+
+ messageContext.setCurrentMessage(new
+ Message(sbe.getValue()));
+
+
+ }
}
}
}
}
+
+ if (messageContext.getCurrentMessage().getSOAPEnvelope().
+ getBody().getFault() != null) {
- // if()
- if (messageContext.getCurrentMessage().getSOAPEnvelope().getBody().getFault()
- != null) {
soapBodyElement = (SOAPBodyElement) iterator.next();
- iterator = soapBodyElement.getChildElements();
+ iterator = soapBodyElement.getChildElements();
SOAPElement soapElement = (SOAPElement) iterator.next();
- Message message =
- new Message(soapElement.getValue());
+ Message message = new Message(soapElement.getValue());
messageContext.setCurrentMessage(message);
}
+
}
- // ////System.out.println("\n" + messageContext.getCurrentMessage().getSOAPPartAsString() + "\n");
- } catch (AxisFault axisFault) {
- System.out.println("axisFault.printStackTrace()");
-
- // To change body of catch statement use Options | File Templates.
- } catch (SOAPException e) {
- System.out.println("e.printStackTrace()");
+
- // To change body of catch statement use Options | File Templates.
+ }catch (SOAPException e) {
+ throw AxisFault.makeFault(e);
}
+
}
+
}
1.5 +9 -1 ws-fx/sandesha/src/org/apache/sandesha/ws/rm/handlers/RMHandler.java
Index: RMHandler.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/ws/rm/handlers/RMHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RMHandler.java 2 May 2004 16:53:00 -0000 1.4
+++ RMHandler.java 6 May 2004 19:03:45 -0000 1.5
@@ -47,7 +47,15 @@
RMHeaders rmHeaders = new RMHeaders();
rmHeaders.fromSOAPEnvelope(msgContext.getCurrentMessage().getSOAPEnvelope());
- msgContext.setProperty(property, rmHeaders);
+ if((rmHeaders.getAckRequest()!=null) ||
+ (rmHeaders.getCreateSequence()!=null) ||
+ (rmHeaders.getCreateSequenceResponse()!=null) ||
+ (rmHeaders.getSequence()!= null) ||
+ (rmHeaders.getSequenceAcknowledgement()!=null) ||
+ (rmHeaders.getTerminateSequence()!=null)){
+ msgContext.setProperty(property, rmHeaders);
+ }
+
}
/**
1.8 +13 -10 ws-fx/sandesha/src/org/apache/sandesha/ws/rm/handlers/RMServerRequestHandler.java
Index: RMServerRequestHandler.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/ws/rm/handlers/RMServerRequestHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RMServerRequestHandler.java 3 May 2004 12:52:37 -0000 1.7
+++ RMServerRequestHandler.java 6 May 2004 19:03:45 -0000 1.8
@@ -20,6 +20,7 @@
import org.apache.axis.MessageContext;
import org.apache.sandesha.Constants;
+
import javax.xml.soap.SOAPException;
/**
@@ -42,14 +43,16 @@
* @param msgContext
* @throws AxisFault
*/
- public void invoke(MessageContext msgContext) throws AxisFault {
-
- // System.out.println("RMServerRequestHandler::invoke");
- try {
- setPropertyToMessageContext(msgContext,
- Constants.ENV_RM_REQUEST_HEADERS);
- } catch (Exception e) {
- throw AxisFault.makeFault(e);
- }
- }
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ try {
+
+ setPropertyToMessageContext(
+ msgContext,
+ Constants.ENV_RM_REQUEST_HEADERS);
+ } catch (SOAPException e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
+
+
}