antelder 2002/12/03 06:19:12
Modified: java/src/org/apache/wsif/providers/soap/apacheaxis
WSIFOperation_ApacheAxis.java
Log:
No changes just format the AXIS Operation code
Revision Changes Path
1.41 +455 -437
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.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- WSIFOperation_ApacheAxis.java 3 Dec 2002 13:37:01 -0000 1.40
+++ WSIFOperation_ApacheAxis.java 3 Dec 2002 14:19:12 -0000 1.41
@@ -147,13 +147,13 @@
public class WSIFOperation_ApacheAxis extends WSIFDefaultOperation {
private static final long serialVersionUID = 1L;
-
+
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;
+ transient protected SOAPOperation soapOperation;
+ transient protected List soapPartNames;
+ transient protected List mimePartNames;
transient protected String inputEncodingStyle;
transient protected String inputNamespace;
transient protected String soapActionURI;
@@ -180,7 +180,7 @@
protected Class[] outputPartTypes;
protected QName[] outputPartTypeQNs;
protected int returnPartIndex;
-
+
public WSIFOperation_ApacheAxis(
WSIFPort_ApacheAxis wsifPort,
Operation portTypeOperation,
@@ -191,220 +191,217 @@
this.wsifPort = wsifPort;
this.portTypeOperation = portTypeOperation;
this.typeMap = wsifdynamictypemap;
-
+
this.bindingOperation = getBindingOperation(portTypeOperation);
- parseSoapOperation();
- parseBindingInput();
- parseBindingOutput();
+ parseSoapOperation();
+ parseBindingInput();
+ parseBindingOutput();
this.inputEncodingStyle = WSIFAXISConstants.DEFAULT_SOAP_ENCODING_URI;
this.outputEncodingStyle = WSIFAXISConstants.DEFAULT_SOAP_ENCODING_URI;
-//TODO???
-// QName bindingQN = wsifPort.getBindingName();
-// if (bindingQN != null) {
-// this.inputNamespace = bindingQN.getNamespaceURI();
-// }
+ //TODO???
+ // QName bindingQN = wsifPort.getBindingName();
+ // if (bindingQN != null) {
+ // this.inputNamespace = bindingQN.getNamespaceURI();
+ // }
- addInputJmsPropertyValues(
- wsifPort.getJmsAddressPropVals());
+ addInputJmsPropertyValues(wsifPort.getJmsAddressPropVals());
if (Trc.ON)
Trc.exit(deep());
}
- /**
- * Initialises instance variables relating to the WSDL soapOperation element
- * The WSDL has the form:
- * <soap:operation soapAction="uri"? style="rpc|document"?>?
- */
- private void parseSoapOperation() throws WSIFException {
+ /**
+ * Initialises instance variables relating to the WSDL soapOperation element
+ * The WSDL has the form:
+ * <soap:operation soapAction="uri"? style="rpc|document"?>?
+ */
+ private void parseSoapOperation() throws WSIFException {
- this.soapOperation =
- wsifPort.getSOAPOperation(bindingOperation);
+ this.soapOperation = wsifPort.getSOAPOperation(bindingOperation);
this.soapActionURI = soapOperation.getSoapActionURI();
this.operationStyle = soapOperation.getStyle();
- if (operationStyle == null || operationStyle.length() < 1 ) {
+ if (operationStyle == null || operationStyle.length() < 1) {
operationStyle = wsifPort.getBindingStyle();
} else if (!WSIFAXISConstants.VALID_STYLES.contains(operationStyle)) {
- throw new WSIFException(
- "unsupported style " + operationStyle + " for operation "
+ portTypeOperation.getName());
+ throw new WSIFException(
+ "unsupported style "
+ + operationStyle
+ + " for operation "
+ + portTypeOperation.getName());
}
-
- if (operationStyle == null || operationStyle.length() < 1 ) {
+
+ if (operationStyle == null || operationStyle.length() < 1) {
operationStyle = WSIFAXISConstants.STYLE_DOCUMENT;
}
- }
-
- /**
- *
- * 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,
+ }
+
+ /**
+ *
+ * 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,
+ javax.wsdl.extensions.soap.SOAPBody.class,
+ inExtElems);
+ if (inSoapBody != null) {
+ List list2 = parseSoapBody(inSoapBody, true);
+ setSoapPartNames(list2);
+ }
+
+ MIMEMultipartRelated inMimeMultipart =
+ (MIMEMultipartRelated) wsifPort.getExtElem(
+ bindinginput,
+ MIMEMultipartRelated.class,
+ inExtElems);
+ if (inSoapBody != null && inMimeMultipart != null)
+ throw new WSIFException(
+ "In a binding operation that contains a
mime:multipartRelated, "
+ + "a soap:body was found that was not in a
mime:part. "
+ + "OperationName="
+ + getOperationName());
+ if (inMimeMultipart != null)
+ parseMimeMultipart(inMimeMultipart, true, getOperationName());
+
+ MIMEMimeXml inMimeMimeXml =
+ (MIMEMimeXml) wsifPort.getExtElem(
+ bindinginput,
+ MIMEMimeXml.class,
+ inExtElems);
+ if (inMimeMimeXml != null)
+ throw new WSIFException(
+ "WSIF does not support mime:mimeXml. Operation="
+ + getOperationName());
+
+ 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);
+
+ List inJmsProps =
+ wsifPort.getExtElems(
+ bindinginput,
+ JMSProperty.class,
+ bindinginput.getExtensibilityElements());
+ if (inJmsProps != null && inJmsProps.size() > 0) {
+ if (wsifPort.isTransportJMS())
+ setInputJmsProperties(inJmsProps);
+ else
+ throw new WSIFException("jms:properties found in
non-jms binding");
+ }
+
+ List inJmsPropVals =
+ wsifPort.getExtElems(
+ bindinginput,
+ JMSPropertyValue.class,
+ bindinginput.getExtensibilityElements());
+ if (inJmsPropVals != null && inJmsPropVals.size() > 0) {
+ if (wsifPort.isTransportJMS())
+ addInputJmsPropertyValues(inJmsPropVals);
+ else
+ throw new WSIFException("jms:propertyValue found in
non-jms binding");
+ }
+ }
+
+ private void parseBindingOutput() throws WSIFException {
+ BindingOutput bindingoutput = bindingOperation.getBindingOutput();
+ if (bindingoutput != null) {
+ List outExtElems = bindingoutput.getExtensibilityElements();
+ SOAPBody outSoapBody =
+ (SOAPBody) wsifPort.getExtElem(
+ bindingoutput,
javax.wsdl.extensions.soap.SOAPBody.class,
- inExtElems);
- if (inSoapBody != null) {
- List list2 =
- parseSoapBody(
- inSoapBody,
- true);
- setSoapPartNames(list2);
+ outExtElems);
+ if (outSoapBody != null) {
+ List list3 = parseSoapBody(outSoapBody, false);
+ if (list3 != null && list3.size() > 0)
+ setReturnName((String) list3.get(0));
}
- MIMEMultipartRelated inMimeMultipart =
- (MIMEMultipartRelated)
wsifPort.getExtElem(bindinginput,
+ MIMEMultipartRelated outMimeMultipart =
+ (MIMEMultipartRelated) wsifPort.getExtElem(
+ bindingoutput,
MIMEMultipartRelated.class,
- inExtElems);
- if (inSoapBody != null && inMimeMultipart != null)
+ outExtElems);
+ if (outSoapBody != null && outMimeMultipart != null)
throw new WSIFException(
"In a binding operation that contains a
mime:multipartRelated, "
+ "a soap:body was found that was not
in a mime:part. "
+ "OperationName="
+ getOperationName());
- if (inMimeMultipart != null)
- parseMimeMultipart(
- inMimeMultipart,
- true,
- getOperationName());
+ if (outMimeMultipart != null)
+ parseMimeMultipart(outMimeMultipart, false,
getOperationName());
- MIMEMimeXml inMimeMimeXml =
- (MIMEMimeXml) wsifPort.getExtElem(bindinginput,
+ MIMEMimeXml outMimeMimeXml =
+ (MIMEMimeXml) wsifPort.getExtElem(
+ bindingoutput,
MIMEMimeXml.class,
- inExtElems);
- if (inMimeMimeXml != null)
+ outExtElems);
+ if (outMimeMimeXml != null)
throw new WSIFException(
- "WSIF does not support mime:mimeXml.
Operation=" + getOperationName());
+ "WSIF does not support mime:mimeXml.
Operation="
+ + getOperationName());
SOAPHeader soapheader =
- (SOAPHeader) wsifPort.getExtElem(bindinginput,
+ (SOAPHeader) wsifPort.getExtElem(
+ bindingoutput,
javax.wsdl.extensions.soap.SOAPHeader.class,
- bindinginput.getExtensibilityElements());
+ outExtElems);
if (soapheader != null)
throw new WSIFException(
- "not supported input soap:header " +
soapheader);
-
- List inJmsProps =
+ "not supported output soap:header " +
soapheader);
+ for (Iterator iterator1 =
+
bindingOperation.getBindingFaults().values().iterator();
+ iterator1.hasNext();
+ ) {
+ BindingFault bindingfault = (BindingFault)
iterator1.next();
+ SOAPFault soapfault =
+ (SOAPFault) wsifPort.getExtElem(
+ bindingfault,
+
javax.wsdl.extensions.soap.SOAPFault.class,
+
bindingfault.getExtensibilityElements());
+ }
+ List outJmsProps =
wsifPort.getExtElems(
- bindinginput,
+ bindingoutput,
JMSProperty.class,
- bindinginput.getExtensibilityElements());
- if (inJmsProps != null && inJmsProps.size() > 0) {
+ outExtElems);
+ if (outJmsProps != null && outJmsProps.size() > 0) {
if (wsifPort.isTransportJMS())
- setInputJmsProperties(inJmsProps);
+ setOutputJmsProperties(outJmsProps);
else
throw new WSIFException("jms:properties found
in non-jms binding");
}
+ }
+ }
- List inJmsPropVals =
- wsifPort.getExtElems(
- bindinginput,
- JMSPropertyValue.class,
- bindinginput.getExtensibilityElements());
- if (inJmsPropVals != null && inJmsPropVals.size() > 0) {
- if (wsifPort.isTransportJMS())
- addInputJmsPropertyValues(
- inJmsPropVals);
- else
- throw new WSIFException("jms:propertyValue
found in non-jms binding");
- }
- }
-
- private void parseBindingOutput() throws WSIFException {
- BindingOutput bindingoutput =
bindingOperation.getBindingOutput();
- if (bindingoutput != null) {
- List outExtElems =
bindingoutput.getExtensibilityElements();
- SOAPBody outSoapBody =
- (SOAPBody) wsifPort.getExtElem(bindingoutput,
-
javax.wsdl.extensions.soap.SOAPBody.class,
- outExtElems);
- if (outSoapBody != null) {
- List list3 =
- parseSoapBody(
- outSoapBody,
- false);
- if (list3 != null && list3.size() > 0)
- setReturnName(
- (String) list3.get(0));
- }
-
- MIMEMultipartRelated outMimeMultipart =
- (MIMEMultipartRelated)
wsifPort.getExtElem(bindingoutput,
- MIMEMultipartRelated.class,
- outExtElems);
- if (outSoapBody != null && outMimeMultipart != null)
- throw new WSIFException(
- "In a binding operation that contains
a mime:multipartRelated, "
- + "a soap:body was found that
was not in a mime:part. "
- + "OperationName="
- + getOperationName());
- if (outMimeMultipart != null)
- parseMimeMultipart(
- outMimeMultipart,
- false,
- getOperationName());
-
- MIMEMimeXml outMimeMimeXml =
- (MIMEMimeXml)
wsifPort.getExtElem(bindingoutput,
- MIMEMimeXml.class,
- outExtElems);
- if (outMimeMimeXml != null)
- throw new WSIFException(
- "WSIF does not support mime:mimeXml.
Operation="
- + getOperationName());
-
- 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();
- ) {
- BindingFault bindingfault = (BindingFault)
iterator1.next();
- SOAPFault soapfault =
- (SOAPFault)
wsifPort.getExtElem(bindingfault,
-
javax.wsdl.extensions.soap.SOAPFault.class,
-
bindingfault.getExtensibilityElements());
- }
- List outJmsProps =
- wsifPort.getExtElems(bindingoutput,
JMSProperty.class, outExtElems);
- if (outJmsProps != null && outJmsProps.size() > 0) {
- if (wsifPort.isTransportJMS())
- setOutputJmsProperties(
- outJmsProps);
- else
- throw new
WSIFException("jms:properties found in non-jms binding");
- }
- }
- }
-
- /**
- * 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(
- SOAPBody soapbody,
- boolean isInput)
+ /**
+ * 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(SOAPBody soapbody, boolean isInput)
throws WSIFException {
Trc.entry(this, soapbody, new Boolean(isInput));
@@ -438,9 +435,7 @@
String operationName)
throws WSIFException {
- Trc.entry(
- this,
- mimeMultipart);
+ Trc.entry(this, mimeMultipart);
Vector mimePartNames = new Vector();
boolean soapBodyFound = false;
@@ -524,17 +519,14 @@
+
operationName);
List soapPartNameList =
- parseSoapBody(
- (SOAPBody) nextChild,
- isInput);
+ parseSoapBody((SOAPBody)
nextChild, isInput);
if (isInput)
setSoapPartNames(soapPartNameList);
else if (
soapPartNameList != null
&&
soapPartNameList.size() > 0)
- setReturnName(
- (String)
soapPartNameList.get(0));
+ setReturnName((String)
soapPartNameList.get(0));
} else if (nextChild instanceof
MIMEMultipartRelated) {
throw new WSIFException(
"WSIF does not support nesting
mime:multipartRelated "
@@ -565,18 +557,19 @@
Trc.exit();
}
- public String getOperationName() {
- return portTypeOperation.getName();
- }
+ public String getOperationName() {
+ return portTypeOperation.getName();
+ }
- private BindingOperation getBindingOperation(Operation operation) throws
WSIFException {
+ private BindingOperation getBindingOperation(Operation operation)
+ throws WSIFException {
Binding binding = wsifPort.getPort().getBinding();
BindingOperation bindingOp =
WSIFUtils.getBindingOperation(binding, operation);
if (bindingOp == null) {
throw new WSIFException(
- "cannot find binding operation for port operation:" +
- operation.getName());
+ "cannot find binding operation for port operation:"
+ + operation.getName());
}
return bindingOp;
}
@@ -604,7 +597,7 @@
op.setResponseHandler(getResponseHandler());
op.setInputJmsProperties(getInputJmsProperties());
op.setOutputJmsProperties(getOutputJmsProperties());
- op.setInputJmsPropertyValues(getInputJmsPropertyValues());
+ op.setInputJmsPropertyValues(getInputJmsPropertyValues());
op.setStyle(getStyle());
if (Trc.ON)
@@ -637,11 +630,11 @@
return inputNamespace;
}
- /**
- * Gets the name of the portType wsdl:operation element
- * being used by this WSIFOperation
- * @return String the operation name
- */
+ /**
+ * Gets the name of the portType wsdl:operation element
+ * being used by this WSIFOperation
+ * @return String the operation name
+ */
public String getName() {
Trc.entry(this);
String s = portTypeOperation.getName();
@@ -649,9 +642,9 @@
return s;
}
- /**
- * @deprecated use getPortTypeOperation
- */
+ /**
+ * @deprecated use getPortTypeOperation
+ */
public Operation getOperation() {
Trc.entry(this);
Operation o = getPortTypeOperation();
@@ -659,10 +652,10 @@
return o;
}
- /**
- * Gets the portType wsdl:operation element used by this WSIFOperation
- * @return Operation the WSDL4J portType Operation object
- */
+ /**
+ * Gets the portType wsdl:operation element used by this WSIFOperation
+ * @return Operation the WSDL4J portType Operation object
+ */
public Operation getPortTypeOperation() {
Trc.entry(this);
Trc.exit(portTypeOperation);
@@ -871,7 +864,7 @@
if (!wsifPort.supportsAsync()) {
throw new WSIFException("asynchronous operations not
available");
}
-
+
//TODO why not, no reason they shouldn't work???
if (WSIFAXISConstants.STYLE_DOCUMENT.equals(operationStyle)) {
throw new WSIFException("docstyle asynchronous operations not
implemented yet");
@@ -974,8 +967,8 @@
msgContext.setResponseMessage(responseMessage);
// This registerTypeMapping code is duplicated in prepare
- //registerTypeMappings(call);
- //TODO: need to sort out this duplicated code
+ //registerTypeMappings(call);
+ //TODO: need to sort out this duplicated code
TypeMappingRegistry tmr = msgContext.getTypeMappingRegistry();
org.apache.axis.encoding.TypeMapping tm =
(org.apache.axis.encoding.TypeMapping)
tmr.getTypeMapping(
@@ -1078,10 +1071,14 @@
private void populateOutMsgReturnPart(Object resp, WSIFMessage outMsg)
throws WSIFException {
if (outMsg != null && outputPartNames.length > 0) {
- // If resp==null then the service returned null.
+ // If resp==null then the service returned null.
// This may be the a correct return value
// and so set the output message part value to null
- setMessagePart(outMsg, outputPartNames[returnPartIndex], resp,
outputPartTypes[returnPartIndex]);
+ setMessagePart(
+ outMsg,
+ outputPartNames[returnPartIndex],
+ resp,
+ outputPartTypes[returnPartIndex]);
}
}
@@ -1094,28 +1091,28 @@
HashMap respParms = getResponseMsgParams();
ArrayList wsdlOutParts = new ArrayList();
- for (int i=0; i<outputPartNames.length; i++) {
- if (i != returnPartIndex) {
- wsdlOutParts.add(outputPartNames[i]);
- }
+ for (int i = 0; i < outputPartNames.length; i++) {
+ if (i != returnPartIndex) {
+ wsdlOutParts.add(outputPartNames[i]);
+ }
}
if (respParms != null) {
String name;
Object value;
- for (Iterator i = respParms.keySet().iterator();
- i.hasNext();
- ) {
-
- name = (String) i.next();
- value = respParms.get(name);
- setMessagePart(
- outMsg,
- name,
- value,
- value == null ? null : value.getClass());
- wsdlOutParts.remove(name);
- }
+ for (Iterator i = respParms.keySet().iterator();
+ i.hasNext();
+ ) {
+
+ name = (String) i.next();
+ value = respParms.get(name);
+ setMessagePart(
+ outMsg,
+ name,
+ value,
+ value == null ? null :
value.getClass());
+ wsdlOutParts.remove(name);
+ }
}
// init any other parts to null
for (Iterator i = wsdlOutParts.iterator(); i.hasNext();) {
@@ -1124,102 +1121,103 @@
}
}
- private static void setMessagePart(
- WSIFMessage msg,
- String name,
- Object value,
- Class type)
- throws WSIFException {
- Trc.entry(null, msg, name, value, type);
-
- Class valueType = value == null ? null : value.getClass();
- try {
- if (valueType != null
- && DataHandler.class.equals(type)
- && AttachmentPart.class.isAssignableFrom(valueType)) {
- AttachmentPart ap = (AttachmentPart) value;
- DataHandler dh = ap.getDataHandler();
- msg.setObjectPart(name, dh);
- } else if (
-// Attachments that are Strings, Images, etc are unsupported at present.
-// Attachments can only be DataHandlers.
- valueType != null
- && (String.class.equals(type)
- || Image.class.equals(type)
- || StreamSource.class.equals(type)
- || DOMSource.class.equals(type)
- || SAXSource.class.equals(type)
- || MimeMultipart.class.equals(type))
- && AttachmentPart.class.isAssignableFrom(valueType)) {
-
- AttachmentPart ap = (AttachmentPart) value;
- InputStream is = ap.getDataHandler().getInputStream();
-
- if (String.class.equals(type)) {
- byte[] bBuff = new byte[is.available()];
- is.read(bBuff);
- msg.setObjectPart(name, new String(bBuff));
- } else if (Image.class.equals(type)) {
- byte[] bBuff = new byte[is.available()];
- is.read(bBuff);
- msg.setObjectPart(name, new ImageIcon(bBuff).getImage());
- } else if (StreamSource.class.equals(type))
- // Warning: this next line of code has never been tested.
- msg.setObjectPart(name, new StreamSource(is));
- else if (DOMSource.class.equals(type))
- throw new WSIFException("DOMSource is not supported");
- else if (SAXSource.class.equals(type))
- throw new WSIFException("SAXSource is not supported");
- else if (MimeMultipart.class.equals(type))
- // Warning: this next line of code has never been tested.
- msg.setObjectPart(
- name,
- new MimeMultipart(ap.getDataHandler().getDataSource()));
- } else if (
- valueType != null
- && type != null // will be null for async responses
- && !type.isPrimitive()
- && !(type.isAssignableFrom(valueType))) {
- throw new WSIFException(
- "return value "
- + value
- + " has unexpected type "
- + valueType
- + " instead of "
- + type);
- } else
- msg.setObjectPart(name, value);
- } catch (SOAPException se) {
- Trc.exception(se);
- throw new WSIFException(
- "WSIFOperation_ApacheAxis.setMessagePart messageName="
- + (msg.getName() == null ? "null" : msg.getName())
- + " partName="
- + name
- + " caught "
- + se);
- } catch (IOException ioe) {
- Trc.exception(ioe);
- throw new WSIFException(
- "WSIFOperation_ApacheAxis.setMessagePart messageName="
- + (msg.getName() == null ? "null" : msg.getName())
- + " partName="
- + name
- + " caught "
- + ioe);
- } catch (MessagingException me) {
- Trc.exception(me);
- throw new WSIFException(
- "WSIFOperation_ApacheAxis.setMessagePart messageName="
- + (msg.getName() == null ? "null" : msg.getName())
- + " partName="
- + name
- + " caught "
- + me);
- }
+ private static void setMessagePart(
+ WSIFMessage msg,
+ String name,
+ Object value,
+ Class type)
+ throws WSIFException {
+ Trc.entry(null, msg, name, value, type);
- Trc.exit();
- }
+ Class valueType = value == null ? null : value.getClass();
+ try {
+ if (valueType != null
+ && DataHandler.class.equals(type)
+ && AttachmentPart.class.isAssignableFrom(valueType)) {
+ AttachmentPart ap = (AttachmentPart) value;
+ DataHandler dh = ap.getDataHandler();
+ msg.setObjectPart(name, dh);
+ } else if (
+ // Attachments that are Strings, Images,
etc are unsupported at present.
+ // Attachments can only be DataHandlers.
+ valueType
+ != null
+ && (String.class.equals(type)
+ || Image.class.equals(type)
+ || StreamSource.class.equals(type)
+ || DOMSource.class.equals(type)
+ || SAXSource.class.equals(type)
+ || MimeMultipart.class.equals(type))
+ &&
AttachmentPart.class.isAssignableFrom(valueType)) {
+
+ AttachmentPart ap = (AttachmentPart) value;
+ InputStream is = ap.getDataHandler().getInputStream();
+
+ if (String.class.equals(type)) {
+ byte[] bBuff = new byte[is.available()];
+ is.read(bBuff);
+ msg.setObjectPart(name, new String(bBuff));
+ } else if (Image.class.equals(type)) {
+ byte[] bBuff = new byte[is.available()];
+ is.read(bBuff);
+ msg.setObjectPart(name, new
ImageIcon(bBuff).getImage());
+ } else if (StreamSource.class.equals(type))
+ // Warning: this next line of code has never
been tested.
+ msg.setObjectPart(name, new StreamSource(is));
+ else if (DOMSource.class.equals(type))
+ throw new WSIFException("DOMSource is not
supported");
+ else if (SAXSource.class.equals(type))
+ throw new WSIFException("SAXSource is not
supported");
+ else if (MimeMultipart.class.equals(type))
+ // Warning: this next line of code has never
been tested.
+ msg.setObjectPart(
+ name,
+ new
MimeMultipart(ap.getDataHandler().getDataSource()));
+ } else if (
+ valueType != null
+ && type != null // will be null for async
responses
+ && !type.isPrimitive()
+ && !(type.isAssignableFrom(valueType))) {
+ throw new WSIFException(
+ "return value "
+ + value
+ + " has unexpected type "
+ + valueType
+ + " instead of "
+ + type);
+ } else
+ msg.setObjectPart(name, value);
+ } catch (SOAPException se) {
+ Trc.exception(se);
+ throw new WSIFException(
+ "WSIFOperation_ApacheAxis.setMessagePart messageName="
+ + (msg.getName() == null ? "null" :
msg.getName())
+ + " partName="
+ + name
+ + " caught "
+ + se);
+ } catch (IOException ioe) {
+ Trc.exception(ioe);
+ throw new WSIFException(
+ "WSIFOperation_ApacheAxis.setMessagePart messageName="
+ + (msg.getName() == null ? "null" :
msg.getName())
+ + " partName="
+ + name
+ + " caught "
+ + ioe);
+ } catch (MessagingException me) {
+ Trc.exception(me);
+ throw new WSIFException(
+ "WSIFOperation_ApacheAxis.setMessagePart messageName="
+ + (msg.getName() == null ? "null" :
msg.getName())
+ + " partName="
+ + name
+ + " caught "
+ + me);
+ }
+
+ Trc.exit();
+ }
public boolean invokeRequestResponseOperation(
WSIFMessage wsifmessage,
@@ -1263,7 +1261,8 @@
}
if (obj != null) {
if (inputPartTypes[i] == null)
- throw new WSIFException("Cannot map type " +
inputPartNames[i]);
+ throw new WSIFException(
+ "Cannot map type " +
inputPartNames[i]);
if (!isPrimitiveOf(obj.getClass(), inputPartTypes[i])
&&
!inputPartTypes[i].isAssignableFrom(obj.getClass())) {
@@ -1353,23 +1352,24 @@
inputEncodingStyle = "";
outputEncodingStyle = "";
- //TODO need to sort out the namespace
+ //TODO need to sort out the namespace
QName bindingQN = wsifPort.getBindingName();
if (bindingQN != null) {
- setInputNamespace(bindingQN.getNamespaceURI());
+ setInputNamespace(bindingQN.getNamespaceURI());
}
Input inputMsg = portTypeOperation.getInput();
if (inputMsg != null) {
- List parts = inputMsg.getMessage().getOrderedParts(null);
- if (WSIFUtils.isWrappedDocLiteral(parts,
portTypeOperation.getName())) {
- operationStyle = WSIFAXISConstants.AXIS_STYLE_WRAPPED;
- }
+ List parts = inputMsg.getMessage().getOrderedParts(null);
+ if (WSIFUtils
+ .isWrappedDocLiteral(parts,
portTypeOperation.getName())) {
+ operationStyle = WSIFAXISConstants.AXIS_STYLE_WRAPPED;
+ }
}
if (isMessaging(inMsg)) {
operationStyle = WSIFAXISConstants.AXIS_STYLE_MESSAGE;
- }
+ }
if (inputPartNames == null) {
prepare(call);
@@ -1388,12 +1388,14 @@
}
}
- if (dest != null && inJmsPropVals != null && !inJmsPropVals.isEmpty())
{
+ if (dest != null
+ && inJmsPropVals != null
+ && !inJmsPropVals.isEmpty()) {
checkForTimeoutProperties(inJmsPropVals, dest);
dest.setProperties(inJmsPropVals);
}
- //TODO: jms:property parts
+ //TODO: jms:property parts
setDestinationContext(dest);
setCallContext(call);
@@ -1412,10 +1414,10 @@
boolean allDOMElements = true;
boolean anyDOMElements = false;
- //TODO this should ignore any MIME parts
+ //TODO this should ignore any MIME parts
if (msg != null) {
for (Iterator i = msg.getParts(); i.hasNext();) {
- Object o = i.next();
+ Object o = i.next();
if (o instanceof Element) {
anyDOMElements = true;
} else {
@@ -1435,7 +1437,8 @@
boolean respOK = false;
// setup the call object
- call.setOperationName(new QName(getInputNamespace(),
portTypeOperation.getName()));
+ call.setOperationName(
+ new QName(getInputNamespace(), portTypeOperation.getName()));
call.setScopedProperty(Call.SEND_TYPE_ATTR, Boolean.FALSE);
call.setScopedProperty(AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
call.setOperationStyle(operationStyle);
@@ -1456,7 +1459,7 @@
outputPartTypeQNs[returnPartIndex],
outputPartTypes[returnPartIndex]);
- // invoke the AXIS call
+ // invoke the AXIS call
Trc.event(this, "Invoking AXIS call", call, inputValues);
Object response;
try {
@@ -1470,7 +1473,7 @@
}
Trc.event(this, "Returned from AXIS invoke, response: ", response);
- // process the AXIS response
+ // process the AXIS response
if (!isAsyncOperation() && outputPartTypes[returnPartIndex] != null) {
Map callParams = call.getOutputParams();
if (callParams != null) {
@@ -1498,15 +1501,15 @@
boolean workedOK = false;
- Object[] inputValues = getInputMessageValues(inMsg);
- SOAPBodyElement[] axisInputs =
- new SOAPBodyElement[inputValues.length];
+ Object[] inputValues = getInputMessageValues(inMsg);
+ SOAPBodyElement[] axisInputs = new SOAPBodyElement[inputValues.length];
for (int i = 0; i < inputValues.length; i++) {
- if ( inputValues[i] instanceof Element) {
- axisInputs[i] = new SOAPBodyElement((Element)inputValues[i]);
- } else {
- throw new WSIFException("unexpected input type: " +
inputValues[i]);
- }
+ if (inputValues[i] instanceof Element) {
+ axisInputs[i] = new SOAPBodyElement((Element)
inputValues[i]);
+ } else {
+ throw new WSIFException(
+ "unexpected input type: " + inputValues[i]);
+ }
}
call.setOperationStyle(WSIFAXISConstants.AXIS_STYLE_MESSAGE);
@@ -1528,32 +1531,42 @@
return workedOK;
}
- /**
- * Prepares this operation.
- * The intention of this is to setup everything that can be
- * reused by the operation.
- */
+ /**
+ * Prepares this operation.
+ * The intention of this is to setup everything that can be
+ * reused by the operation.
+ */
private void prepare(Call call) throws WSIFException {
- Trc.entry(this,call);
+ Trc.entry(this, call);
// register any WSIFDynamicTypeMappings
- registerTypeMappings(call);
+ registerTypeMappings(call);
// create the arrays for the input parts
List inputParts = getInputParts();
this.inputPartNames = getPartNamesArray(inputParts);
this.inputPartQNs = getPartQNamesArray(inputParts);
this.inputPartTypeQNs = getPartTypeQNamesArray(inputParts);
- this.inputPartTypes = getPartTypesArray(inputParts, call,
inputEncodingStyle);
- registerMIMETypes(inputPartNames, inputPartTypes, inputPartTypeQNs,
call);
+ this.inputPartTypes =
+ getPartTypesArray(inputParts, call, inputEncodingStyle);
+ registerMIMETypes(
+ inputPartNames,
+ inputPartTypes,
+ inputPartTypeQNs,
+ call);
// create the arrays for the output parts
List outputParts = getOutputParts();
this.outputPartNames = getPartNamesArray(outputParts);
this.outputPartQNs = getPartQNamesArray(outputParts);
this.outputPartTypeQNs = getPartTypeQNamesArray(outputParts);
- this.outputPartTypes = getPartTypesArray(outputParts, call,
outputEncodingStyle);
- registerMIMETypes(outputPartNames, outputPartTypes, outputPartTypeQNs,
call);
+ this.outputPartTypes =
+ getPartTypesArray(outputParts, call, outputEncodingStyle);
+ registerMIMETypes(
+ outputPartNames,
+ outputPartTypes,
+ outputPartTypeQNs,
+ call);
// the index in the output part arrays of the return part
this.returnPartIndex = getReturnPartIndex();
@@ -1561,9 +1574,9 @@
Trc.exit();
}
- /**
- * Register all the type mappings with the AXIS Call object
- */
+ /**
+ * Register all the type mappings with the AXIS Call object
+ */
private void registerTypeMappings(Call call) throws WSIFException {
Class objClass;
String namespaceURI, localPart;
@@ -1573,7 +1586,7 @@
wsifdynamictypemapping = (WSIFDynamicTypeMapping)
iterator.next();
objClass = wsifdynamictypemapping.getJavaType();
QName xmlType = wsifdynamictypemapping.getXmlType();
-
+
SerializerFactory sf = null;
DeserializerFactory df = null;
if (tm.getSerializer(objClass, xmlType) == null) {
@@ -1611,28 +1624,29 @@
qn,
JAFDataHandlerSerializerFactory.class,
JAFDataHandlerDeserializerFactory.class);
- } else if (
- // Attachments that are Images, Strings are unsupported at
present.
- // Attachments can only be DataHandlers.
- Image.class.equals(objClass)
-// || String.class.equals(objClass)
- || Source.class.equals(objClass)
- || MimeMultipart.class.equals(objClass)) {
- call.registerTypeMapping(
- objClass,
- qn,
- JAFDataHandlerSerializerFactory.class,
- JAFDataHandlerDeserializerFactory.class);
+ } else if (
+ // Attachments that are Images, Strings are
unsupported at present.
+ // Attachments can only be DataHandlers.
+ Image
+ .class
+ .equals(objClass) // ||
String.class.equals(objClass)
+ || Source.class.equals(objClass)
+ ||
MimeMultipart.class.equals(objClass)) {
+ call.registerTypeMapping(
+ objClass,
+ qn,
+ JAFDataHandlerSerializerFactory.class,
+
JAFDataHandlerDeserializerFactory.class);
} else if (sf != null || df != null) {
- call.registerTypeMapping(objClass, qn, sf, df);
+ call.registerTypeMapping(objClass, qn, sf, df);
}
}
}
}
- /**
- * Gets an array of all the input WSIFMessage values
- */
+ /**
+ * Gets an array of all the input WSIFMessage values
+ */
private Object[] getInputMessageValues(WSIFMessage inMsg)
throws WSIFException {
@@ -1661,8 +1675,10 @@
return axisInputs;
}
- //TODO why can't this use buildResponseMessages
- private void setOutputMessageValues(Object axisResponse, WSIFMessage outMsg)
+ //TODO why can't this use buildResponseMessages
+ private void setOutputMessageValues(
+ Object axisResponse,
+ WSIFMessage outMsg)
throws WSIFException {
if (!(axisResponse instanceof Vector)) {
throw new WSIFException(
@@ -1746,12 +1762,12 @@
private void unWrapIfWrappedDocLit(List parts, String operationName)
throws WSIFException {
if (!WSIFAXISConstants.AXIS_STYLE_MESSAGE.equals(operationStyle)) {
- Part p = WSIFUtils.getWrappedDocLiteralPart(parts, operationName);
- if (p != null) {
- List unWrappedParts = WSIFUtils.unWrapPart(p,
getDefinition());
- parts.remove(p);
- parts.addAll(unWrappedParts);
- }
+ Part p = WSIFUtils.getWrappedDocLiteralPart(parts,
operationName);
+ if (p != null) {
+ List unWrappedParts = WSIFUtils.unWrapPart(p,
getDefinition());
+ parts.remove(p);
+ parts.addAll(unWrappedParts);
+ }
}
}
@@ -1788,8 +1804,8 @@
for (int i = 0; i < parts.size(); i++) {
Part p = (Part) parts.get(i);
qnames[i] = p.getTypeName();
- if (qnames[i]==null) {
- qnames[i] = p.getElementName();
+ if (qnames[i] == null) {
+ qnames[i] = p.getElementName();
}
}
return qnames;
@@ -1798,13 +1814,15 @@
/**
* Returns a Class array of the class of each part
*/
- private Class[] getPartTypesArray(List parts, Call call, String encodingStyle)
+ private Class[] getPartTypesArray(
+ List parts,
+ Call call,
+ String encodingStyle)
throws WSIFException {
TypeMappingRegistry registry =
call.getMessageContext().getTypeMappingRegistry();
- Object o =
- registry.getTypeMapping( encodingStyle );
+ Object o = registry.getTypeMapping(encodingStyle);
if (!(o instanceof TypeMapping)) {
throw new WSIFException("expecting a TypeMapping but found: "
+ o);
}
@@ -1819,9 +1837,7 @@
}
if (partQN == null) {
throw new WSIFException(
- "part "
- + p
- + " must have type name or element
declared");
+ "part " + p + " must have type name or element
declared");
}
if
(WSIFAXISConstants.AXIS_STYLE_MESSAGE.equals(operationStyle)) {
types[i] = Element.class;
@@ -1857,25 +1873,25 @@
* (unless the user has already typemapped them explicitly)
*/
private void registerMIMETypes(
- String[] partNames,
- Class[] partTypes,
- QName[] partTypeQNs,
- Call call) {
+ String[] partNames,
+ Class[] partTypes,
+ QName[] partTypeQNs,
+ Call call) {
//TODO shouldn't there be in + out mimePartNames
- if (mimePartNames != null) {
- for (int i = 0; i < partNames.length; i++) {
-// if (partTypes[i] == null // no user explicit mapping
-// && mimePartNames.contains(partNames[i])) {
- if (mimePartNames.contains(partNames[i])) {
- partTypes[i] = DataHandler.class;
- call.registerTypeMapping(
- DataHandler.class,
- partTypeQNs[i],
- JAFDataHandlerSerializerFactory.class,
- JAFDataHandlerDeserializerFactory.class);
- }
- }
- }
+ if (mimePartNames != null) {
+ for (int i = 0; i < partNames.length; i++) {
+ // if (partTypes[i] == null //
no user explicit mapping
+ // &&
mimePartNames.contains(partNames[i])) {
+ if (mimePartNames.contains(partNames[i])) {
+ partTypes[i] = DataHandler.class;
+ call.registerTypeMapping(
+ DataHandler.class,
+ partTypeQNs[i],
+ JAFDataHandlerSerializerFactory.class,
+
JAFDataHandlerDeserializerFactory.class);
+ }
+ }
+ }
}
/**
@@ -1897,9 +1913,9 @@
return responseHandler;
}
- /**
- * @deprecated
- */
+ /**
+ * @deprecated
+ */
public void setDefinition(Definition definition1) {
Trc.entry(this, definition1);
throw new RuntimeException("nolonger supported");
@@ -1923,11 +1939,11 @@
Trc.exit();
}
-// public void setOperation(Operation operation1) {
-// Trc.entry(this, operation1);
-// operation = operation1;
-// Trc.exit();
-// }
+ // public void setOperation(Operation operation1) {
+ // Trc.entry(this, operation1);
+ // operation = operation1;
+ // Trc.exit();
+ // }
public void setOperation(Operation operation1) {
Trc.entry(this, operation1);
portTypeOperation = operation1;
@@ -1940,25 +1956,25 @@
Trc.exit();
}
- /**
- * soapPartNames==null means that soap:body parts="..." wasn't set.
- * soapPartNames is an empty list means soap:body part="" (nothing in the
quotes).
- */
- public void setSoapPartNames(List soapList) {
- Trc.entry(this, soapList);
- soapPartNames = soapList;
- Trc.exit();
- }
-
- public void setMimePartNames(List mimeList) {
- Trc.entry(this, mimeList);
- if (mimeList == null || mimeList.isEmpty())
- mimePartNames = null;
- else
- mimePartNames = mimeList;
- Trc.exit();
- }
-
+ /**
+ * soapPartNames==null means that soap:body parts="..." wasn't set.
+ * soapPartNames is an empty list means soap:body part="" (nothing in the
quotes).
+ */
+ public void setSoapPartNames(List soapList) {
+ Trc.entry(this, soapList);
+ soapPartNames = soapList;
+ Trc.exit();
+ }
+
+ public void setMimePartNames(List mimeList) {
+ Trc.entry(this, mimeList);
+ if (mimeList == null || mimeList.isEmpty())
+ mimePartNames = null;
+ else
+ mimePartNames = mimeList;
+ Trc.exit();
+ }
+
public void setReturnName(String s) {
Trc.entry(this, s);
returnName = s;
@@ -2115,7 +2131,8 @@
private void checkForTimeoutProperties(
HashMap inJmsPropVals,
- WSIFJMSDestination dest) throws WSIFException {
+ WSIFJMSDestination dest)
+ throws WSIFException {
for (Iterator i = inJmsPropVals.keySet().iterator(); i.hasNext();) {
String name = (String) i.next();
Object value = inJmsPropVals.get(name);
@@ -2128,7 +2145,8 @@
private boolean timeoutProperty(
WSIFJMSDestination dest,
String propertyName,
- Object value) throws WSIFException {
+ Object value)
+ throws WSIFException {
boolean isTimeoutProperty = false;
try {
if (WSIFConstants.WSIF_PROP_SYNC_TIMEOUT.equals(propertyName))
{
@@ -2277,8 +2295,8 @@
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(" soapPartNames:").append(soapPartNames);
+ buff.append(" mimePartNames:").append(mimePartNames);
buff.append(" inputEncodingStyle:").append(inputEncodingStyle);
buff.append(" inputNamespace:").append(inputNamespace);
buff.append(" actionUri:").append(soapActionURI);