antelder 2002/06/18 05:16:05
Modified: java/src/org/apache/wsif/providers/jms JMSFormatter.java
WSIFOperation_Jms.java
Log:
Bug fixes (134730,135199) - native JMS provider requires user JMS properties in
response msg, and ports in WSDL defined in specific order
Revision Changes Path
1.2 +266 -243
xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSFormatter.java
Index: JMSFormatter.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSFormatter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JMSFormatter.java 6 Jun 2002 08:28:51 -0000 1.1
+++ JMSFormatter.java 18 Jun 2002 12:16:05 -0000 1.2
@@ -59,6 +59,7 @@
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
@@ -83,16 +84,16 @@
import org.apache.wsif.wsdl.extensions.jms.JMSInput;
import org.apache.wsif.wsdl.extensions.jms.JMSOutput;
-public class JMSFormatter implements WSIFFormatter {
+public class JMSFormatter implements WSIFFormatter, Serializable {
- // Declaration of Header Fields
- public static String OPERATION_NAME = "WSDL_Operation";
- public static String INPUT_NAME = "WSDL_Input";
- public static String OUTPUT_NAME = "WSDL_Output";
- public static String PORT_TYPE_NS = "WSDL_PortType_NS";
- public static String PORT_TYPE_LOCAL = "WSDL_PortType_Local";
private javax.wsdl.Definition fieldDefinition;
+ private String reqOpName;
+ private String reqInputName;
+ private String reqOutputName;
+ private String reqPortTypeNS;
+ private String reqPortTypeLocal;
+
/**
* Constructor for JMSFormatter
*/
@@ -159,20 +160,12 @@
copyTo(req.getIncomingMessage(), fhMsg);
fhMsg.write(out);
- // Add the specific tags to the header
- try {
- out.setStringProperty(OPERATION_NAME, req.getOperationName());
- out.setStringProperty(INPUT_NAME, req.getInputName());
- out.setStringProperty(OUTPUT_NAME, req.getOutputName());
- out.setStringProperty(
- PORT_TYPE_NS,
- binding.getPortType().getQName().getNamespaceURI());
- out.setStringProperty(
- PORT_TYPE_LOCAL,
- binding.getPortType().getQName().getLocalPart());
- } catch (javax.jms.JMSException e) {
- }
-
+ setOperationName( req.getOperationName() );
+ setInputName( req.getInputName() );
+ setOutputName( req.getOutputName() );
+ setPortTypeNS( binding.getQName().getNamespaceURI() );
+ setPortTypeLocal( binding.getQName().getLocalPart() );
+
Tr.exit();
}
@@ -216,111 +209,108 @@
String input = null;
String output = null;
- try {
-
- operationName = msg.getStringProperty(OPERATION_NAME);
- // Check to see if one of the properties are defined
- // If so, get the information from them.
- if (operationName != null && !operationName.equals("")) {
- input = msg.getStringProperty(INPUT_NAME);
- output = msg.getStringProperty(OUTPUT_NAME);
-
- String portType_ns = msg.getStringProperty(PORT_TYPE_NS);
- String portType_local = msg.getStringProperty(PORT_TYPE_LOCAL);
-
- javax.wsdl.QName portTypeName =
- new javax.wsdl.QName(portType_ns, portType_local);
-
- //Locate Binding
- javax.wsdl.Binding binding = null;
-
- for (java.util.Iterator bindings =
- fieldDefinition.getBindings().values().iterator();
- bindings.hasNext();
- ) {
- javax.wsdl.Binding b = (javax.wsdl.Binding) bindings.next();
- if (b.getPortType().getQName().equals(portTypeName)) {
- binding = b;
- break;
- }
- }
-
- if (binding == null)
- throw new WSIFException("Unable to locate Binding");
-
- //Locate Service
- java.util.Iterator services =
fieldDefinition.getServices().values().iterator();
-
- while (services.hasNext() && serviceName == null) {
- javax.wsdl.Service s = (javax.wsdl.Service) services.next();
-
- for (java.util.Iterator ports =
s.getPorts().values().iterator();
- ports.hasNext();
- ) {
- javax.wsdl.Port p = (javax.wsdl.Port) ports.next();
- if (p.getBinding().getQName().equals(binding.getQName())) {
- // Binding found
- serviceName = s.getQName();
- portName = p.getName();
- break;
- }
- }
- }
-
- }
- } catch (javax.jms.JMSException e) {
- }
-
- // Check to see if anything was defined
- if (operationName == null) {
- // Nothing defined. Resort to getting the info from the service
definition
- java.util.Iterator services =
fieldDefinition.getServices().values().iterator();
-
- while (services.hasNext() && serviceName == null) {
-
- javax.wsdl.Service s = (javax.wsdl.Service) services.next();
- //Get the first Port that has a JMS Address
- java.util.Iterator i = s.getPorts().values().iterator();
-
- while (i.hasNext() && serviceName == null) {
- javax.wsdl.Port p = (javax.wsdl.Port) i.next();
- java.util.Iterator e = p.getExtensibilityElements().iterator();
-
- while (e.hasNext() && serviceName == null) {
- javax.wsdl.extensions.ExtensibilityElement ee =
- (javax.wsdl.extensions.ExtensibilityElement) e.next();
-
- // Check to see if the extensibility element is a JMS
binding
- if (ee
- .getElementType()
-
.equals(org.apache.wsif.wsdl.extensions.jms.JMSConstants.Q_ELEM_JMS_ADDRESS)) {
-
- // Assign the service definition
- serviceName = s.getQName();
- portName = p.getName();
-
- // Locate the operation
- javax.wsdl.Binding binding = p.getBinding();
- if (binding != null) {
- javax.wsdl.PortType portType =
p.getBinding().getPortType();
- if (portType != null) {
- java.util.List operations =
portType.getOperations();
- if (operations != null && operations.size() >
0) {
- javax.wsdl.Operation o =
(javax.wsdl.Operation) operations.get(0);
- operationName = o.getName();
- if (o.getInput() != null)
- input = o.getInput().getName();
- if (o.getOutput() != null)
- output = o.getOutput().getName();
- }
- }
- }
+ String portType_ns = null;
+ String portType_local = null;
- }
- }
- }
- }
- }
+ operationName = getOperationName();
+ // Check to see if one of the properties are defined
+ // If so, get the information from them.
+ if (operationName != null && !operationName.equals("")) {
+ input = getInputName();
+ output = getOutputName();
+
+ portType_ns = getPortTypeNS();
+ portType_local = getPortTypeLocal();
+
+ javax.wsdl.QName portTypeName = new
javax.wsdl.QName(portType_ns, portType_local);
+
+ //Locate Binding
+ javax.wsdl.Binding binding = null;
+
+ for (java.util.Iterator bindings =
fieldDefinition.getBindings().values().iterator(); bindings.hasNext();) {
+ javax.wsdl.Binding b =
(javax.wsdl.Binding)bindings.next();
+ if (b.getQName().equals(portTypeName)) {
+ binding = b;
+ break;
+ }
+ }
+
+ if (binding == null)
+ throw new WSIFException("Unable to locate Binding");
+
+ //Locate Service
+ java.util.Iterator services =
fieldDefinition.getServices().values().iterator();
+
+ while (services.hasNext() && serviceName ==null) {
+ javax.wsdl.Service s =
(javax.wsdl.Service)services.next();
+
+ for (java.util.Iterator ports =
s.getPorts().values().iterator(); ports.hasNext();) {
+ javax.wsdl.Port p =
(javax.wsdl.Port)ports.next();
+ if
(p.getBinding().getQName().equals(binding.getQName())) {
+ // Binding found
+ serviceName = s.getQName();
+ portName = p.getName();
+ break;
+ }
+ }
+ }
+
+ }
+
+ // Check to see if anything was defined
+ if (operationName == null) {
+ // Nothing defined. Resort to getting the info from the
service definition
+ java.util.Iterator services =
fieldDefinition.getServices().values().iterator();
+
+ while (services.hasNext()) {
+
+ javax.wsdl.Service s =
(javax.wsdl.Service)services.next();
+ //Get the first Port that has a JMS Address
+ java.util.Iterator i =
s.getPorts().values().iterator();
+
+ while (i.hasNext()) {
+ javax.wsdl.Port p = (javax.wsdl.Port)i.next();
+
+ if
(hasExtensibilityElementType(p.getExtensibilityElements(),
+
org.apache.wsif.wsdl.extensions.jms.JMSConstants.Q_ELEM_JMS_ADDRESS)) {
+
+ // Need to check if binding has a JMS
Binding
+ javax.wsdl.Binding binding =
p.getBinding();
+ if (binding != null &&
+
hasExtensibilityElementType(binding.getExtensibilityElements(),
+
org.apache.wsif.wsdl.extensions.jms.JMSConstants.Q_ELEM_JMS_BINDING))
+ {
+
+ if (serviceName == null) {
+ // Assign the service
definition
+ serviceName =
s.getQName();
+ portName = p.getName();
+
+ // Locate the operation
+ javax.wsdl.PortType
portType = binding.getPortType();
+ if (portType!= null) {
+ java.util.List
operations = portType.getOperations();
+ if (operations
!= null) {
+ if
(operations.size() == 1) {
+
javax.wsdl.Operation o = (javax.wsdl.Operation)operations.get(0);
+
operationName = o.getName();
+
if (o.getInput() != null)
+
input = o.getInput().getName();
+
if (o.getOutput() != null)
+
output = o.getOutput().getName();
+ }
+ else
+
throw new WSIFException("Port Type definition contains multiple operations.");
+ }
+ }
+ }
+ else
+ throw new
WSIFException("More than one Port definition references a JMS Binding definition");
+ }
+ }
+ }
+ }
+ }
if (serviceName == null)
throw new WSIFException("Unable to locate Service");
@@ -350,111 +340,105 @@
String input = null;
String output = null;
- try {
-
- operationName = msg.getStringProperty(OPERATION_NAME);
- // Check to see if one of the properties are defined
- // If so, get the information from them.
- if (operationName != null && !operationName.equals("")) {
- input = msg.getStringProperty(INPUT_NAME);
- output = msg.getStringProperty(OUTPUT_NAME);
-
- String portType_ns = msg.getStringProperty(PORT_TYPE_NS);
- String portType_local = msg.getStringProperty(PORT_TYPE_LOCAL);
-
- javax.wsdl.QName portTypeName =
- new javax.wsdl.QName(portType_ns, portType_local);
-
- //Locate Binding
- javax.wsdl.Binding binding = null;
-
- for (java.util.Iterator bindings =
- fieldDefinition.getBindings().values().iterator();
- bindings.hasNext();
- ) {
- javax.wsdl.Binding b = (javax.wsdl.Binding) bindings.next();
- if (b.getPortType().getQName().equals(portTypeName)) {
- binding = b;
- break;
- }
- }
-
- if (binding == null)
- throw new WSIFException("Unable to locate Binding");
-
- //Locate Service
- java.util.Iterator services =
fieldDefinition.getServices().values().iterator();
-
- while (services.hasNext() && serviceName == null) {
- javax.wsdl.Service s = (javax.wsdl.Service) services.next();
-
- for (java.util.Iterator ports =
s.getPorts().values().iterator();
- ports.hasNext();
- ) {
- javax.wsdl.Port p = (javax.wsdl.Port) ports.next();
- if (p.getBinding().getQName().equals(binding.getQName())) {
- // Binding found
- serviceName = s.getQName();
- portName = p.getName();
- break;
- }
- }
- }
-
- }
- } catch (javax.jms.JMSException e) {
- }
-
- // Check to see if anything was defined
- if (operationName == null) {
- // Nothing defined. Resort to getting the info from the service
definition
- java.util.Iterator services =
fieldDefinition.getServices().values().iterator();
-
- while (services.hasNext() && serviceName == null) {
-
- javax.wsdl.Service s = (javax.wsdl.Service) services.next();
- //Get the first Port that has a JMS Address
- java.util.Iterator i = s.getPorts().values().iterator();
-
- while (i.hasNext() && serviceName == null) {
- javax.wsdl.Port p = (javax.wsdl.Port) i.next();
- java.util.Iterator e = p.getExtensibilityElements().iterator();
-
- while (e.hasNext() && serviceName == null) {
- javax.wsdl.extensions.ExtensibilityElement ee =
- (javax.wsdl.extensions.ExtensibilityElement) e.next();
-
- // Check to see if the extensibility element is a JMS
binding
- if (ee
- .getElementType()
-
.equals(org.apache.wsif.wsdl.extensions.jms.JMSConstants.Q_ELEM_JMS_ADDRESS)) {
-
- // Assign the service definition
- serviceName = s.getQName();
- portName = p.getName();
-
- // Locate the operation
- javax.wsdl.Binding binding = p.getBinding();
- if (binding != null) {
- javax.wsdl.PortType portType =
p.getBinding().getPortType();
- if (portType != null) {
- java.util.List operations =
portType.getOperations();
- if (operations != null && operations.size() >
0) {
- javax.wsdl.Operation o =
(javax.wsdl.Operation) operations.get(0);
- operationName = o.getName();
- if (o.getInput() != null)
- input = o.getInput().getName();
- if (o.getOutput() != null)
- output = o.getOutput().getName();
- }
- }
- }
-
- }
- }
- }
- }
- }
+ operationName = getOperationName();
+ // Check to see if one of the properties are defined
+ // If so, get the information from them.
+ if (operationName != null && !operationName.equals("")) {
+ input = getInputName();
+ output = getOutputName();
+
+ String portType_ns = getPortTypeNS();
+ String portType_local = getPortTypeLocal();
+
+ javax.wsdl.QName portTypeName = new
javax.wsdl.QName(portType_ns, portType_local);
+
+ //Locate Binding
+ javax.wsdl.Binding binding = null;
+
+ for (java.util.Iterator bindings =
fieldDefinition.getBindings().values().iterator(); bindings.hasNext();) {
+ javax.wsdl.Binding b =
(javax.wsdl.Binding)bindings.next();
+ if (b.getQName().equals(portTypeName)) {
+ binding = b;
+ break;
+ }
+ }
+
+ if (binding == null)
+ throw new WSIFException("Unable to locate Binding");
+
+ //Locate Service
+ java.util.Iterator services =
fieldDefinition.getServices().values().iterator();
+
+ while (services.hasNext() && serviceName ==null) {
+ javax.wsdl.Service s =
(javax.wsdl.Service)services.next();
+
+ for (java.util.Iterator ports =
s.getPorts().values().iterator(); ports.hasNext();) {
+ javax.wsdl.Port p =
(javax.wsdl.Port)ports.next();
+ if
(p.getBinding().getQName().equals(binding.getQName())) {
+ // Binding found
+ serviceName = s.getQName();
+ portName = p.getName();
+ break;
+ }
+ }
+ }
+
+ }
+
+ // Check to see if anything was defined
+ if (operationName == null) {
+ // Nothing defined. Resort to getting the info from the
service definition
+ java.util.Iterator services =
fieldDefinition.getServices().values().iterator();
+
+ while (services.hasNext()) {
+
+ javax.wsdl.Service s =
(javax.wsdl.Service)services.next();
+ //Get the first Port that has a JMS Address
+ java.util.Iterator i =
s.getPorts().values().iterator();
+
+ while (i.hasNext()) {
+ javax.wsdl.Port p = (javax.wsdl.Port)i.next();
+
+ if
(hasExtensibilityElementType(p.getExtensibilityElements(),
+
org.apache.wsif.wsdl.extensions.jms.JMSConstants.Q_ELEM_JMS_ADDRESS)) {
+
+ // Need to check if binding has a JMS
Binding
+ javax.wsdl.Binding binding =
p.getBinding();
+ if (binding != null &&
+
hasExtensibilityElementType(binding.getExtensibilityElements(),
+
org.apache.wsif.wsdl.extensions.jms.JMSConstants.Q_ELEM_JMS_BINDING))
+ {
+
+ if (serviceName == null) {
+ // Assign the service
definition
+ serviceName =
s.getQName();
+ portName = p.getName();
+
+ // Locate the operation
+ javax.wsdl.PortType
portType = binding.getPortType();
+ if (portType!= null) {
+ java.util.List
operations = portType.getOperations();
+ if (operations
!= null) {
+ if
(operations.size() == 1) {
+
javax.wsdl.Operation o = (javax.wsdl.Operation)operations.get(0);
+
operationName = o.getName();
+
if (o.getInput() != null)
+
input = o.getInput().getName();
+
if (o.getOutput() != null)
+
output = o.getOutput().getName();
+ }
+ else
+
throw new WSIFException("Port Type definition contains multiple operations.");
+ }
+ }
+ }
+ else
+ throw new
WSIFException("More than one Port definition references a JMS Binding definition");
+ }
+ }
+ }
+ }
+ }
if (serviceName == null)
throw new WSIFException("Unable to locate Service");
@@ -496,19 +480,6 @@
copyTo(resp.getOutgoingMessage(), fhMsg);
fhMsg.write(out);
- // Add the operation to the header
- try {
- out.setStringProperty(OPERATION_NAME, resp.getOperationName());
- out.setStringProperty(INPUT_NAME, resp.getInputName());
- out.setStringProperty(OUTPUT_NAME, resp.getOutputName());
- out.setStringProperty(
- PORT_TYPE_NS,
- binding.getPortType().getQName().getNamespaceURI());
- out.setStringProperty(
- PORT_TYPE_LOCAL,
- binding.getPortType().getQName().getLocalPart());
- } catch (Exception e) {
- }
Tr.exit();
}
@@ -600,4 +571,56 @@
}
return null;
}
+
+ private boolean hasExtensibilityElementType(java.util.List ee,
javax.wsdl.QName type) {
+
+ Object[] list = ee.toArray();
+
+ for (int i=0; i<list.length; i++) {
+ if
(((javax.wsdl.extensions.ExtensibilityElement)list[i]).getElementType().equals(type))
+ return true;
+ }
+ return false;
+ }
+
+ private String getOperationName() {
+ return reqOpName;
+ }
+
+ private void setOperationName(String s) {
+ reqOpName = s;
+ }
+
+ private String getInputName() {
+ return reqInputName;
+ }
+
+ private void setInputName(String s) {
+ reqInputName = s;
+ }
+
+ private String getOutputName() {
+ return reqOutputName;
+ }
+
+ private void setOutputName(String s) {
+ reqOutputName = s;
+ }
+
+ private String getPortTypeNS() {
+ return reqPortTypeNS;
+ }
+
+ private void setPortTypeNS(String s) {
+ reqPortTypeNS = s;
+ }
+
+ private String getPortTypeLocal() {
+ return reqPortTypeLocal;
+ }
+
+ private void setPortTypeLocal(String s) {
+ reqPortTypeLocal = s;
+ }
+
}
1.5 +26 -6
xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java
Index: WSIFOperation_Jms.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WSIFOperation_Jms.java 14 Jun 2002 14:28:03 -0000 1.4
+++ WSIFOperation_Jms.java 18 Jun 2002 12:16:05 -0000 1.5
@@ -78,6 +78,7 @@
import org.apache.wsif.base.WSIFDefaultOperation;
import org.apache.wsif.logging.MessageLogger;
import org.apache.wsif.logging.Tr;
+import org.apache.wsif.WSIFCorrelationService;
import org.apache.wsif.util.WSIFCorrelationServiceLocator;
import org.apache.wsif.util.WSIFProperties;
import org.apache.wsif.util.jms.WSIFJMSCorrelationId;
@@ -121,7 +122,9 @@
private WSIFResponseHandler handler;
private boolean asyncOperation;
+ private JMSFormatter formatter;
private final static boolean DEBUG = false;
+ private static final long ASYNC_TIMEOUT = WSIFProperties.getAsyncTimeout();
/**
* ctor
@@ -219,6 +222,22 @@
}
/**
+ * executeRequestResponseAsync(WSIFMessage)
+ * This is the simple async form where the client is expected
+ * to handle the correlating of the response.
+ * @param input input message to send to the operation
+ *
+ * @return the correlation ID or the request. The correlation ID
+ * is used to associate the request with the WSIFOperation.
+ *
+ * @exception WSIFException if something goes wrong.
+ */
+ public WSIFCorrelationId executeRequestResponseAsync(
+ WSIFMessage input) throws WSIFException {
+ return executeRequestResponseAsync( input, null );
+ }
+
+ /**
* executeRequestResponseAsync(WSIFMessage, WSIFResponseHandler)
*
* @param input input message to send to the operation
@@ -260,10 +279,12 @@
setDestinationContext( jmsDest );
// send the jms message
- correlId = new WSIFJMSCorrelationId(sendJmsMessage(input, jmsDest));
- if (handler != null) {
- //register it to the correlation service
- WSIFCorrelationServiceLocator.getCorrelationService().put(correlId,
this, 0);
+ WSIFCorrelationService cs =
+ WSIFCorrelationServiceLocator.getCorrelationService();
+ synchronized( cs ) {
+ correlId = new WSIFJMSCorrelationId( sendJmsMessage(input, jmsDest)
);
+ //register it to the correlation service
+ cs.put( correlId, this, ASYNC_TIMEOUT );
}
} catch (Exception ex) {
// Log message
@@ -423,7 +444,7 @@
}
}
- JMSFormatter formatter = (JMSFormatter) fieldJmsPort.getFormatter();
+ formatter = (JMSFormatter)fieldJmsPort.getFormatter();
WSIFRequest request = new WSIFRequest(serviceModel.getQName());
request.setIncomingMessage(message);
@@ -457,7 +478,6 @@
if (!(responseObject instanceof javax.jms.Message))
throw new WSIFException("Object is not of type javax.jms.Message");
- JMSFormatter formatter = (JMSFormatter) fieldJmsPort.getFormatter();
WSIFResponse resp =
formatter.unformatResponse((javax.jms.Message) responseObject);