whitlock 2003/03/04 09:16:13
Modified: java/test/mime Mime.wsdl MimeTest.java Mime.java
MimeImpl.java DeploymentDescriptor.xml
java/src/org/apache/wsif/providers/soap/apacheaxis
WSIFOperation_ApacheAxis.java
Log:
16993: Support unreferenced attachments
Revision Changes Path
1.12 +41 -10 xml-axis-wsif/java/test/mime/Mime.wsdl
Index: Mime.wsdl
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/Mime.wsdl,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Mime.wsdl 24 Feb 2003 10:51:46 -0000 1.11
+++ Mime.wsdl 4 Mar 2003 17:16:12 -0000 1.12
@@ -160,6 +160,10 @@
<input message="tns:MixMimePartsMessage"/>
<output message="tns:StringMessage"/>
</operation>
+ <operation name="unref">
+ <input message="tns:MultiMimePartsMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation>
</portType>
<!-- binding declns -->
@@ -281,7 +285,8 @@
<mime:content part="file" type="image/jpeg"/>
</mime:part>
<mime:part>
- <soap:body use="encoded" parts="shouldBounce"
+ <soap:body use="encoded"
+ parts="shouldBounce file"
namespace="http://mime/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</mime:part>
@@ -425,7 +430,7 @@
<soap:body use="encoded"
namespace="http://mime/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- parts="shouldBounce" />
+ parts="shouldBounce file" />
</mime:part>
<mime:part>
<mime:content part="file" type="text/plain"/>
@@ -450,7 +455,7 @@
<soap:body use="encoded"
namespace="http://mime/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- parts="" />
+ parts="file" />
</mime:part>
</mime:multipartRelated>
</input>
@@ -524,8 +529,8 @@
</mime:part>
<mime:part>
<!-- This soap:body deliberately doesn't have a parts=""
- to test that the soap body defaults to excluding the
- attachment -->
+ to test that the soap body defaults to referring to the
+ attachment but not inlining it in the soap body -->
<soap:body use="encoded"
namespace="http://mime/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
@@ -560,7 +565,32 @@
<soap:body use="encoded"
namespace="http://mime/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- parts="position1 position2 position3"/>
+ parts="position1 file1 position2 file2 position3"/>
+ </mime:part>
+ </mime:multipartRelated>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+
+ <operation name="unref">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file" type="text/html"/>
+ </mime:part>
+ <mime:part>
+ <mime:content part="file2" type="text/html"/>
+ </mime:part>
+ <mime:part>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ parts="file"/>
</mime:part>
</mime:multipartRelated>
</input>
@@ -690,7 +720,8 @@
<mime:content part="file" type="image/jpeg"/>
</mime:part>
<mime:part>
- <soap:body use="encoded" parts="shouldBounce"
+ <soap:body use="encoded"
+ parts="shouldBounce file"
namespace="http://mime/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</mime:part>
@@ -834,7 +865,7 @@
<soap:body use="encoded"
namespace="http://mime/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- parts="shouldBounce" />
+ parts="shouldBounce file" />
</mime:part>
<mime:part>
<mime:content part="file" type="text/plain"/>
@@ -859,7 +890,7 @@
<soap:body use="encoded"
namespace="http://mime/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- parts="" />
+ parts="file" />
</mime:part>
</mime:multipartRelated>
</input>
@@ -969,7 +1000,7 @@
<soap:body use="encoded"
namespace="http://mime/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- parts="position1 position2 position3"/>
+ parts="position1 file1 position2 file2 position3"/>
</mime:part>
</mime:multipartRelated>
</input>
1.13 +17 -3 xml-axis-wsif/java/test/mime/MimeTest.java
Index: MimeTest.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/MimeTest.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- MimeTest.java 24 Feb 2003 10:51:46 -0000 1.12
+++ MimeTest.java 4 Mar 2003 17:16:12 -0000 1.13
@@ -141,6 +141,7 @@
private final static String ARRAY_OF_BINARY = "ARRAY-OF-BINARY";
private final static String OPTIONAL_SOAP_BODY = "OPTIONAL_SOAP_BODY";
private final static String MIX_MIME_PARTS = "MIX_MIME_PARTS";
+ private final static String UNREF = "UNREF";
private final static String MAP_TYPE = "MAP-TYPE";
private final static String BAD_NO_PART = "BAD-NO-PART";
private final static String BAD_PART = "BAD-PART";
@@ -343,14 +344,18 @@
doit(server + "Port", MAP_TYPE, "Mime.wsdl");
}
- public void testOptionalSoapBodyHttp() {
- doit(server + "Port", OPTIONAL_SOAP_BODY, "Mime.wsdl");
- }
+// public void testOptionalSoapBodyHttp() {
+// doit(server + "Port", OPTIONAL_SOAP_BODY, "Mime.wsdl");
+// }
public void testMixMimePartsHttp() {
doit(server + "Port", MIX_MIME_PARTS, "Mime.wsdl");
}
+ public void testUnrefHttp() {
+ doit(server + "Port", UNREF, "Mime.wsdl");
+ }
+
/* ***************************************************/
/* AXIS/JMS tests */
/* ***************************************************/
@@ -575,6 +580,8 @@
optional_soap_body(service, stub);
else if (cmd.equals(MIX_MIME_PARTS))
mix_mime_parts(portName, service, stub);
+ else if (cmd.equals(UNREF))
+ unref(service, stub);
else if (cmd.equals(BAD_NO_PART))
bad_no_part(portName, service);
else if (cmd.equals(BAD_PART))
@@ -933,6 +940,13 @@
String expected =
position1 + readFile(dh1) + position2 + readFile(dh2) + position3;
assertTrue(expected.equals(s));
+ }
+
+ private void unref(WSIFService service, Mime stub) throws Exception {
+ DataHandler dh1 = new DataHandler(new FileDataSource(flatfileLocation));
+ DataHandler dh2 = new DataHandler(new FileDataSource(flatfileLocation2));
+ String buff = stub.unref(dh1, dh2);
+ assertTrue(compareFiles(flatfileLocation, buff));
}
/* *********************** ERRORS ********************************** */
1.8 +1 -0 xml-axis-wsif/java/test/mime/Mime.java
Index: Mime.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/Mime.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Mime.java 20 Jan 2003 14:34:09 -0000 1.7
+++ Mime.java 4 Mar 2003 17:16:12 -0000 1.8
@@ -100,6 +100,7 @@
String pos2,
DataHandler dh2,
String pos3);
+ public String unref(DataHandler dh1, DataHandler dh2);
public String badNoPart(DataHandler dh) throws Exception;
public String badPart(DataHandler dh) throws Exception;
1.10 +4 -0 xml-axis-wsif/java/test/mime/MimeImpl.java
Index: MimeImpl.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/MimeImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- MimeImpl.java 24 Feb 2003 10:51:46 -0000 1.9
+++ MimeImpl.java 4 Mar 2003 17:16:12 -0000 1.10
@@ -245,6 +245,10 @@
+ dataHandlerToString(dh2)
+ pos3;
}
+
+ public String unref(DataHandler dh) {
+ return dataHandlerToString(dh);
+ }
/* ******************* ERRORS *********************** */
1.7 +1 -1 xml-axis-wsif/java/test/mime/DeploymentDescriptor.xml
Index: DeploymentDescriptor.xml
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/DeploymentDescriptor.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DeploymentDescriptor.xml 20 Jan 2003 14:34:09 -0000 1.6
+++ DeploymentDescriptor.xml 4 Mar 2003 17:16:12 -0000 1.7
@@ -6,7 +6,7 @@
stringToPlainText bounceImage bounceImage2 bounceImage4
orMultiMimeParts andMultiMimeParts noContent typeStar
soapBodyParts1 soapBodyParts2 soapBodyParts3
soapBodyParts4
- arrayOfBinary optionalSoapBody mixMimeParts
+ arrayOfBinary optionalSoapBody mixMimeParts unref
badNoSoapBody badNoPart badPart badNested badMixSoapMime
badMultipleSoapBodies badSoapBodyType">
<isd:java class="mime.MimeImpl" static="false"/>
1.72 +134 -69
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.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- WSIFOperation_ApacheAxis.java 27 Feb 2003 16:52:57 -0000 1.71
+++ WSIFOperation_ApacheAxis.java 4 Mar 2003 17:16:13 -0000 1.72
@@ -157,11 +157,13 @@
transient protected List inputSOAPParts;
transient protected List inputUnwrappedSOAPParts;
transient protected List inputMIMEParts;
+ transient protected List inputUnrefMIMEPartNames;
transient protected Part inputSOAPHeader;
transient protected Part inputSOAPHeaderFault;
protected List outputSOAPParts;
protected List outputUnwrappedSOAPParts;
+ protected List outputUnrefMIMEPartNames;
protected List outputMIMEParts;
protected Part outputSOAPHeader;
protected Part outputSOAPHeaderFault;
@@ -234,12 +236,14 @@
op.inputSOAPParts = inputSOAPParts;
op.inputUnwrappedSOAPParts = inputUnwrappedSOAPParts;
op.inputMIMEParts = inputMIMEParts;
+ op.inputUnrefMIMEPartNames = inputUnrefMIMEPartNames;
op.inputSOAPHeader = inputSOAPHeader;
op.inputSOAPHeaderFault = inputSOAPHeaderFault;
op.outputSOAPParts = outputSOAPParts;
op.outputUnwrappedSOAPParts = outputUnwrappedSOAPParts;
op.outputMIMEParts = outputMIMEParts;
+ op.outputUnrefMIMEPartNames = outputUnrefMIMEPartNames;
op.outputSOAPHeader = outputSOAPHeader;
op.outputSOAPHeaderFault = outputSOAPHeaderFault;
@@ -668,8 +672,8 @@
SOAPBody soapBody = null;
Operation op = bindingOperation.getOperation();
- Map mapInParts = op.getInput().getMessage().getParts();
- Map mapOutParts =
+ Map inMessageParts = op.getInput().getMessage().getParts();
+ Map outMessageParts =
op.getOutput() == null
? new HashMap()
: op.getOutput().getMessage().getParts();
@@ -721,8 +725,8 @@
"No part name for a
mime:content. Operation="
+ getName());
- if ((isInput &&
mapInParts.get(partName) == null)
- || (!isInput &&
mapOutParts.get(partName) == null))
+ if ((isInput &&
inMessageParts.get(partName) == null)
+ || (!isInput &&
outMessageParts.get(partName) == null))
throw new WSIFException(
"The part specified in
a mime:content does "
+ "not exist
in the operation. Operation="
@@ -762,67 +766,93 @@
}
}
- // There is at most one soap:body so process it here.
- if (soapBody != null)
- {
- List soapBodyParts = soapBody.getParts();
- if (soapBodyParts == null && !mimePartNames.isEmpty())
- {
- /* In the WSDL (containing attachments and non-attachment
- * parts), if there is a soap:body that does not have
- * the parts attribute, which parts should the soap body
- * contain? The WSDL spec is not clear so this code
- * fixes the soap body to contain only the non-attachment
- * parts, which is the kinder option. The alternative which
- * is making the soap body contain all the parts (so duplicating
- * the attachments) is cruel since this is probably not
- * what the backend is expecting.
- */
- Map soapParts;
- if (isInput)
- soapParts = mapInParts;
- else
- soapParts = mapOutParts;
-
- if (soapParts != null && !soapParts.isEmpty())
- {
- ArrayList nonMimeParts =
- new ArrayList(
- Arrays.asList(soapParts.keySet().toArray()));
- nonMimeParts.removeAll(
- Arrays.asList(soapParts.keySet().toArray()));
- soapBody.setParts(nonMimeParts);
+ ArrayList mimePartList = null;
+ if (mimePartNames != null && !mimePartNames.isEmpty()) {
+ javax.wsdl.Message m = null;
+ if (isInput) {
+ Input in = portTypeOperation.getInput();
+ if (in != null) {
+ m = in.getMessage();
+ }
+ } else {
+ Output out = portTypeOperation.getOutput();
+ if (out != null) {
+ m = out.getMessage();
}
}
- List soapParts = parseSoapBody(soapBody, isInput);
+ /*
+ * Mime parts can be referenced or unreferenced from the
+ * soap:body. By default they are all referenced. Mime parts
+ * can be unreferenced if there is a soap:body parts="a b c"
+ * which does not reference all the mime parts.
+ */
+ mimePartList = getParts(m, mimePartNames);
+ }
+
+ // There is at most one soap:body so process it here.
+ Map messageParts = null;
+ if (isInput)
+ messageParts = inMessageParts;
+ else
+ messageParts = outMessageParts;
+
+ // There is at most one soap:body so process it here.
+ List soapParts = null;
+ if (soapBody != null) {
+ List soapBodyParts = soapBody.getParts();
+// if (soapBodyParts == null && !mimePartNames.isEmpty()) {
+// /* In the WSDL (containing attachments and non-attachment
+// * parts), if there is a soap:body that does not have
+// * the parts attribute, which parts should the soap body
+// * contain? The WSDL spec is not clear so this code
+// * fixes the soap body to contain only the non-attachment
+// * parts, which is the kinder option. The alternative which
+// * is making the soap body contain all the parts (so duplicating
+// * the attachments) is cruel since this is probably not
+// * what the backend is expecting.
+// */
+// if (messageParts != null && !messageParts.isEmpty()) {
+// ArrayList nonMimeParts =
+// new ArrayList(
+// Arrays.asList(messageParts.values().toArray()));
+// nonMimeParts.removeAll(mimePartList);
+// soapBody.setParts(nonMimeParts);
+// }
+// }
+
+ soapParts = parseSoapBody(soapBody, isInput);
if (isInput)
this.inputSOAPParts = soapParts;
else
this.outputSOAPParts = soapParts;
}
- if (mimePartNames != null && !mimePartNames.isEmpty()) {
- javax.wsdl.Message m = null;
- if (isInput) {
- Input in = portTypeOperation.getInput();
- if (in != null) {
- m = in.getMessage();
- }
+ if (mimePartList != null) {
+ ArrayList refMimeParts = new ArrayList();
+ ArrayList unrefMimePartNames = new ArrayList();
+ if (soapParts == null) {
+ // No soap parts means no unref mime parts
+ refMimeParts = mimePartList;
} else {
- Output out = portTypeOperation.getOutput();
- if (out != null) {
- m = out.getMessage();
- }
+ Iterator it = mimePartList.iterator();
+ while (it.hasNext()) {
+ Part p = (Part) it.next();
+ if (soapParts.contains(p))
+ refMimeParts.add(p);
+ else
+ unrefMimePartNames.add(p.getName());
+ }
}
- ArrayList al = getParts(m, mimePartNames);
+
if (isInput) {
- this.inputMIMEParts = al;
+ this.inputMIMEParts = refMimeParts;
+ this.inputUnrefMIMEPartNames = unrefMimePartNames;
} else {
- this.outputMIMEParts = al;
+ this.outputMIMEParts = refMimeParts;
+ this.outputUnrefMIMEPartNames = unrefMimePartNames;
}
-
- }
+ }
Trc.exit();
}
@@ -1545,6 +1575,7 @@
setCallParameterNames(call);
Object[] inputValues = getInputMessageValues(inMsg, dest);
+ addAttachments(inMsg, call, false);
Object response = null;
boolean respOK = true;
@@ -1630,7 +1661,8 @@
partName = qn.getLocalPart();
}
}
- if (!inJmsProps.containsKey(partName)) {
+ if (!inJmsProps.containsKey(partName)
+ && !inputUnrefMIMEPartNames.contains(partName)) {
if (inputMIMEParts.isEmpty()
|| (inputMIMEParts.contains(p) || soapParts.contains(p))) {
QName name = new QName(inputNamespace, partName);
@@ -1708,6 +1740,7 @@
setCallParameterNames(call);
Object[] inputValues = getInputMessageValues(inMsg, null);
+ addAttachments(inMsg, call, false);
// invoke the AXIS call
Trc.event(this, "Invoking AXIS call", call, inputValues);
@@ -1766,7 +1799,7 @@
boolean workedOK = false;
- List attachments = addAttachments(inMsg, call);
+ List attachments = addAttachments(inMsg, call, true);
Object[] inputValues = getInputMessageValues(inMsg, null);
ArrayList soapBodies = new ArrayList();
@@ -1884,8 +1917,10 @@
*/
this.inputSOAPParts = new ArrayList();
this.inputMIMEParts = new ArrayList();
+ this.inputUnrefMIMEPartNames = new ArrayList();
this.outputSOAPParts = new ArrayList();
this.outputMIMEParts = new ArrayList();
+ this.outputUnrefMIMEPartNames = new ArrayList();
parseSoapOperation();
parseBindingInput();
@@ -2218,22 +2253,50 @@
* returns a List of all the AttachmentPart so that href parts
* can be made for each attachment later if required.
*/
- private List addAttachments(WSIFMessage inMsg, Call call) throws WSIFException
{
- ArrayList attachments = new ArrayList();
- for (int i = 0; i < inputMIMEParts.size(); i++) {
- Part p = (Part) inputMIMEParts.get(i);
- try {
- String partName = p.getName();
- Object value = inMsg.getObjectPart(partName);
- AttachmentPart ap = MIMEHelper.getAttachementPart(value);
- call.addAttachmentPart(ap);
- attachments.add(ap);
- } catch (WSIFException e) {
- throw new WSIFException("attachment part '" +
p.getName() + "' not in input WSIFMessage");
- }
- }
- return attachments;
- }
+ private List addAttachments(WSIFMessage inMsg, Call call, boolean doRef)
+ throws WSIFException {
+ ArrayList attachments = null;
+ if (doRef) {
+ attachments = new ArrayList();
+ for (int i = 0; i < inputMIMEParts.size(); i++) {
+ Part p = (Part) inputMIMEParts.get(i);
+ try {
+ String partName = p.getName();
+ Object value = inMsg.getObjectPart(partName);
+ AttachmentPart ap = MIMEHelper.getAttachementPart(value);
+ call.addAttachmentPart(ap);
+ attachments.add(ap);
+ } catch (WSIFException e) {
+ throw new WSIFException(
+ "attachment part '"
+ + p.getName()
+ + "' not in input WSIFMessage");
+ }
+ }
+ }
+
+ // TODO: if some attachments are referenced and some are not, then
+ // this code does not add them to the message in the correct order,
+ // instead all the referenced attachments will come first, then the
+ // unreferenced ones.
+ if (inputUnrefMIMEPartNames != null
+ && !inputUnrefMIMEPartNames.isEmpty())
+ for (int i = 0; i < inputUnrefMIMEPartNames.size(); i++) {
+ String partName = (String) inputUnrefMIMEPartNames.get(i);
+ try {
+ Object value = inMsg.getObjectPart(partName);
+ AttachmentPart ap = MIMEHelper.getAttachementPart(value);
+ call.addAttachmentPart(ap);
+ } catch (WSIFException e) {
+ Trc.exception(e);
+ throw new WSIFException(
+ "attachment part '"
+ + partName
+ + "' not in input WSIFMessage");
+ }
+ }
+ return attachments;
+ }
/**
* This extracts the values from the AXIS response when using messaging
@@ -2751,11 +2814,13 @@
buff.append(" inputSOAPParts:").append(inputSOAPParts);
buff.append("
inputUnwrappedSOAPParts:").append(inputUnwrappedSOAPParts);
buff.append(" inputMIMEParts:").append(inputMIMEParts);
+ buff.append("
inputUnrefMIMEPartNames:").append(inputUnrefMIMEPartNames);
buff.append(" inputSOAPHeader:").append(inputSOAPHeader);
buff.append("
inputSOAPHeaderFault:").append(inputSOAPHeaderFault);
buff.append(" outputSOAPParts:").append(outputSOAPParts);
buff.append("
outputUnwrappedSOAPParts:").append(outputUnwrappedSOAPParts);
buff.append(" outputMIMEParts:").append(outputMIMEParts);
+ buff.append("
outputUnrefMIMEPartNames:").append(outputUnrefMIMEPartNames);
buff.append(" outputSOAPHeader:").append(outputSOAPHeader);
buff.append("
outputSOAPHeaderFault:").append(outputSOAPHeaderFault);
buff.append(" inputEncodingStyle:").append(inputEncodingStyle);