antelder 2002/12/03 03:40:35
Modified: java/src/org/apache/wsif/providers/soap/apacheaxis
WSIFPort_ApacheAxis.java
WSIFOperation_ApacheAxis.java
Log:
Continuing tidyup of the AXIS provider
Revision Changes Path
1.20 +95 -102
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java
Index: WSIFPort_ApacheAxis.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WSIFPort_ApacheAxis.java 2 Dec 2002 13:26:20 -0000 1.19
+++ WSIFPort_ApacheAxis.java 3 Dec 2002 11:40:35 -0000 1.20
@@ -87,11 +87,17 @@
import org.apache.wsif.logging.Trc;
import org.apache.wsif.providers.WSIFDynamicTypeMap;
import org.apache.wsif.util.WSIFProperties;
+import org.apache.wsif.util.WSIFUtils;
import org.apache.wsif.util.jms.WSIFJMSDestination;
import org.apache.wsif.util.jms.WSIFJMSFinder;
import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
/**
+ * This class implements a WSDL SOAP binding using Apache AXIS.
+ * See section 3 of the WSDL 1.1 specification for details
+ * of the WSDL SOAP binding. WSIF extends this standard SOAP
+ * binding with the WSIF extensions for SOAP over JMS.
+ *
* @author Mark Whitlock <[EMAIL PROTECTED]>
* @author Ant Elder <[EMAIL PROTECTED]>
*/
@@ -110,7 +116,7 @@
protected List jmsAddressPropVals;
protected WSIFDynamicTypeMap wsifdynamictypemap;
- protected Map operationInstances;
+ protected Map cachedWSIFOperations;
transient protected Transport transport;
transient protected Call call;
@@ -136,9 +142,8 @@
this.soapBinding = soapBinding;
this.wsifdynamictypemap = wsifdynamictypemap;
- initializeSoapBinding();
- initializeServiceAddress();
- operationInstances = new HashMap();
+ parseSoapBinding();
+ parseServiceAddress();
if (Trc.ON)
Trc.exit(deep());
@@ -146,8 +151,10 @@
/**
* Gets the soap:binding WSDL element and validates its attributes
+ * The soap:binding WSDL element has the form:
+ * <soap:binding style="rpc|document" transport="uri">
*/
- private void initializeSoapBinding() throws WSIFException {
+ private void parseSoapBinding() throws WSIFException {
this.bindingStyle = soapBinding.getStyle();
if (bindingStyle == null || bindingStyle.length() < 1) {
bindingStyle = WSIFAXISConstants.STYLE_DOCUMENT;
@@ -172,8 +179,25 @@
/**
* Gets the soap:address or jms:address WSDL element from the service port
* and validates it against the binding transport.
+ * <port .... >
+ * <soap:address location="uri"/>?
+ * <jms:address destinationStyle="topic|queue"
+ * jmsVendorURI="uri"?
+ * initialContextFactory="uri"?
+ * jndiProviderURL="uri"?
+ * jndiConnectionFactoryName="nmtoken"
+ * jndiDestinationName="nmtoken"
+ * <jms:propertyValue
+ * name="nmtoken" value="nmtoken" type="qname">*
+ * </jms:address>?
+ * <jms:address jmsVendorURI="uri"
+ * jmsImplementationSpecificURI="uri"
+ * <jms:propertyValue
+ * name="nmtoken" value="nmtoken" type="qname">*
+ * </jms:address>?
+ * </port>
*/
- private void initializeServiceAddress() throws WSIFException {
+ private void parseServiceAddress() throws WSIFException {
this.soapAddress =
(SOAPAddress) getExtElem(port,
SOAPAddress.class,
@@ -234,7 +258,8 @@
/**
* Creates a WSIFOperation for the given operation name
* @return WSIFOperation the WSIFOperation
- * @see WSIFOperation.createOperation
+ * @see WSIFOperation#createOperation(opName)
+ * @throws WSIFException if there is an exception creating the WSIFOperation
*/
public WSIFOperation createOperation(String operationName)
throws WSIFException {
@@ -246,8 +271,9 @@
/**
* Creates a WSIFOperation for the given operation name
- * @return WSIFOperation the WSIFOperation
- * @see WSIFOperation.createOperation
+ * @return WSIFOperation the WSIFOperation_ApacheAxis
+ * @see WSIFOperation#createOperation(opName, inName, outName)
+ * @throws WSIFException if there is an exception creating the WSIFOperation
*/
public WSIFOperation createOperation(
String operationName,
@@ -275,6 +301,7 @@
/**
* Closes the port.
* All methods are invalid after calling this method.
+ * @throws WSIFException if there is an exception closing the Transport
*/
public void close() throws WSIFException {
Trc.entry(this);
@@ -319,20 +346,22 @@
/**
* Gets the AXIS Call object being used by this WSIFPort
* @return Call the AXIS Call object
+ * @throws WSIFException if there is an exception creating the AXIS Call
*/
public Call getCall() throws WSIFException {
Trc.entry(this);
if (call == null) {
- Transport axistransport = getTransport();
java.net.URL url = getEndPoint();
try {
if (url != null) {
call = new Call(url);
+ Transport axistransport = getTransport();
if (axistransport != null) {
axistransport.setUrl(url.toString());
}
- } else
+ } else {
call = new Call(new
org.apache.axis.client.Service());
+ }
} catch (JAXRPCException e) {
Trc.exception(e);
throw new WSIFException(
@@ -357,83 +386,45 @@
}
/**
- * @deprecated replaced by the createOperation methods
- */ //TODO make this private or merge into createOp method
+ * @deprecated WSIF clients should use the createOperation methods
+ */
public WSIFOperation_ApacheAxis getDynamicWSIFOperation(
- String name,
+ String opName,
String inputName,
String outputName)
throws WSIFException {
- Trc.entry(this, name, inputName, outputName);
+ Trc.entry(this, opName, inputName, outputName);
- WSIFOperation_ApacheAxis wsifOperation = null;
-
- WSIFOperation_ApacheAxis tempOp =
- (WSIFOperation_ApacheAxis) operationInstances.get(
- getKey(name, inputName, outputName));
-
- if (tempOp != null) {
- wsifOperation = tempOp.copy();
- }
-
- if (wsifOperation == null) {
- // TODO I don't really understand what this is doing
- // TODO can't I delete all this now???
- BindingOperation bindingOperationModel =
- port.getBinding().getBindingOperation(
- name,
- inputName,
- outputName);
- if (bindingOperationModel != null) {
- // Only one operation matched in binding so find it in
instances
- // from all the information that is available to us
- Iterator i = operationInstances.keySet().iterator();
- while (i.hasNext()) {
- String key = (String) i.next();
- if ((outputName != null &&
key.endsWith(outputName))
- || outputName == null) {
- String start =
- (inputName == null)
- ? name + ":"
- : name + ":" +
inputName;
- if (key.startsWith(start)) {
- if (wsifOperation != null) {
- // Duplicate operation
found based on names!
- wsifOperation = null;
- break;
- }
- wsifOperation =
- (
-
WSIFOperation_ApacheAxis) operationInstances
- .get(
- key);
- }
- }
- }
- }
-
- Binding binding = port.getBinding();
- PortType portType = binding.getPortType();
- Operation operation =
- portType.getOperation(name, inputName, outputName);
- if (operation == null) {
+ WSIFOperation_ApacheAxis cachedOp = null;
+
+ if (cachedWSIFOperations == null) {
+ cachedWSIFOperations = new HashMap();
+ } else {
+ cachedOp = (WSIFOperation_ApacheAxis) cachedWSIFOperations.get(
+ getKey(opName, inputName, outputName));
+ }
+
+ if (cachedOp == null) {
+ BindingOperation bop =
+ WSIFUtils.getBindingOperation(
+ port.getBinding(), opName, inputName, outputName );
+ if (bop == null) {
throw new WSIFException(
"no operation found named " +
- name + ", input:" + inputName + ", output:" +
outputName );
+ opName + ", input:" + inputName + ", output:" +
outputName );
}
- String opName = operation.getName();
- Input input = operation.getInput();
- Output output = operation.getOutput();
- wsifOperation =
+ cachedOp =
new WSIFOperation_ApacheAxis(
this,
- operation,
+ bop.getOperation(),
wsifdynamictypemap);
- operationInstances.put(
+ cachedWSIFOperations.put(
getKey(opName, inputName, outputName),
- wsifOperation);
+ cachedOp);
}
+ WSIFOperation_ApacheAxis wsifOperation = cachedOp.copy();
+
Trc.exit(wsifOperation);
return wsifOperation;
}
@@ -448,9 +439,10 @@
return endPointURL;
}
+ //TODO these getExtElem methods should be moved to ProviderUtils?
/**
* Wrapper to enable WSIFOperation to use the same WSIFDefaultPort method
- * @see WSIFDefaultPort.getExtElem
+ * @see WSIFDefaultPort#getExtElem
*/
public Object getExtElem(Object ctx, Class extType, List extElems)
throws WSIFException {
@@ -462,7 +454,7 @@
/**
* Wrapper to enable WSIFOperation to use the same WSIFDefaultPort method
- * @see WSIFDefaultPort.getExtElems
+ * @see WSIFDefaultPort#getExtElems
*/
public List getExtElems(Object ctx, Class extType, List extElems)
throws WSIFException {
@@ -493,8 +485,17 @@
}
/**
- * Gets the soap:operation WSDL element for a BindingOperation
+ * Gets the soap:operation WSDL element from a BindingOperation
+ * The WSDL binding operation element has the form:
+ * <binding .... >
+ * ...
+ * <operation .... >
+ * <soap:operation soapAction="uri"? style="rpc|document"?>?
+ * ...
+ * </operation>
+ * </binding>
* @return SOAPOperation the soap:operation element
+ * @throws WSIFException if there is no soap:operation element in the binding
operation element.
*/
public SOAPOperation getSOAPOperation(BindingOperation bindingOp)
throws WSIFException {
@@ -513,6 +514,7 @@
/**
* Gets the AXIS Transport object being used by this WSIFPort
* @return Transport the AXIS Transport object
+ * @throws WSIFException if there is an exception creating the Transport
*/
public Transport getTransport() throws WSIFException {
Trc.entry(this);
@@ -577,7 +579,10 @@
String s2,
WSIFOperation_ApacheAxis wsifoperation_apacheaxis) {
Trc.entry(this, s, s1, s2, wsifoperation_apacheaxis);
- operationInstances.put(getKey(s, s1, s2), wsifoperation_apacheaxis);
+ if (cachedWSIFOperations == null) {
+ cachedWSIFOperations = new HashMap();
+ }
+ cachedWSIFOperations.put(getKey(s, s1, s2), wsifoperation_apacheaxis);
Trc.exit();
}
@@ -619,30 +624,18 @@
try {
buff.append(new String(super.toString()));
buff.append(":\n");
- buff.append(" port: ");
- buff.append(port);
- buff.append(" definition: ");
- buff.append(definition);
- buff.append(" soapbinding: ");
- buff.append(soapBinding);
- buff.append(" bindingStyle: ");
- buff.append(bindingStyle);
- buff.append(" soapAddress: ");
- buff.append(soapAddress);
- buff.append(" jmsAddress: ");
- buff.append(jmsAddress);
- buff.append(" service url: ");
- buff.append(endPointURL);
- buff.append(" jmsAddressPropVals: ");
- buff.append(jmsAddressPropVals);
- buff.append(" dynamicTypeMap: ");
- buff.append(wsifdynamictypemap);
- buff.append(" transport: ");
- buff.append(transport);
- buff.append(" call: ");
- buff.append(call);
- buff.append("operationInstances: ");
- buff.append(operationInstances);
+ buff.append(" port: ").append(port);
+ buff.append(" definition: ").append(definition);
+ buff.append(" soapbinding: ").append(soapBinding);
+ buff.append(" bindingStyle: ").append(bindingStyle);
+ buff.append(" soapAddress: ").append(soapAddress);
+ buff.append(" jmsAddress: ").append(jmsAddress);
+ buff.append(" service url: ").append(endPointURL);
+ buff.append(" jmsAddressPropVals:
").append(jmsAddressPropVals);
+ buff.append(" dynamicTypeMap: ").append(wsifdynamictypemap);
+ buff.append(" transport: ").append(transport);
+ buff.append(" call: ").append(call);
+ buff.append("operationInstances:
").append(cachedWSIFOperations);
} catch (Exception e) {
Trc.exceptionInTrace(e);
}
1.39 +68 -65
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.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- WSIFOperation_ApacheAxis.java 2 Dec 2002 13:26:38 -0000 1.38
+++ WSIFOperation_ApacheAxis.java 3 Dec 2002 11:40:35 -0000 1.39
@@ -150,6 +150,7 @@
transient protected WSIFPort_ApacheAxis wsifPort;
transient protected Operation portTypeOperation;
+ transient protected BindingOperation bindingOperation;
transient protected SOAPOperation soapOperation;
transient protected List soapPartNames;
transient protected List mimePartNames;
@@ -191,12 +192,11 @@
this.portTypeOperation = portTypeOperation;
this.typeMap = wsifdynamictypemap;
- BindingOperation bindingOperation =
- getBindingOperation(portTypeOperation);
+ this.bindingOperation = getBindingOperation(portTypeOperation);
- initialiseSoapOperation(bindingOperation);
- initialiseBindingInput(bindingOperation);
- initialiseBindingOutput(bindingOperation);
+ parseSoapOperation();
+ parseBindingInput();
+ parseBindingOutput();
this.inputEncodingStyle = WSIFAXISConstants.DEFAULT_SOAP_ENCODING_URI;
this.outputEncodingStyle = WSIFAXISConstants.DEFAULT_SOAP_ENCODING_URI;
@@ -219,7 +219,7 @@
* The WSDL has the form:
* <soap:operation soapAction="uri"? style="rpc|document"?>?
*/
- private void initialiseSoapOperation(BindingOperation bindingOperation) throws
WSIFException {
+ private void parseSoapOperation() throws WSIFException {
this.soapOperation =
wsifPort.getSOAPOperation(bindingOperation);
@@ -238,9 +238,22 @@
"no style specified on either soap:binding or
soap:operation" );
}
}
-
- private void initialiseBindingInput(BindingOperation bindingoperation) throws
WSIFException {
- BindingInput bindinginput = bindingoperation.getBindingInput();
+
+ /**
+ *
+ * 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:header>
+ * </input>
+ */
+ private void parseBindingInput() throws WSIFException {
+ BindingInput bindinginput = bindingOperation.getBindingInput();
List inExtElems = bindinginput.getExtensibilityElements();
SOAPBody inSoapBody =
(SOAPBody) wsifPort.getExtElem(bindinginput,
@@ -249,7 +262,6 @@
if (inSoapBody != null) {
List list2 =
parseSoapBody(
- soapOperation,
inSoapBody,
true);
setSoapPartNames(list2);
@@ -268,8 +280,6 @@
if (inMimeMultipart != null)
parseMimeMultipart(
inMimeMultipart,
- bindingoperation,
- soapOperation,
true,
getOperationName());
@@ -315,8 +325,8 @@
}
}
- private void initialiseBindingOutput(BindingOperation bindingoperation) throws
WSIFException {
- BindingOutput bindingoutput =
bindingoperation.getBindingOutput();
+ private void parseBindingOutput() throws WSIFException {
+ BindingOutput bindingoutput =
bindingOperation.getBindingOutput();
if (bindingoutput != null) {
List outExtElems =
bindingoutput.getExtensibilityElements();
SOAPBody outSoapBody =
@@ -326,7 +336,6 @@
if (outSoapBody != null) {
List list3 =
parseSoapBody(
- soapOperation,
outSoapBody,
false);
if (list3 != null && list3.size() > 0)
@@ -347,8 +356,6 @@
if (outMimeMultipart != null)
parseMimeMultipart(
outMimeMultipart,
- bindingoperation,
- soapOperation,
false,
getOperationName());
@@ -369,7 +376,7 @@
throw new WSIFException(
"not supported output soap:header " +
soapheader);
for (Iterator iterator1 =
-
bindingoperation.getBindingFaults().values().iterator();
+
bindingOperation.getBindingFaults().values().iterator();
iterator1.hasNext();
) {
BindingFault bindingfault = (BindingFault)
iterator1.next();
@@ -390,13 +397,17 @@
}
}
+ /**
+ * Validates the soap:body WSDL element.
+ * The soap:body WSDL element has the form:
+ * <soap:body parts="nmtokens"? use="literal|encoded"
+ * encodingStyle="uri-list"? namespace="uri"?>
+ */
private List parseSoapBody(
- SOAPOperation soapoperation,
SOAPBody soapbody,
boolean isInput)
throws WSIFException {
-
- Trc.entry(this, soapoperation, soapbody, new Boolean(isInput));
+ Trc.entry(this, soapbody, new Boolean(isInput));
if (isInput) {
String ns = soapbody.getNamespaceURI();
@@ -408,7 +419,7 @@
String use = soapbody.getUse();
if (!WSIFAXISConstants.VALID_USES.contains(use)) {
throw new WSIFException(
- "unsupported use " + use + " in " + soapoperation);
+ "unsupported use " + use + " in " + soapOperation);
}
if (isInput) {
@@ -424,21 +435,17 @@
private void parseMimeMultipart(
MIMEMultipartRelated mimeMultipart,
- BindingOperation bindingoperation,
- SOAPOperation soapoperation,
boolean isInput,
String operationName)
throws WSIFException {
Trc.entry(
this,
- mimeMultipart,
- bindingoperation,
- soapoperation);
+ mimeMultipart);
Vector mimePartNames = new Vector();
boolean soapBodyFound = false;
- Operation op = bindingoperation.getOperation();
+ Operation op = bindingOperation.getOperation();
Map mapInParts = op.getInput().getMessage().getParts();
Map mapOutParts =
op.getOutput() == null
@@ -456,7 +463,7 @@
.equals(mimePart.getElementType().getNamespaceURI()))
throw new WSIFException(
"A MIME part in binding operation "
- + bindingoperation.getName()
+ + bindingOperation.getName()
+ " did not have the correct
namespace URI of "
+ MIMEConstants.NS_URI_MIME
+ ".");
@@ -475,7 +482,7 @@
mimePart.getElementType().getNamespaceURI()))
throw new WSIFException(
"A MIME part in
binding operation "
- +
bindingoperation.getName()
+ +
bindingOperation.getName()
+ " did not
have the correct namespace URI of "
+
MIMEConstants.NS_URI_MIME
+ ".");
@@ -519,7 +526,6 @@
List soapPartNameList =
parseSoapBody(
- soapoperation,
(SOAPBody) nextChild,
isInput);
@@ -574,7 +580,6 @@
operation.getName());
}
return bindingOp;
-
}
/**
@@ -1741,7 +1746,7 @@
*/
private void unWrapIfWrappedDocLit(List parts, String operationName)
throws WSIFException {
- if (!"message".equals(operationStyle)) {
+ if (!WSIFAXISConstants.AXIS_STYLE_MESSAGE.equals(operationStyle)) {
Part p = WSIFUtils.getWrappedDocLiteralPart(parts, operationName);
if (p != null) {
List unWrappedParts = WSIFUtils.unWrapPart(p,
getDefinition());
@@ -2268,41 +2273,39 @@
}
public String deep() {
- String buff = "";
+ StringBuffer buff = new StringBuffer();
try {
- buff = new String(super.toString() + ":\n");
-
- buff += "portInstance:" + wsifPort;
- buff += " operation:" + Trc.brief(portTypeOperation);
- buff += " soapPartNames:" + soapPartNames;
- buff += " mimePartNames:" + mimePartNames;
- buff += " inputEncodingStyle:" + inputEncodingStyle;
- buff += " inputNamespace:" + inputNamespace;
- buff += " actionUri:" + soapActionURI;
- buff += " inJmsProps:" + inJmsProps;
- buff += " outJmsProps:" + outJmsProps;
- buff += " inJmsPropVals:" + inJmsPropVals;
- buff += " context:" + context;
- buff += " asyncOperation:" + asyncOperation;
- buff += " asyncRequestID:" + asyncRequestID;
- buff += " responseHandler:" + responseHandler;
- buff += " returnName:" + returnName;
- buff += " inputPartNames:" + inputPartNames;
- buff += " inputPartQNs:" + inputPartQNs;
- buff += " inputPartTypes:" + inputPartTypes;
- buff += " inputPartTypeQN:" + inputPartTypeQNs;
- buff += " outputPartNames:" + outputPartNames;
- buff += " outputPartQNs:" + outputPartQNs;
- buff += " outputPartTypes:" + outputPartTypes;
- buff += " outputPartTypeQN:" + outputPartTypeQNs;
- buff += " returnPartIndex:" + returnPartIndex;
- buff += " outParams:" + outParams;
- buff += " outputEncodingStyle:" + outputEncodingStyle;
- buff += " typeMap:" + typeMap;
+ buff.append(super.toString()).append(":\n");
+ buff.append("portInstance:").append(wsifPort);
+ buff.append("
operation:").append(Trc.brief(portTypeOperation));
+ buff.append(" soapPartNames:").append(soapPartNames);
+ buff.append(" mimePartNames:").append(mimePartNames);
+ buff.append(" inputEncodingStyle:").append(inputEncodingStyle);
+ buff.append(" inputNamespace:").append(inputNamespace);
+ buff.append(" actionUri:").append(soapActionURI);
+ buff.append(" inJmsProps:").append(inJmsProps);
+ buff.append(" outJmsProps:").append(outJmsProps);
+ buff.append(" inJmsPropVals:").append(inJmsPropVals);
+ buff.append(" context:").append(context);
+ buff.append(" asyncOperation:").append(asyncOperation);
+ buff.append(" asyncRequestID:").append(asyncRequestID);
+ buff.append(" responseHandler:").append(responseHandler);
+ buff.append(" returnName:").append(returnName);
+ buff.append(" inputPartNames:").append(inputPartNames);
+ buff.append(" inputPartQNs:").append(inputPartQNs);
+ buff.append(" inputPartTypes:").append(inputPartTypes);
+ buff.append(" inputPartTypeQN:").append(inputPartTypeQNs);
+ buff.append(" outputPartNames:").append(outputPartNames);
+ buff.append(" outputPartQNs:").append(outputPartQNs);
+ buff.append(" outputPartTypes:").append(outputPartTypes);
+ buff.append(" outputPartTypeQN:").append(outputPartTypeQNs);
+ buff.append(" returnPartIndex:").append(returnPartIndex);
+ buff.append(" outParams:").append(outParams);
+ buff.append("
outputEncodingStyle:").append(outputEncodingStyle);
+ buff.append(" typeMap:").append(typeMap);
} catch (Exception e) {
Trc.exceptionInTrace(e);
}
-
- return buff;
+ return buff.toString();
}
}