You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by wh...@apache.org on 2002/10/07 17:25:52 UTC
cvs commit: xml-axis-wsif/java/test/org/apache/wsif/util/jms NativeJMSRequestListener.java
whitlock 2002/10/07 08:25:52
Modified: java/src/org/apache/wsif/wsdl/extensions/jms
JMSExtensionRegistry.java JMSConstants.java
java/src/org/apache/wsif/providers/jms JMSFormatter.java
WSIFOperation_Jms.java
java/test/util TestUtilities.java
java/test/org/apache/wsif/util/jms
NativeJMSRequestListener.java
Added: java/src/org/apache/wsif/wsdl/extensions/jms
JMSFaultPropertySerializer.java JMSFault.java
JMSFaultIndicator.java JMSFaultProperty.java
JMSFaultIndicatorSerializer.java
JMSFaultSerializer.java
java/test/jms JmsFaultTest.java JmsFault.wsdl
Log:
Add support for Native JMS faults
Revision Changes Path
1.3 +9 -0 xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSExtensionRegistry.java
Index: JMSExtensionRegistry.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSExtensionRegistry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JMSExtensionRegistry.java 19 Jul 2002 15:46:28 -0000 1.2
+++ JMSExtensionRegistry.java 7 Oct 2002 15:25:51 -0000 1.3
@@ -88,6 +88,15 @@
// Register JMS Output Serializer
new JMSOutputSerializer().registerSerializer(this);
+ // Register JMS Fault Serializer
+ new JMSFaultSerializer().registerSerializer(this);
+
+ // Register JMS Fault Indicator Serializer
+ new JMSFaultIndicatorSerializer().registerSerializer(this);
+
+ // Register JMS Fault Property Serializer
+ new JMSFaultPropertySerializer().registerSerializer(this);
+
// Register JMS Property Serializer
new JMSPropertySerializer().registerSerializer(this);
1.3 +12 -0 xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSConstants.java
Index: JMSConstants.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSConstants.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JMSConstants.java 24 Jun 2002 13:11:18 -0000 1.2
+++ JMSConstants.java 7 Oct 2002 15:25:51 -0000 1.3
@@ -79,6 +79,9 @@
public static final String ELEM_PROPERTY_VALUE = "propertyValue";
public static final String ELEM_INPUT = "input";
public static final String ELEM_OUTPUT = "output";
+ public static final String ELEM_FAULT = "fault";
+ public static final String ELEM_FAULT_INDICATOR = "faultIndicator";
+ public static final String ELEM_FAULT_PROPERTY = "faultProperty";
public static final String ATTR_MESSAGE_TYPE = "type";
// managed environment elements
@@ -142,6 +145,15 @@
public static final QName Q_ELEM_JMS_OUTPUT =
new QName(NS_URI_JMS, ELEM_OUTPUT);
+
+ public static final QName Q_ELEM_JMS_FAULT =
+ new QName(NS_URI_JMS, ELEM_FAULT);
+
+ public static final QName Q_ELEM_JMS_FAULT_INDICATOR =
+ new QName(NS_URI_JMS, ELEM_FAULT_INDICATOR);
+
+ public static final QName Q_ELEM_JMS_FAULT_PROPERTY =
+ new QName(NS_URI_JMS, ELEM_FAULT_PROPERTY);
// Jms message (body) types
public static final int MESSAGE_TYPE_NOTSET = 0;
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFaultPropertySerializer.java
Index: JMSFaultPropertySerializer.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.extensions.jms;
import java.io.Serializable;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.ExtensionDeserializer;
import javax.wsdl.extensions.ExtensionRegistry;
import javax.wsdl.extensions.ExtensionSerializer;
import javax.xml.namespace.QName;
import org.apache.wsif.logging.Trc;
import org.w3c.dom.Element;
import com.ibm.wsdl.Constants;
import com.ibm.wsdl.util.xml.DOMUtils;
/**
* WSDL Jms extension
*
* @author Mark Whitlock <wh...@apache.org>
*/
public class JMSFaultPropertySerializer
implements ExtensionSerializer, ExtensionDeserializer, Serializable {
/**
* @see ExtensionSerializer#marshall(Class, QName, ExtensibilityElement,
* PrintWriter, Definition, ExtensionRegistry)
*/
public void marshall(
Class parentType,
QName elementType,
javax.wsdl.extensions.ExtensibilityElement extension,
java.io.PrintWriter pw,
javax.wsdl.Definition def,
javax.wsdl.extensions.ExtensionRegistry extReg)
throws javax.wsdl.WSDLException {
Trc.entry(parentType, elementType, extension, pw, def, extReg);
if (extension == null) {
Trc.exit();
return;
}
JMSFaultProperty jmsFaultProperty = (JMSFaultProperty) extension;
String tagName =
DOMUtils.getQualifiedValue(
JMSConstants.NS_URI_JMS,
"faultProperty",
def);
pw.print(" <" + tagName);
/**
* handle attributes
*/
if (jmsFaultProperty.getName() != null) {
DOMUtils.printAttribute(
JMSConstants.ATTR_NAME,
jmsFaultProperty.getName(),
pw);
}
if (jmsFaultProperty.getType() != null) {
DOMUtils.printQualifiedAttribute(
JMSConstants.ATTR_TYPE,
jmsFaultProperty.getType(),
def,
pw);
}
if (jmsFaultProperty.getValue() != null) {
DOMUtils.printAttribute(
JMSConstants.ATTR_VALUE,
jmsFaultProperty.getValue(),
pw);
}
Boolean required = extension.getRequired();
if (required != null) {
DOMUtils.printQualifiedAttribute(
Constants.Q_ATTR_REQUIRED,
required.toString(),
def,
pw);
}
pw.println("/>");
Trc.exit();
}
/**
* Registers the serializer.
*/
public void registerSerializer(ExtensionRegistry registry) {
Trc.entry(this, registry);
// faultProperty
registry.registerSerializer(
JMSFaultIndicator.class,
JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY,
this);
registry.registerDeserializer(
JMSFaultIndicator.class,
JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY,
this);
registry.mapExtensionTypes(
JMSFaultIndicator.class,
JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY,
JMSFaultProperty.class);
Trc.exit();
}
/**
* @see ExtensionDeserializer#unmarshall(Class, QName, Element, Definition,
* ExtensionRegistry)
*/
public ExtensibilityElement unmarshall(
Class parentType,
QName elementType,
Element el,
Definition def,
ExtensionRegistry extReg)
throws WSDLException {
Trc.entry(this, parentType, elementType, el, def, extReg);
JMSFaultProperty jmsFaultProperty =
(JMSFaultProperty) extReg.createExtension(parentType, elementType);
String name = DOMUtils.getAttribute(el, JMSConstants.ATTR_NAME);
if (name != null) {
jmsFaultProperty.setName(name);
}
QName type =
DOMUtils.getQualifiedAttributeValue(
el,
JMSConstants.ATTR_TYPE,
JMSConstants.ELEM_FAULT_PROPERTY,
false);
if (type != null) {
jmsFaultProperty.setType(type);
}
String value = DOMUtils.getAttribute(el, JMSConstants.ATTR_VALUE);
if (value != null) {
jmsFaultProperty.setValue(value);
}
Trc.exit(jmsFaultProperty);
return jmsFaultProperty;
}
}
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFault.java
Index: JMSFault.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.extensions.jms;
import java.io.Serializable;
import java.util.List;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
* WSDL Jms service-port extension
*
* @author Mark Whitlock <wh...@apache.org>
*/
public class JMSFault implements ExtensibilityElement, Serializable {
protected QName fieldElementType = JMSConstants.Q_ELEM_JMS_FAULT;
// Uses the wrapper type so we can tell if it was set or not.
protected Boolean fieldRequired = null;
protected List fieldParts;
/**
* @see ExtensibilityElement#setElementType(QName)
*/
public void setElementType(QName elementType) {
fieldElementType = elementType;
}
/**
* @see ExtensibilityElement#getElementType()
*/
public QName getElementType() {
return fieldElementType;
}
/**
* @see ExtensibilityElement#setRequired(Boolean)
*/
public void setRequired(Boolean required) {
fieldRequired = required;
}
/**
* @see ExtensibilityElement#getRequired()
*/
public Boolean getRequired() {
return fieldRequired;
}
/**
* Gets the parts
* @return Returns a String
*/
public List getParts() {
return fieldParts;
}
/**
* Sets the parts
* @param parts The parts to set
*/
public void setParts(List parts) {
this.fieldParts = parts;
}
public String toString() {
StringBuffer strBuf = new StringBuffer(super.toString());
strBuf.append("\nJavaAddress (" + fieldElementType + "):");
strBuf.append("\nrequired=" + fieldRequired);
strBuf.append("\nparts=" + fieldParts);
return strBuf.toString();
}
}
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFaultIndicator.java
Index: JMSFaultIndicator.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.extensions.jms;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
* WSDL Jms service-port extension
*
* @author Mark Whitlock <wh...@apache.org>
*/
public class JMSFaultIndicator implements ExtensibilityElement, Serializable {
protected QName fieldElementType = JMSConstants.Q_ELEM_JMS_FAULT_INDICATOR;
// Uses the wrapper type so we can tell if it was set or not.
protected Boolean fieldRequired = null;
protected String fieldType;
protected List faultProperties;
/**
* @see ExtensibilityElement#setElementType(QName)
*/
public void setElementType(QName elementType) {
fieldElementType = elementType;
}
/**
* @see ExtensibilityElement#getElementType()
*/
public QName getElementType() {
return fieldElementType;
}
/**
* @see ExtensibilityElement#setRequired(Boolean)
*/
public void setRequired(Boolean required) {
fieldRequired = required;
}
/**
* @see ExtensibilityElement#getRequired()
*/
public Boolean getRequired() {
return fieldRequired;
}
/**
* Gets the type
* @return Returns a String
*/
public String getType() {
return fieldType;
}
/**
* Sets the type
* @param type The type to set
*/
public void setType(String type) {
this.fieldType = type;
}
public void addJMSFaultProperty(JMSFaultProperty jmsFaultProperty) {
getJMSFaultProperties().add(jmsFaultProperty);
}
public List getJMSFaultProperties() {
if (faultProperties == null)
faultProperties = new ArrayList();
return faultProperties;
}
public String toString() {
StringBuffer strBuf = new StringBuffer(super.toString());
strBuf.append("\nJavaAddress (" + fieldElementType + "):");
strBuf.append("\nrequired=" + fieldRequired);
strBuf.append("\ntype=" + fieldType);
strBuf.append("\nfaultProperties=" + faultProperties);
return strBuf.toString();
}
}
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFaultProperty.java
Index: JMSFaultProperty.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.extensions.jms;
import java.io.Serializable;
import java.util.List;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
* WSDL Jms service-port extension
*
* @author Mark Whitlock <wh...@apache.org>
*/
public class JMSFaultProperty implements ExtensibilityElement, Serializable {
protected QName fieldElementType = JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY;
// Uses the wrapper type so we can tell if it was set or not.
protected Boolean fieldRequired = null;
protected String fieldName;
protected QName fieldType;
protected String fieldValue;
/**
* @see ExtensibilityElement#setElementType(QName)
*/
public void setElementType(QName elementType) {
fieldElementType = elementType;
}
/**
* @see ExtensibilityElement#getElementType()
*/
public QName getElementType() {
return fieldElementType;
}
/**
* @see ExtensibilityElement#setRequired(Boolean)
*/
public void setRequired(Boolean required) {
fieldRequired = required;
}
/**
* @see ExtensibilityElement#getRequired()
*/
public Boolean getRequired() {
return fieldRequired;
}
/**
* Gets the Name
* @return Returns a String
*/
public String getName() {
return fieldName;
}
/**
* Sets the Name
* @param fieldName The name to set
*/
public void setName(String name) {
this.fieldName = name;
}
/**
* Gets the Type
* @return Returns a String
*/
public QName getType() {
return fieldType;
}
/**
* Sets the Type
* @param fieldType The type to set
*/
public void setType(QName type) {
this.fieldType = type;
}
/**
* Gets the Value
* @return Returns a String
*/
public String getValue() {
return fieldValue;
}
/**
* Sets the Value
* @param fieldValue The value to set
*/
public void setValue(String value) {
this.fieldValue = value;
}
public String toString() {
StringBuffer strBuf = new StringBuffer(super.toString());
strBuf.append("\nJavaAddress (" + fieldElementType + "):");
strBuf.append("\nrequired=" + fieldRequired);
strBuf.append("\nname=" + fieldName);
strBuf.append("\ntype=" + fieldType);
strBuf.append("\nvalue=" + fieldValue);
return strBuf.toString();
}
}
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFaultIndicatorSerializer.java
Index: JMSFaultIndicatorSerializer.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.extensions.jms;
import java.io.Serializable;
import java.util.Iterator;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.ExtensionDeserializer;
import javax.wsdl.extensions.ExtensionRegistry;
import javax.wsdl.extensions.ExtensionSerializer;
import javax.xml.namespace.QName;
import org.apache.wsif.logging.Trc;
import org.w3c.dom.Element;
import com.ibm.wsdl.Constants;
import com.ibm.wsdl.util.xml.DOMUtils;
import com.ibm.wsdl.util.xml.QNameUtils;
/**
* WSDL Jms extension
*
* @author Mark Whitlock <wh...@apache.org>
*/
public class JMSFaultIndicatorSerializer
implements ExtensionSerializer, ExtensionDeserializer, Serializable {
JMSFaultPropertySerializer jmsFaultPropertySerializer;
/**
* @see ExtensionSerializer#marshall(Class, QName, ExtensibilityElement,
* PrintWriter, Definition, ExtensionRegistry)
*/
public void marshall(
Class parentType,
QName elementType,
javax.wsdl.extensions.ExtensibilityElement extension,
java.io.PrintWriter pw,
javax.wsdl.Definition def,
javax.wsdl.extensions.ExtensionRegistry extReg)
throws javax.wsdl.WSDLException {
Trc.entry(parentType, elementType, extension, pw, def, extReg);
if (extension == null) {
Trc.exit();
return;
}
JMSFaultIndicator jmsFaultIndicator = (JMSFaultIndicator) extension;
String tagName =
DOMUtils.getQualifiedValue(
JMSConstants.NS_URI_JMS,
"faultIndicator",
def);
pw.print(" <" + tagName);
/**
* handle attributes
*/
if (jmsFaultIndicator.getType() != null) {
DOMUtils.printAttribute(
JMSConstants.ATTR_TYPE,
jmsFaultIndicator.getType(),
pw);
}
pw.println(">");
// Handle JMSFaultProperties
Iterator i = jmsFaultIndicator.getJMSFaultProperties().iterator();
while (i.hasNext()) {
JMSFaultProperty ee = (JMSFaultProperty) i.next();
getJMSFaultPropertySerializer().marshall(
JMSFaultIndicator.class,
JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY,
ee,
pw,
def,
extReg);
}
Boolean required = extension.getRequired();
if (required != null) {
DOMUtils.printQualifiedAttribute(
Constants.Q_ATTR_REQUIRED,
required.toString(),
def,
pw);
}
pw.println("</" + tagName + ">");
Trc.exit();
}
/**
* Registers the serializer.
*/
public void registerSerializer(ExtensionRegistry registry) {
Trc.entry(this, registry);
// input
registry.registerSerializer(
javax.wsdl.BindingFault.class,
JMSConstants.Q_ELEM_JMS_FAULT_INDICATOR,
this);
registry.registerDeserializer(
javax.wsdl.BindingFault.class,
JMSConstants.Q_ELEM_JMS_FAULT_INDICATOR,
this);
registry.mapExtensionTypes(
javax.wsdl.BindingFault.class,
JMSConstants.Q_ELEM_JMS_FAULT_INDICATOR,
JMSFaultIndicator.class);
Trc.exit();
}
/**
* @see ExtensionDeserializer#unmarshall(Class, QName, Element, Definition,
* ExtensionRegistry)
*/
public ExtensibilityElement unmarshall(
Class parentType,
QName elementType,
Element el,
Definition def,
ExtensionRegistry extReg)
throws WSDLException {
Trc.entry(this, parentType, elementType, el, def, extReg);
JMSFaultIndicator jmsFaultIndicator =
(JMSFaultIndicator) extReg.createExtension(parentType, elementType);
String type = DOMUtils.getAttribute(el, JMSConstants.ATTR_TYPE);
if (type != null) {
jmsFaultIndicator.setType(type);
}
// Handle JMSFaultProperty's
Element tempEl = DOMUtils.getFirstChildElement(el);
while (tempEl != null) {
if (QNameUtils
.matches(JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY, tempEl)) {
jmsFaultIndicator.addJMSFaultProperty(
(JMSFaultProperty) getJMSFaultPropertySerializer()
.unmarshall(
JMSFaultIndicator.class,
JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY,
tempEl,
def,
extReg));
}
tempEl = DOMUtils.getNextSiblingElement(tempEl);
}
Trc.exit(jmsFaultIndicator);
return jmsFaultIndicator;
}
private JMSFaultPropertySerializer getJMSFaultPropertySerializer() {
if (jmsFaultPropertySerializer == null)
jmsFaultPropertySerializer = new JMSFaultPropertySerializer();
return jmsFaultPropertySerializer;
}
}
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/extensions/jms/JMSFaultSerializer.java
Index: JMSFaultSerializer.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.extensions.jms;
import java.io.Serializable;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.ExtensionDeserializer;
import javax.wsdl.extensions.ExtensionRegistry;
import javax.wsdl.extensions.ExtensionSerializer;
import javax.xml.namespace.QName;
import org.apache.wsif.logging.Trc;
import org.w3c.dom.Element;
import com.ibm.wsdl.Constants;
import com.ibm.wsdl.util.xml.DOMUtils;
/**
* WSDL Jms extension
*
* @author Mark Whitlock <wh...@apache.org>
*/
public class JMSFaultSerializer
implements ExtensionSerializer, ExtensionDeserializer, Serializable {
/**
* @see ExtensionSerializer#marshall(Class, QName, ExtensibilityElement, PrintWriter, Definition, ExtensionRegistry)
*/
public void marshall(
Class parentType,
QName elementType,
javax.wsdl.extensions.ExtensibilityElement extension,
java.io.PrintWriter pw,
javax.wsdl.Definition def,
javax.wsdl.extensions.ExtensionRegistry extReg)
throws javax.wsdl.WSDLException {
Trc.entry(parentType, elementType, extension, pw, def, extReg);
if (extension == null) {
Trc.exit();
return;
}
JMSFault jmsFault = (JMSFault) extension;
String tagName =
DOMUtils.getQualifiedValue(JMSConstants.NS_URI_JMS, "fault", def);
pw.print(" <" + tagName);
/**
* handle attributes
*/
if (jmsFault.getParts() != null) {
DOMUtils.printAttribute(
JMSConstants.ATTR_PARTS,
com.ibm.wsdl.util.StringUtils.getNMTokens(jmsFault.getParts()),
pw);
}
Boolean required = extension.getRequired();
if (required != null) {
DOMUtils.printQualifiedAttribute(
Constants.Q_ATTR_REQUIRED,
required.toString(),
def,
pw);
}
pw.println("/>");
Trc.exit();
}
/**
* Registers the serializer.
*/
public void registerSerializer(ExtensionRegistry registry) {
Trc.entry(this, registry);
// fault
registry.registerSerializer(
javax.wsdl.BindingFault.class,
JMSConstants.Q_ELEM_JMS_FAULT,
this);
registry.registerDeserializer(
javax.wsdl.BindingFault.class,
JMSConstants.Q_ELEM_JMS_FAULT,
this);
registry.mapExtensionTypes(
javax.wsdl.BindingFault.class,
JMSConstants.Q_ELEM_JMS_FAULT,
JMSFault.class);
Trc.exit();
}
/**
* @see ExtensionDeserializer#unmarshall(Class, QName, Element, Definition, ExtensionRegistry)
*/
public ExtensibilityElement unmarshall(
Class parentType,
QName elementType,
Element el,
Definition def,
ExtensionRegistry extReg)
throws WSDLException {
Trc.entry(this, parentType, elementType, el, def, extReg);
JMSFault jmsFault = (JMSFault) extReg.createExtension(parentType, elementType);
String parts = DOMUtils.getAttribute(el, JMSConstants.ATTR_PARTS);
if (parts != null) {
jmsFault.setParts(com.ibm.wsdl.util.StringUtils.parseNMTokens(parts));
}
Trc.exit(jmsFault);
return jmsFault;
}
}
1.1 xml-axis-wsif/java/test/jms/JmsFaultTest.java
Index: JmsFaultTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package jms;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.wsif.WSIFException;
import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.WSIFPort;
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;
import util.TestUtilities;
/**
* Junit test to do various JMS tests
* @author Mark Whitlock
*/
public class JmsFaultTest extends TestCase {
String wsdlLocation = TestUtilities.getWsdlPath("java\\test\\jms") + "jmsfault.wsdl";
public JmsFaultTest(String name) {
super(name);
}
public static void main(String[] args) {
TestUtilities.startListeners(TestUtilities.NATIVEJMS_LISTENER);
junit.textui.TestRunner.run (suite());
TestUtilities.stopListeners();
}
public static Test suite() {
return new TestSuite(JmsFaultTest.class);
}
public void setUp() {
TestUtilities.setUpExtensionsAndProviders();
}
public void testSoapDefault() {
doit("throwSimple", false);
}
private void doit(String method, boolean exceptionExpected) {
if (!TestUtilities.areWeTesting("jms"))
return;
try {
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service =
factory.getService(
wsdlLocation,
null,
null,
"http://jms/",
"JmsFault");
WSIFPort port = service.getPort("default");
WSIFOperation operation = port.createOperation(method);
WSIFMessage inputMessage = operation.createInputMessage();
WSIFMessage outputMessage = operation.createOutputMessage();
WSIFMessage faultMessage = operation.createFaultMessage();
boolean operationSucceeded =
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
if ("throwSimple".equals(method)) {
String faultText =
(String) faultMessage.getObjectPart("faultText");
assertTrue("A Simple Fault".equals(faultText));
} else
assertTrue("noFault".equals(method));
assertTrue(!exceptionExpected);
} catch (Exception e) {
System.err.println("JmsFaultTest(" + method + ") caught exception " + e);
if (!exceptionExpected || !(e instanceof WSIFException))
e.printStackTrace();
assertTrue(exceptionExpected && e instanceof WSIFException);
}
}
}
1.1 xml-axis-wsif/java/test/jms/JmsFault.wsdl
Index: JmsFault.wsdl
===================================================================
<?xml version="1.0" ?>
<definitions targetNamespace="http://jms/"
xmlns:tns="http://jms/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:jms="http://schemas.xmlsoap.org/wsdl/jms/"
xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<!-- message declns -->
<message name="NoFaultReq"/>
<message name="NoFaultResp"/>
<message name="SimpleReq"/>
<message name="SimpleResp"/>
<message name="SimpleFault">
<part name="faultText" type="xsd:string"/>
</message>
<message name="IntFault">
<part name="faultInt" type="xsd:int"/>
</message>
<!-- port type declns -->
<portType name="JmsFault">
<operation name="noFault">
<input message="tns:NoFaultReq"/>
<output message="tns:NoFaultResp"/>
</operation>
<operation name="throwSimple">
<input message="tns:SimpleReq"/>
<output message="tns:SimpleResp"/>
<fault name="SimpleFault" message="tns:SimpleFault"/>
<fault name="IntFault" message="tns:IntFault"/>
</operation>
</portType>
<!--
A todo list of other tests that should be included here ...
- <jms:property in the <fault - need to implement output properties
- <jms:fault included/excluded in the <fault
- multiple <fault's as in a switch
- parts="xxx" included/excluded in the <jms:fault
- different types for the <jms:faultProperty
- the jms property's value does not match a <jms:faultProperty is not an exception
- async and sync
- <fault with and without name="xxx"
- <fault with and without message="xxx" (don't really know what that means)
Error cases to test ...
- <jms:faultIndicator type="trash"
- when the <jms:faultProperty type does not match the real jms property type
- no type="xxx" in the jms:faultIndicator is an error
- no name, type, value in the <jms:faultProperty is an error
- bad parts="xxx" in the <jms:fault
- multiple parts="xxx" in the <jms:fault is an error
- multiple <jms:fault in the <fault is an error
A list of unanswered questions
- Should multiple <jms:faultIndicator's in the <fault be and'ed or or'ed (I guess and'ed)
- What if I mix <jms:faultProperty type's?
- How do other providers handle fault messages? All providers should look the same.
- How does this work with stubs? How do parts in the fault message get mapped to
output parts on the stub?
- for other providers, WSIF puts a fault string in the fault message ignoring any
parts in the definition of the fault message. I guess WSIF should use the fault
message definition but I can't really see how. Maybe WSIF should force the fault
message to be a string, but that would fail on existing WSDL.
-->
<binding name="NativeJmsBinding" type="tns:JmsFault">
<jms:binding type="ObjectMessage"/>
<format:typeMapping encoding="Java" style="Java">
<format:typeMap typeName="xsd:string" formatType="java.lang.String" />
</format:typeMapping>
<operation name="noFault">
<input/>
<output/>
</operation>
<operation name="throwSimple">
<input/>
<output/>
<fault name="SimpleFault">
<jms:faultIndicator type="property">
<jms:faultProperty name="faultIndicator" type="xsd:string" value="simple"/>
</jms:faultIndicator>
</fault>
</operation>
</binding>
<!-- service decln -->
<service name="JmsFaultService">
<port name="default" binding="tns:NativeJmsBinding">
<jms:address jndiDestinationName="NativeJmsRequestQueue"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
jndiProviderURL="file://C:/JNDI-Directory"/>
</port>
</service>
</definitions>
1.8 +172 -36 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- JMSFormatter.java 13 Sep 2002 15:41:09 -0000 1.7
+++ JMSFormatter.java 7 Oct 2002 15:25:51 -0000 1.8
@@ -61,17 +61,31 @@
import java.io.OutputStream;
import java.io.Serializable;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import javax.jms.JMSException;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingFault;
import javax.wsdl.BindingOperation;
+import javax.wsdl.Fault;
+import javax.wsdl.Operation;
+import javax.wsdl.extensions.ExtensibilityElement;
import org.apache.wsif.WSIFConstants;
import org.apache.wsif.WSIFException;
+import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFRequest;
import org.apache.wsif.WSIFResponse;
import org.apache.wsif.format.WSIFFormatter;
import org.apache.wsif.logging.Trc;
import org.apache.wsif.util.WSIFUtils;
+import org.apache.wsif.wsdl.extensions.jms.JMSFault;
+import org.apache.wsif.wsdl.extensions.jms.JMSFaultIndicator;
+import org.apache.wsif.wsdl.extensions.jms.JMSFaultProperty;
+import org.apache.wsif.wsdl.extensions.jms.JMSInput;
+import org.apache.wsif.wsdl.extensions.jms.JMSOutput;
+import org.apache.wsif.wsdl.extensions.jms.JMSProperty;
/**
* JMSFormatter
@@ -134,10 +148,10 @@
}
public void formatRequest(WSIFRequest req, javax.jms.Message out)
- throws org.apache.wsif.WSIFException {
+ throws WSIFException {
Trc.entry(this, req, out);
- javax.wsdl.Binding binding = fieldPort.getBinding();
+ Binding binding = fieldPort.getBinding();
BindingOperation bop =
binding.getBindingOperation(
req.getOperationName(),
@@ -163,13 +177,13 @@
}
public WSIFRequest unformatRequest(javax.jms.Message in)
- throws org.apache.wsif.WSIFException {
+ throws WSIFException {
Trc.entry(this, in);
// Need to construct the request.
WSIFRequest req = createRequest(in);
- javax.wsdl.Binding binding = fieldPort.getBinding();
- javax.wsdl.BindingOperation bop =
+ Binding binding = fieldPort.getBinding();
+ BindingOperation bop =
binding.getBindingOperation(
req.getOperationName(),
req.getInputName(),
@@ -200,7 +214,7 @@
String input = null;
String output = null;
- javax.wsdl.Binding fieldBinding = fieldPort.getBinding();
+ Binding fieldBinding = fieldPort.getBinding();
if (fieldBinding == null)
throw new WSIFException("Unable to locate Binding");
@@ -210,7 +224,7 @@
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();) {
+ for (Iterator ports = s.getPorts().values().iterator(); ports.hasNext();) {
javax.wsdl.Port p = (javax.wsdl.Port)ports.next();
if (p.getBinding() != null && p.getBinding().getQName().equals(fieldBinding.getQName())) {
// Binding found
@@ -228,7 +242,7 @@
// that one, otherwise use the one defined in the JMS message properties.
javax.wsdl.PortType portType = fieldBinding.getPortType();
if (portType!= null) {
- java.util.List operations = portType.getOperations();
+ List operations = portType.getOperations();
if (operations != null && operations.size() == 1 ) {
javax.wsdl.Operation o = (javax.wsdl.Operation)operations.get(0);
operationName = o.getName();
@@ -272,7 +286,7 @@
String input = null;
String output = null;
- javax.wsdl.Binding fieldBinding = fieldPort.getBinding();
+ Binding fieldBinding = fieldPort.getBinding();
if (fieldBinding == null)
throw new WSIFException("Unable to locate Binding");
@@ -282,7 +296,7 @@
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();) {
+ for (Iterator ports = s.getPorts().values().iterator(); ports.hasNext();) {
javax.wsdl.Port p = (javax.wsdl.Port)ports.next();
if (p.getBinding() != null && p.getBinding().getQName().equals(fieldBinding.getQName())) {
// Binding found
@@ -304,7 +318,7 @@
// Nothing defined. Resort to getting the info from the wsdl document
javax.wsdl.PortType portType = fieldBinding.getPortType();
if (portType!= null) {
- java.util.List operations = portType.getOperations();
+ List operations = portType.getOperations();
if (operations != null) {
if (operations.size() == 1) {
javax.wsdl.Operation o = (javax.wsdl.Operation)operations.get(0);
@@ -333,10 +347,10 @@
}
public void formatResponse(WSIFResponse resp, javax.jms.Message out)
- throws org.apache.wsif.WSIFException {
+ throws WSIFException {
Trc.entry(this, resp, out);
- javax.wsdl.Binding binding = fieldPort.getBinding();
- javax.wsdl.BindingOperation bop =
+ Binding binding = fieldPort.getBinding();
+ BindingOperation bop =
binding.getBindingOperation(
resp.getOperationName(),
resp.getInputName(),
@@ -360,19 +374,26 @@
* @see WSIFFormatter#unformatResponse(InputStream)
*/
public WSIFResponse unformatResponse(javax.jms.Message out)
- throws org.apache.wsif.WSIFException {
+ throws WSIFException {
+
Trc.entry(this, out);
// Need to construct the response.
WSIFResponse resp = createResponse(out);
- javax.wsdl.Binding binding = fieldPort.getBinding();
- javax.wsdl.BindingOperation bop =
+ Binding binding = fieldPort.getBinding();
+ BindingOperation bop =
binding.getBindingOperation(
resp.getOperationName(),
resp.getInputName(),
resp.getOutputName());
-
- javax.wsdl.Output output = bop.getOperation().getOutput();
+
+ if (unformatResponseFault(resp, out, binding, bop)) {
+ Trc.exit(resp);
+ return resp;
+ }
+
+ Operation op = bop.getOperation();
+ javax.wsdl.Output output = op.getOutput();
if ( output != null ) {
javax.wsdl.Message outMessage = output.getMessage();
@@ -392,50 +413,165 @@
return resp;
}
+ /**
+ * If this message is a fault message, unformat it, else do nothing
+ * @return true for a fault, false if it is not a fault.
+ */
+ private boolean unformatResponseFault(
+ WSIFResponse resp,
+ javax.jms.Message out,
+ Binding binding,
+ BindingOperation bop)
+ throws WSIFException {
+
+ Trc.entry(this, resp, out, binding, bop);
+
+ Map bndFs = bop.getBindingFaults();
+ if (bndFs != null && !bndFs.isEmpty()) {
+ Iterator itBndFNames = bndFs.keySet().iterator();
+ while (itBndFNames.hasNext()) {
+ String bndFName = (String) itBndFNames.next();
+ BindingFault bndF = (BindingFault) bndFs.get(bndFName);
+
+ List bndFElems = bndF.getExtensibilityElements();
+ if (bndFElems == null || bndFElems.isEmpty())
+ continue;
+
+ Iterator itBndFElems = bndFElems.iterator();
+ while (itBndFElems.hasNext()) {
+ Object bndFElem = itBndFElems.next();
+ if (bndFElem instanceof JMSFaultIndicator) {
+ JMSFaultIndicator indic = (JMSFaultIndicator) bndFElem;
+ String type = indic.getType();
+ if (type==null || !"property".equals(type)) continue;
+
+ List fProps = indic.getJMSFaultProperties();
+ if (fProps==null || fProps.isEmpty()) continue;
+
+ Iterator itFProps = fProps.iterator();
+ while (itFProps.hasNext()) {
+ JMSFaultProperty fProp = (JMSFaultProperty) itFProps.next();
+ String propName = fProp.getName();
+ if (propName == null
+ || fProp.getType() == null
+ || fProp.getValue() == null)
+ continue;
+
+ String propValue = null;
+ try {
+ if (!out.propertyExists(propName))
+ continue;
+
+ // Need to sort out the type here ???
+ // NativeJms propertyValues also ignore the type ???
+ // We assume the type is a string. This is a HACK.
+
+ propValue = out.getStringProperty(propName);
+ } catch (JMSException je) {
+ Trc.ignoredException(je);
+ continue;
+ }
+
+ if (propValue != null
+ && propValue.equals(fProp.getValue())) {
+
+ Operation op = bop.getOperation();
+ Fault fault = op.getFault(bndFName);
+ if (fault != null) {
+ javax.wsdl.Message faultMessage =
+ fault.getMessage();
+
+ JMSMessage fhMsg =
+ new JMSMessage(
+ fieldDefinition,
+ binding,
+ faultMessage,
+ getFaultParts(bndF));
+
+ fhMsg.read(out);
+
+ resp.setOutgoingMessage(fhMsg);
+ }
+
+ resp.setIsFault(true);
+ Trc.exit(true);
+ return true;
+ }
+
+ }
+
+ } else if (bndFElem instanceof JMSProperty) {
+ JMSProperty prop = (JMSProperty) bndFElem;
+ }
+ }
+ }
+ }
+ Trc.exit(false);
+ return false;
+ }
+
void copyTo(
- org.apache.wsif.WSIFMessage source,
- org.apache.wsif.WSIFMessage target)
+ WSIFMessage source,
+ WSIFMessage target)
throws WSIFException {
if (source == null || target == null)
return;
- for (java.util.Iterator i = source.getPartNames(); i.hasNext();) {
+ for (Iterator i = source.getPartNames(); i.hasNext();) {
String partName = i.next().toString();
target.setObjectPart(partName, source.getObjectPart(partName));
}
}
- private java.util.List getInputParts(
- javax.wsdl.BindingOperation bindingOperation) {
+ private List getInputParts(
+ BindingOperation bindingOperation) {
if (bindingOperation.getBindingInput() != null) {
- java.util.Iterator inputIterator =
+ Iterator inputIterator =
bindingOperation.getBindingInput().getExtensibilityElements().iterator();
while (inputIterator.hasNext()) {
- javax.wsdl.extensions.ExtensibilityElement ele =
- (javax.wsdl.extensions.ExtensibilityElement) inputIterator.next();
- if (ele instanceof org.apache.wsif.wsdl.extensions.jms.JMSInput) {
- return ((org.apache.wsif.wsdl.extensions.jms.JMSInput) ele).getParts();
+ ExtensibilityElement ele =
+ (ExtensibilityElement) inputIterator.next();
+ if (ele instanceof JMSInput) {
+ return ((JMSInput) ele).getParts();
}
}
}
return null;
}
- private java.util.List getOutputParts(
- javax.wsdl.BindingOperation bindingOperation) {
+ private List getOutputParts(
+ BindingOperation bindingOperation) {
if (bindingOperation.getBindingOutput() != null) {
- java.util.Iterator outputIterator =
+ Iterator outputIterator =
bindingOperation.getBindingOutput().getExtensibilityElements().iterator();
while (outputIterator.hasNext()) {
- javax.wsdl.extensions.ExtensibilityElement ele =
- (javax.wsdl.extensions.ExtensibilityElement) outputIterator.next();
- if (ele instanceof org.apache.wsif.wsdl.extensions.jms.JMSOutput) {
- return ((org.apache.wsif.wsdl.extensions.jms.JMSOutput) ele).getParts();
+ ExtensibilityElement ele =
+ (ExtensibilityElement) outputIterator.next();
+ if (ele instanceof JMSOutput) {
+ return ((JMSOutput) ele).getParts();
}
}
}
return null;
+ }
+
+ private List getFaultParts(BindingFault bindingFault) {
+ Trc.entry(this, bindingFault);
+
+ List list = null;
+ if (bindingFault != null) {
+ Iterator it = bindingFault.getExtensibilityElements().iterator();
+ while (it.hasNext()) {
+ Object ele = it.next();
+ if (ele instanceof JMSFault) {
+ list = ((JMSFault) ele).getParts();
+ break;
+ }
+ }
+ }
+ Trc.exit(list);
+ return list;
}
private String getOperationName() {
1.29 +21 -18 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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- WSIFOperation_Jms.java 1 Oct 2002 14:30:53 -0000 1.28
+++ WSIFOperation_Jms.java 7 Oct 2002 15:25:52 -0000 1.29
@@ -485,24 +485,27 @@
WSIFResponse resp =
formatter.unformatResponse((javax.jms.Message) responseObject);
- formatter.copyTo(resp.getFaultMessage(), fault);
-
- // the output message contains all response parts
- // even if not defined in the WSDL. Any parts
- // defined in the WSDL but not in the response
- // default to null
- ArrayList wsdlOutputParts = getWSDLOutputPartNames();
- WSIFMessage m = resp.getOutgoingMessage();
- if ( m != null ) {
- String partName;
- for (Iterator i = m.getPartNames(); i.hasNext();) {
- partName = (String) i.next();
- output.setObjectPart( partName, m.getObjectPart(partName) );
- wsdlOutputParts.remove( partName );
- }
- }
- for (Iterator i = wsdlOutputParts.iterator(); i.hasNext(); ) {
- output.setObjectPart( (String) i.next(), null );
+ if (resp.getIsFault())
+ formatter.copyTo(resp.getOutgoingMessage(), fault);
+ else {
+
+ // the output message contains all response parts
+ // even if not defined in the WSDL. Any parts
+ // defined in the WSDL but not in the response
+ // default to null
+ ArrayList wsdlOutputParts = getWSDLOutputPartNames();
+ WSIFMessage m = resp.getOutgoingMessage();
+ if (m != null) {
+ String partName;
+ for (Iterator i = m.getPartNames(); i.hasNext();) {
+ partName = (String) i.next();
+ output.setObjectPart(partName, m.getObjectPart(partName));
+ wsdlOutputParts.remove(partName);
+ }
+ }
+ for (Iterator i = wsdlOutputParts.iterator(); i.hasNext();) {
+ output.setObjectPart((String) i.next(), null);
+ }
}
/**
1.10 +42 -24 xml-axis-wsif/java/test/util/TestUtilities.java
Index: TestUtilities.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/util/TestUtilities.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TestUtilities.java 1 Oct 2002 15:06:17 -0000 1.9
+++ TestUtilities.java 7 Oct 2002 15:25:52 -0000 1.10
@@ -88,6 +88,12 @@
private static JMSAsyncListener asyncListener = null;
private static NativeJMSRequestListener nativeReqListener = null;
+ public static final int ADDRESSBOOK_LISTENER = 1;
+ public static final int STOCKQUOTE_LISTENER = 2;
+ public static final int ASYNC_LISTENER = 4;
+ public static final int NATIVEJMS_LISTENER = 8;
+ public static final int ALL_LISTENERS = 15;
+
public static final Class DEFAULT_SOAP_PROVIDER_CLASS =
WSIFDynamicProvider_ApacheAxis.class;
private static final String DEFAULT_SOAP_PROTOCOL =
@@ -213,30 +219,42 @@
* NativeJMSRequestListener - for the native JMS provider
* JMSAsynListener - for asynchronous operation tests
*/
- public static void startListeners()
- {
- if (TestUtilities.areWeTesting("jms"))
- {
- jmsAb = new BridgeThread("AddressBook");
- jmsSq = new BridgeThread("Stockquote");
- jmsAb.start();
- jmsSq.start();
- try {
- nativeReqListener =
- new NativeJMSRequestListener(
- TestUtilities.getWsifProperty("wsif.nativejms.requestq") );
- } catch (WSIFException ex) {
- ex.printStackTrace();
- }
- }
- if (TestUtilities.areWeTesting("async")) {
- try {
- asyncListener =
- new JMSAsyncListener( TestUtilities.getWsifProperty("wsif.async.replytoq") );
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
+ public static void startListeners() {
+ startListeners(ALL_LISTENERS);
+ }
+
+ public static void startListeners(int which) {
+ if (TestUtilities.areWeTesting("jms")) {
+ if ((which & ADDRESSBOOK_LISTENER) > 0) {
+ jmsAb = new BridgeThread("AddressBook");
+ jmsAb.start();
+ }
+
+ if ((which & STOCKQUOTE_LISTENER) > 0) {
+ jmsSq = new BridgeThread("Stockquote");
+ jmsSq.start();
+ }
+
+ if ((which & NATIVEJMS_LISTENER) > 0)
+ try {
+ nativeReqListener =
+ new NativeJMSRequestListener(
+ TestUtilities.getWsifProperty(
+ "wsif.nativejms.requestq"));
+ } catch (WSIFException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ if ((which & ASYNC_LISTENER) > 0
+ && TestUtilities.areWeTesting("async"))
+ try {
+ asyncListener =
+ new JMSAsyncListener(
+ TestUtilities.getWsifProperty("wsif.async.replytoq"));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
}
/**
1.13 +27 -1 xml-axis-wsif/java/test/org/apache/wsif/util/jms/NativeJMSRequestListener.java
Index: NativeJMSRequestListener.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/org/apache/wsif/util/jms/NativeJMSRequestListener.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- NativeJMSRequestListener.java 1 Oct 2002 15:06:16 -0000 1.12
+++ NativeJMSRequestListener.java 7 Oct 2002 15:25:52 -0000 1.13
@@ -263,6 +263,10 @@
} else if ( "whoami".equals( operationName ) ) {
reply = inoutWhoami( (ObjectMessage) msg );
sendReply( msg, reply );
+ } else if ( "noFault".equals( operationName ) ) {
+ noFault( (ObjectMessage) msg );
+ } else if ( "throwSimple".equals( operationName ) ) {
+ throwSimple( (ObjectMessage) msg );
} else {
System.err.println( "unknown operation: " + operationName ) ;
}
@@ -344,6 +348,28 @@
return hmr;
}
+ private void noFault(ObjectMessage msg) throws Exception {
+ sendReply(msg,"No Fault");
+ }
+
+ private void throwSimple(ObjectMessage msg) throws Exception {
+ Queue replyTo = (Queue) (msg.getJMSReplyTo());
+ if (replyTo == null)
+ return;
+
+ ObjectMessage faultMsg = (ObjectMessage) session.createObjectMessage();
+ faultMsg.setObject((Serializable) "A Simple Fault");
+
+ faultMsg.setStringProperty("faultIndicator","simple");
+ setReplyToQueue(replyTo);
+ String o = msg.getJMSMessageID();
+ try {
+ send(faultMsg, o, false);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
private String doFakeOp(String fake) {
fake = fake.substring( 1 ); // remove leading quote
fake = fake.substring( 0, fake.length() - 1 ); // remove trailing quote
@@ -374,7 +400,7 @@
Message replyMsg = session.createObjectMessage();
((ObjectMessage) replyMsg).setObject((Serializable) response);
- setEchoProperties(msg, replyMsg);
+ setEchoProperties( msg, replyMsg );
setReplyToQueue(replyTo);
String o = msg.getJMSMessageID();