antelder 2002/12/05 02:04:18
Modified: java/src/org/apache/wsif/providers/soap/apacheaxis
WSIFOperation_ApacheAxis.java
Log:
Start adding support for SOAP headers, and add add a bit more Javadoc
Revision Changes Path
1.42 +174 -66
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java
Index: WSIFOperation_ApacheAxis.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- WSIFOperation_ApacheAxis.java 3 Dec 2002 14:19:12 -0000 1.41
+++ WSIFOperation_ApacheAxis.java 5 Dec 2002 10:04:18 -0000 1.42
@@ -90,6 +90,7 @@
import javax.wsdl.extensions.soap.SOAPBody;
import javax.wsdl.extensions.soap.SOAPFault;
import javax.wsdl.extensions.soap.SOAPHeader;
+import javax.wsdl.extensions.soap.SOAPHeaderFault;
import javax.wsdl.extensions.soap.SOAPOperation;
import javax.xml.namespace.QName;
import javax.xml.soap.AttachmentPart;
@@ -141,6 +142,8 @@
import com.ibm.wsdl.extensions.mime.MIMEConstants;
/**
+ * The WSIFOperation class for invoking WSDL operations using Apache AXIS.
+ *
* @author Mark Whitlock <[EMAIL PROTECTED]>
* @author Ant Elder <[EMAIL PROTECTED]>
*/
@@ -181,16 +184,24 @@
protected QName[] outputPartTypeQNs;
protected int returnPartIndex;
+ transient protected Part inputSOAPHeader;
+ transient protected Part inputSOAPHeaderFault;
+ protected Part outputSOAPHeader;
+ protected Part outputSOAPHeaderFault;
+
+ /**
+ * Construct a new WSIFOperation
+ */
public WSIFOperation_ApacheAxis(
WSIFPort_ApacheAxis wsifPort,
Operation portTypeOperation,
- WSIFDynamicTypeMap wsifdynamictypemap)
+ WSIFDynamicTypeMap typeMap)
throws WSIFException {
- Trc.entry(this, wsifPort, portTypeOperation, wsifdynamictypemap);
+ Trc.entry(this, wsifPort, portTypeOperation, typeMap);
this.wsifPort = wsifPort;
this.portTypeOperation = portTypeOperation;
- this.typeMap = wsifdynamictypemap;
+ this.typeMap = typeMap;
this.bindingOperation = getBindingOperation(portTypeOperation);
@@ -207,15 +218,44 @@
// this.inputNamespace = bindingQN.getNamespaceURI();
// }
- addInputJmsPropertyValues(wsifPort.getJmsAddressPropVals());
-
if (Trc.ON)
Trc.exit(deep());
}
/**
- * Initialises instance variables relating to the WSDL soapOperation element
- * The WSDL has the form:
+ * Create a new copy of this object. This is not a clone, since
+ * it does not copy the referenced objects as well.
+ * TODO: should this also copy the inputxxx/outputxxx arrays?
+ * then prepare results would be cached?
+ */
+ public WSIFOperation_ApacheAxis copy() throws WSIFException {
+ Trc.entry(this);
+
+ WSIFOperation_ApacheAxis op =
+ new WSIFOperation_ApacheAxis(wsifPort, portTypeOperation,
typeMap);
+
+ op.setSoapActionURI(getSoapActionURI());
+ op.setInputNamespace(getInputNamespace());
+ op.setInputEncodingStyle(getInputEncodingStyle());
+ op.setOutputEncodingStyle(getOutputEncodingStyle());
+ op.setSoapPartNames(getSoapPartNames());
+ op.setMimePartNames(getMimePartNames());
+ op.setReturnName(getReturnName());
+ op.setAsyncOperation(isAsyncOperation());
+ op.setResponseHandler(getResponseHandler());
+ op.setInputJmsProperties(getInputJmsProperties());
+ op.setOutputJmsProperties(getOutputJmsProperties());
+ op.setInputJmsPropertyValues(getInputJmsPropertyValues());
+ op.setStyle(getStyle());
+
+ if (Trc.ON)
+ Trc.exit(op.deep());
+ return op;
+ }
+
+ /**
+ * Initialises instance variables relating to the WSDL soap:operation element
+ * The soap:operation WSDL element has the form:
* <soap:operation soapAction="uri"? style="rpc|document"?>?
*/
private void parseSoapOperation() throws WSIFException {
@@ -233,22 +273,22 @@
+ " for operation "
+ portTypeOperation.getName());
}
-
if (operationStyle == null || operationStyle.length() < 1) {
operationStyle = WSIFAXISConstants.STYLE_DOCUMENT;
}
}
/**
- *
+ * Initialises instance variables relating to the WSDL binding:input element
* The WSDL binding input has the form:
* <input>
* <soap:body parts="nmtokens"? use="literal|encoded"
* encodingStyle="uri-list"? namespace="uri"?>
* <soap:header message="qname" part="nmtoken" use="literal|encoded"
* encodingStyle="uri-list"? namespace="uri"?>*
- * <soap:headerfault message="qname" part="nmtoken"
use="literal|encoded"
- * encodingStyle="uri-list"? namespace="uri"?/>*
+ * <soap:headerfault message="qname"
+ * part="nmtoken" use="literal|encoded"
+ * encodingStyle="uri-list"? namespace="uri"?/>*
* <soap:header>
* </input>
*/
@@ -275,9 +315,9 @@
"In a binding operation that contains a
mime:multipartRelated, "
+ "a soap:body was found that was not in a
mime:part. "
+ "OperationName="
- + getOperationName());
+ + getName());
if (inMimeMultipart != null)
- parseMimeMultipart(inMimeMultipart, true, getOperationName());
+ parseMimeMultipart(inMimeMultipart, true, getName());
MIMEMimeXml inMimeMimeXml =
(MIMEMimeXml) wsifPort.getExtElem(
@@ -287,16 +327,9 @@
if (inMimeMimeXml != null)
throw new WSIFException(
"WSIF does not support mime:mimeXml. Operation="
- + getOperationName());
+ + getName());
- SOAPHeader soapheader =
- (SOAPHeader) wsifPort.getExtElem(
- bindinginput,
- javax.wsdl.extensions.soap.SOAPHeader.class,
- bindinginput.getExtensibilityElements());
- if (soapheader != null)
- throw new WSIFException(
- "not supported input soap:header " + soapheader);
+ parseSOAPHeaderElement(bindinginput);
List inJmsProps =
wsifPort.getExtElems(
@@ -348,9 +381,9 @@
"In a binding operation that contains a
mime:multipartRelated, "
+ "a soap:body was found that was not
in a mime:part. "
+ "OperationName="
- + getOperationName());
+ + getName());
if (outMimeMultipart != null)
- parseMimeMultipart(outMimeMultipart, false,
getOperationName());
+ parseMimeMultipart(outMimeMultipart, false, getName());
MIMEMimeXml outMimeMimeXml =
(MIMEMimeXml) wsifPort.getExtElem(
@@ -360,16 +393,10 @@
if (outMimeMimeXml != null)
throw new WSIFException(
"WSIF does not support mime:mimeXml.
Operation="
- + getOperationName());
+ + getName());
+
+ parseSOAPHeaderElement(bindingoutput);
- SOAPHeader soapheader =
- (SOAPHeader) wsifPort.getExtElem(
- bindingoutput,
- javax.wsdl.extensions.soap.SOAPHeader.class,
- outExtElems);
- if (soapheader != null)
- throw new WSIFException(
- "not supported output soap:header " +
soapheader);
for (Iterator iterator1 =
bindingOperation.getBindingFaults().values().iterator();
iterator1.hasNext();
@@ -396,6 +423,90 @@
}
/**
+ * Parses any SOAP header elements in the binding input or output.
+ * The WSDL soap:header element has the form:
+ * <soap:header message="qname" part="nmtoken" use="literal|encoded"
+ * encodingStyle="uri-list"? namespace="uri"?>*
+ * <soap:headerfault message="qname" part="nmtoken" use="literal|encoded"
+ * encodingStyle="uri-list"? namespace="uri"?/>*
+ * <soap:header>
+ */
+ private void parseSOAPHeaderElement(Object element) throws WSIFException {
+
+ List extensabilityElements;
+ if (element instanceof BindingInput) {
+ extensabilityElements =
+ ((BindingInput) element).getExtensibilityElements();
+ } else if (element instanceof BindingOutput) {
+ extensabilityElements =
+ ((BindingOutput) element).getExtensibilityElements();
+ } else {
+ throw new WSIFException(
+ "internal error, unexpected object: " + element);
+ }
+
+ Part soapHeaderPart = null;
+ Part soapHeaderFaultPart = null;
+
+ SOAPHeader soapHeader =
+ (SOAPHeader) wsifPort.getExtElem(
+ element,
+ javax.wsdl.extensions.soap.SOAPHeader.class,
+ extensabilityElements);
+ if (soapHeader != null) {
+ QName messageName = soapHeader.getMessage();
+ if (messageName == null) {
+ throw new WSIFException(
+ "no message attribute on soap:header: " +
soapHeader);
+ }
+ String messagePart = soapHeader.getPart();
+ if (messagePart == null) {
+ throw new WSIFException(
+ "no part attribute on soap:header: " +
soapHeader);
+ }
+ soapHeaderPart = getPart(messageName, messagePart);
+ if (soapHeaderPart == null) {
+ throw new WSIFException(
+ "non existent part specified on soap:header: "
+ + soapHeader);
+ }
+
+ SOAPHeaderFault soapHeaderFault =
+ (SOAPHeaderFault) wsifPort.getExtElem(
+ soapHeader,
+
javax.wsdl.extensions.soap.SOAPHeaderFault.class,
+ extensabilityElements);
+ if (soapHeaderFault != null) {
+ messageName = soapHeader.getMessage();
+ if (messageName == null) {
+ throw new WSIFException(
+ "no message attribute on soap:header:
" + soapHeader);
+ }
+ messagePart = soapHeader.getPart();
+ if (messagePart == null) {
+ throw new WSIFException(
+ "no part attribute on soap:header: " +
soapHeader);
+ }
+ soapHeaderFaultPart = getPart(messageName,
messagePart);
+ if (soapHeaderFaultPart == null) {
+ throw new WSIFException(
+ "non existent part specified on
soap:header: "
+ + soapHeader);
+ }
+ }
+ }
+
+ if (element instanceof BindingInput) {
+ this.inputSOAPHeader = soapHeaderPart;
+ this.inputSOAPHeaderFault = soapHeaderFaultPart;
+ } else {
+ this.outputSOAPHeader = soapHeaderPart;
+ this.outputSOAPHeaderFault = soapHeaderFaultPart;
+ }
+ //TODO now go and do something with them...
+ }
+
+ /**
* Validates the soap:body WSDL element.
* The soap:body WSDL element has the form:
* <soap:body parts="nmtokens"? use="literal|encoded"
@@ -429,6 +540,15 @@
return list2;
}
+ /**
+ * Parses the mime:multipartRelated WSDL element
+ * The mime:multipartRelated element has the form:
+ * <mime:multipartRelated>
+ * <mime:part> *
+ * <-- mime element -->
+ * </mime:part>
+ * </mime:multipartRelated>
+ */
private void parseMimeMultipart(
MIMEMultipartRelated mimeMultipart,
boolean isInput,
@@ -557,10 +677,9 @@
Trc.exit();
}
- public String getOperationName() {
- return portTypeOperation.getName();
- }
-
+ /**
+ * Gets the WSDL binding:operation element for this operation
+ */
private BindingOperation getBindingOperation(Operation operation)
throws WSIFException {
Binding binding = wsifPort.getPort().getBinding();
@@ -575,36 +694,9 @@
}
/**
- * Create a new copy of this object. This is not a clone, since
- * it does not copy the referenced objects as well.
- * TODO: should this also copy the inputxxx/outputxxx arrays?
- * then prepare results would be cached?
+ * Returns the Definition object for the WSDL file
+ * @return Definition the WSDL4J Definition object
*/
- public WSIFOperation_ApacheAxis copy() throws WSIFException {
- Trc.entry(this);
-
- WSIFOperation_ApacheAxis op =
- new WSIFOperation_ApacheAxis(wsifPort, portTypeOperation,
typeMap);
-
- op.setSoapActionURI(getSoapActionURI());
- op.setInputNamespace(getInputNamespace());
- op.setInputEncodingStyle(getInputEncodingStyle());
- op.setOutputEncodingStyle(getOutputEncodingStyle());
- op.setSoapPartNames(getSoapPartNames());
- op.setMimePartNames(getMimePartNames());
- op.setReturnName(getReturnName());
- op.setAsyncOperation(isAsyncOperation());
- op.setResponseHandler(getResponseHandler());
- op.setInputJmsProperties(getInputJmsProperties());
- op.setOutputJmsProperties(getOutputJmsProperties());
- op.setInputJmsPropertyValues(getInputJmsPropertyValues());
- op.setStyle(getStyle());
-
- if (Trc.ON)
- Trc.exit(op.deep());
- return op;
- }
-
public Definition getDefinition() {
Trc.entry(this);
Definition d = wsifPort.getDefinition();
@@ -653,6 +745,19 @@
}
/**
+ * Returns the WSDL Part for a part in a particular message
+ */
+ private Part getPart(QName message, String partName) {
+ Part p = null;
+ Definition def = wsifPort.getDefinition();
+ javax.wsdl.Message m = def.getMessage(message);
+ if (m != null) {
+ p = m.getPart(partName);
+ }
+ return p;
+ }
+
+ /**
* Gets the portType wsdl:operation element used by this WSIFOperation
* @return Operation the WSDL4J portType Operation object
*/
@@ -1538,6 +1643,9 @@
*/
private void prepare(Call call) throws WSIFException {
Trc.entry(this, call);
+
+ // register any jms:address propertyValues
+ addInputJmsPropertyValues(wsifPort.getJmsAddressPropVals());
// register any WSIFDynamicTypeMappings
registerTypeMappings(call);