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 di...@apache.org on 2005/07/31 23:59:37 UTC
cvs commit: ws-axis/java/src/org/apache/axis/encoding/ser JAFDataHandlerDeserializer.java JAFDataHandlerSerializer.java
dims 2005/07/31 14:59:37
Modified: java/src/org/apache/axis/attachments Attachments.java
AttachmentsImpl.java MimeUtils.java
java/src/org/apache/axis/client Call.java
java/src/org/apache/axis Constants.java Message.java
java/src/org/apache/axis/encoding/ser
JAFDataHandlerDeserializer.java
JAFDataHandlerSerializer.java
Log:
Preliminary MTOM support.
- Tested with the WSE 3.0 July CTP service (http://www.mail-archive.com/axis-dev@ws.apache.org/msg08296.html)
- Sample client code below (modified version of the samples/attachments client code)
===============================================================
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.axis.AxisFault;
import org.apache.axis.constants.Style;
import org.apache.axis.constants.Use;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;
import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.axis.utils.Options;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import java.io.File;
import java.net.URL;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Vector;
import samples.attachments.EchoAttachment;
/**
* An example of sending an attachment via RPC.
* This class has a main method that beside the standard arguments
* allows you to specify an attachment that will be sent to a
* service which will then send it back.
*
*/
public class EchoStockAttachment {
Options opts = null;
public EchoStockAttachment(Options opts) {
this.opts = opts;
}
/**
* This method sends a file as an attachment then
* receives it as a return. The returned file is
* compared to the source.
* @param doMTOM The filename that is the source to send.
* @return True if sent and compared.
*/
public boolean echo(final boolean doMTOM, String filename) throws Exception {
//Create the data for the attached file.
DataHandler dhSource = new DataHandler(new FileDataSource(filename));
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(opts.getURL())); //Set the target service host and service location,
call.setSOAPActionURI("http://stockservice.contoso.com/wse/samples/echoAttachment");
call.setOperationName(new QName("http://stockservice.contoso.com/wse/samples", "echoAttachment")); //This is the target services method to invoke.
call.setEncodingStyle("");
call.setOperationStyle(Style.WRAPPED);
call.setOperationUse(Use.LITERAL);
QName qnameAttachment = new QName("http://stockservice.contoso.com/wse/samples", "DataHandler");
call.registerTypeMapping(dhSource.getClass(), //Add serializer for attachment.
qnameAttachment,
JAFDataHandlerSerializerFactory.class,
JAFDataHandlerDeserializerFactory.class);
call.addParameter(new QName("http://stockservice.contoso.com/wse/samples", "bytes"), qnameAttachment,
ParameterMode.IN); //Add the file.
call.setReturnType(qnameAttachment);
call.setUsername(opts.getUser());
call.setPassword(opts.getPassword());
if (doMTOM)
call.setProperty(call.ATTACHMENT_ENCAPSULATION_FORMAT,
call.ATTACHMENT_ENCAPSULATION_FORMAT_MTOM);
Object ret = call.invoke(new Object[]{
dhSource
}
); //Add the attachment.
if (null == ret) {
System.out.println("Received null ");
throw new AxisFault("", "Received null", null, null);
}
if (ret instanceof String) {
System.out.println("Received problem response from server: " + ret);
throw new AxisFault("", (String) ret, null, null);
}
if (!(ret instanceof DataHandler)) {
//The wrong type of object that what was expected.
System.out.println("Received problem response from server:" +
ret.getClass().getName());
throw new AxisFault("", "Received problem response from server:" +
ret.getClass().getName(), null, null);
}
//Still here, so far so good.
//Now lets brute force compare the source attachment
// to the one we received.
DataHandler rdh = (DataHandler) ret;
//From here we'll just treat the data resource as file.
String receivedfileName = rdh.getName();//Get the filename.
if (receivedfileName == null) {
System.err.println("Could not get the file name.");
throw new AxisFault("", "Could not get the file name.", null, null);
}
System.out.println("Going to compare the files..");
boolean retv = compareFiles(filename, receivedfileName);
File receivedFile = new File(receivedfileName);
receivedFile.delete();
return retv;
}
/**
* Give a single file to send or name a directory
* to send an array of attachments of the files in
* that directory.
*/
public static void main(String args[]) {
try {
Options opts = new Options(args);
EchoStockAttachment echoattachment = new EchoStockAttachment(opts);
args = opts.getRemainingArgs();
int argpos = 0;
if (args == null || args.length == 0) {
System.err.println("Need a file.");
System.exit(8);
}
boolean doMTOM = false;
if (args[0].trim().equalsIgnoreCase("+FDR")) {
doMTOM = true;
++argpos;
}
if (argpos >= args.length) {
System.err.println("Need a file argument.");
System.exit(8);
}
String argFile = args[argpos];
File source = new File(argFile);
if (!source.exists()) {
System.err.println("Error \"" + argFile + "\" does not exist!");
System.exit(8);
}
if (echoattachment.echo(doMTOM, argFile)) {
System.out.println("Attachment sent and received ok!");
System.exit(0);
} else {
System.err.println("Problem in matching attachments");
System.exit(8);
}
} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
}
System.exit(18);
}
/**
* Quick and unsophisticated method to compare two file's
* byte stream.
* @return True if the bytestreams do compare, false for
* any other reason.
*/
protected boolean compareFiles(String one, String other)
throws java.io.FileNotFoundException, java.io.IOException {
java.io.BufferedInputStream oneStream = null;
java.io.BufferedInputStream otherStream = null;
// First compare file length.
File f1 = new File(one);
File f2 = new File(other);
if (f1.length() != f2.length())
return false;
try {
oneStream = new java.io.BufferedInputStream(
new java.io.FileInputStream(one), 1024 * 64);
otherStream = new java.io.BufferedInputStream(
new java.io.FileInputStream(other), 1024 * 64);
byte[] bufOne = new byte[1024 * 64];
byte[] bufOther = new byte[1024 * 64];
int breadOne = -1;
int breadOther = -1;
int available = 0;
do {
available = oneStream.available();
available = Math.min(available, otherStream.available());
available = Math.min(available, bufOther.length);
if (0 != available) {
java.util.Arrays.fill(bufOne, (byte) 0);
java.util.Arrays.fill(bufOther, (byte) 0);
breadOne = oneStream.read(bufOne, 0, available);
breadOther = otherStream.read(bufOther, 0, available);
if (breadOne != breadOther)
throw new RuntimeException(
"Sorry couldn't really read whats available!");
if (!java.util.Arrays.equals(bufOne, bufOther)) {
return false;
}
}
} while (available != 0 && breadOne != -1 && breadOther != -1);
if (available != 0 && (breadOne != -1 || breadOther != -1)) {
return false;
}
return true;
} finally {
if (null != oneStream) oneStream.close();
if (null != otherStream) otherStream.close();
}
}
}
=====================================================================================
Revision Changes Path
1.19 +5 -2 ws-axis/java/src/org/apache/axis/attachments/Attachments.java
Index: Attachments.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/attachments/Attachments.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Attachments.java 25 Feb 2004 14:02:30 -0000 1.18
+++ Attachments.java 31 Jul 2005 21:59:37 -0000 1.19
@@ -198,10 +198,13 @@
/** Use the DIME attatchment type. */
public final int SEND_TYPE_DIME= 3; //use dime;
+ /** Use the MTOM attatchment type. */
+ public final int SEND_TYPE_MTOM= 4; //use MTOM;
+
/** Use the DIME attatchment type. */
- public final int SEND_TYPE_NONE= 4; //don't send as attachments
+ public final int SEND_TYPE_NONE= 5; //don't send as attachments
- final int SEND_TYPE_MAX = 4;
+ final int SEND_TYPE_MAX = 5;
/** The default attatchment type. MIME */
final int SEND_TYPE_DEFAULT = SEND_TYPE_MIME;
1.49 +16 -9 ws-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java
Index: AttachmentsImpl.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- AttachmentsImpl.java 26 Apr 2004 11:51:43 -0000 1.48
+++ AttachmentsImpl.java 31 Jul 2005 21:59:37 -0000 1.49
@@ -103,9 +103,9 @@
new java.util.StringTokenizer(contentType, " \t;");
if (st.hasMoreTokens()) {
- String mimetype = st.nextToken();
+ String token = st.nextToken();
- if (mimetype.equalsIgnoreCase(
+ if (token.equalsIgnoreCase(
org.apache.axis.Message.MIME_MULTIPART_RELATED)) {
sendtype= SEND_TYPE_MIME;
mpartStream =
@@ -131,17 +131,20 @@
soapPart = new org.apache.axis.SOAPPart(null,
mpartStream,
false);
- } else if (mimetype.equalsIgnoreCase(org.apache.axis.Message.MIME_APPLICATION_DIME)) {
+ } else if (token.equalsIgnoreCase(org.apache.axis.Message.MIME_APPLICATION_DIME)) {
try{
mpartStream=
new MultiPartDimeInputStream( (java.io.InputStream) intialContents);
soapPart = new org.apache.axis.SOAPPart(null, mpartStream, false);
}catch(Exception e){ throw org.apache.axis.AxisFault.makeFault(e);}
sendtype= SEND_TYPE_DIME;
+ } else if (token.indexOf(org.apache.axis.Message.CONTENT_TYPE_MTOM)!=-1){
+ sendtype = SEND_TYPE_MTOM;
}
}
}
}
+
}
/**
@@ -402,9 +405,9 @@
int sendtype= this.sendtype == SEND_TYPE_NOTSET ? SEND_TYPE_DEFAULT : this.sendtype;
try {
- if(sendtype == SEND_TYPE_MIME)
+ if(sendtype == SEND_TYPE_MIME || sendtype == SEND_TYPE_MTOM)
return org.apache.axis.attachments.MimeUtils.getContentLength(
- multipart != null ? multipart : (multipart = org.apache.axis.attachments.MimeUtils.createMP(soapPart.getAsString(), orderedAttachments)));
+ multipart != null ? multipart : (multipart = org.apache.axis.attachments.MimeUtils.createMP(soapPart.getAsString(), orderedAttachments, getSendType())));
else if (sendtype == SEND_TYPE_DIME)return createDimeMessage().getTransmissionSize();
} catch (Exception e) {
throw AxisFault.makeFault(e);
@@ -457,13 +460,13 @@
try{
mergeinAttachments();
- if(sendtype == SEND_TYPE_MIME){
+ if(sendtype == SEND_TYPE_MIME || sendtype == SEND_TYPE_MTOM){
org.apache.axis.attachments.MimeUtils.writeToMultiPartStream(os,
(multipart != null)
? multipart
: (multipart =
org.apache.axis.attachments.MimeUtils.createMP(
- soapPart.getAsString(), orderedAttachments)));
+ soapPart.getAsString(), orderedAttachments, getSendType())));
for (java.util.Iterator i = orderedAttachments.iterator();
i.hasNext();) {
@@ -493,14 +496,14 @@
int sendtype= this.sendtype == SEND_TYPE_NOTSET ? SEND_TYPE_DEFAULT :
this.sendtype;
- if(sendtype == SEND_TYPE_MIME)
+ if(sendtype == SEND_TYPE_MIME || sendtype == SEND_TYPE_MTOM)
return org.apache.axis.attachments.MimeUtils.getContentType((multipart
!= null)
? multipart
: (multipart =
org.apache.axis.attachments.MimeUtils.createMP(
soapPart.getAsString(),
- orderedAttachments)));
+ orderedAttachments, getSendType())));
else return org.apache.axis.Message.MIME_APPLICATION_DIME;
}
@@ -646,6 +649,7 @@
* @return an <code>int</code> send type code
*/
public static int getSendType(String value) {
+ if (value.equalsIgnoreCase("MTOM")) return SEND_TYPE_MTOM;
if (value.equalsIgnoreCase("MIME")) return SEND_TYPE_MIME;
if (value.equalsIgnoreCase("DIME")) return SEND_TYPE_DIME;
if (value.equalsIgnoreCase("NONE")) return SEND_TYPE_NONE;
@@ -659,6 +663,9 @@
* @return a <code>String</code> representation of <code>value</code>
*/
public static String getSendTypeString(int value) {
+ if (value == SEND_TYPE_MTOM) {
+ return "MTOM";
+ }
if (value == SEND_TYPE_MIME) {
return "MIME";
}
1.41 +17 -5 ws-axis/java/src/org/apache/axis/attachments/MimeUtils.java
Index: MimeUtils.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/attachments/MimeUtils.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- MimeUtils.java 5 Apr 2004 13:53:48 -0000 1.40
+++ MimeUtils.java 31 Jul 2005 21:59:37 -0000 1.41
@@ -237,7 +237,9 @@
* @throws org.apache.axis.AxisFault
*/
public static javax.mail.internet.MimeMultipart createMP(
- String env, java.util.Collection parts)
+ String env,
+ java.util.Collection parts,
+ int sendType)
throws org.apache.axis.AxisFault {
javax.mail.internet.MimeMultipart multipart = null;
@@ -245,15 +247,25 @@
try {
String rootCID = SessionUtils.generateSessionId();
- multipart = new javax.mail.internet.MimeMultipart(
- "related; type=\"text/xml\"; start=\"<" + rootCID + ">\"");
+ if(sendType == Attachments.SEND_TYPE_MTOM) {
+ multipart = new javax.mail.internet.MimeMultipart(
+ "related;type=\"application/xop+xml\"; start=\"<" + rootCID + ">\"; start-info=\"text/xml; charset=utf-8\"");
+ } else {
+ multipart = new javax.mail.internet.MimeMultipart(
+ "related; type=\"text/xml\"; start=\"<" + rootCID + ">\"");
+ }
javax.mail.internet.MimeBodyPart messageBodyPart =
new javax.mail.internet.MimeBodyPart();
messageBodyPart.setText(env, "UTF-8");
- messageBodyPart.setHeader("Content-Type",
- "text/xml; charset=UTF-8");
+ if(sendType == Attachments.SEND_TYPE_MTOM){
+ messageBodyPart.setHeader("Content-Type",
+ "application/xop+xml; charset=utf-8; type=\"text/xml; charset=utf-8\"");
+ } else {
+ messageBodyPart.setHeader("Content-Type",
+ "text/xml; charset=UTF-8");
+ }
messageBodyPart.setHeader("Content-Id", "<" + rootCID + ">");
messageBodyPart.setHeader(
HTTPConstants.HEADER_CONTENT_TRANSFER_ENCODING, "binary");
1.243 +10 -0 ws-axis/java/src/org/apache/axis/client/Call.java
Index: Call.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/client/Call.java,v
retrieving revision 1.242
retrieving revision 1.243
diff -u -r1.242 -r1.243
--- Call.java 27 May 2005 17:57:32 -0000 1.242
+++ Call.java 31 Jul 2005 21:59:37 -0000 1.243
@@ -237,6 +237,7 @@
* @see #setProperty
* @see #ATTACHMENT_ENCAPSULATION_FORMAT_DIME
* @see #ATTACHMENT_ENCAPSULATION_FORMAT_MIME
+ * @see #ATTACHMENT_ENCAPSULATION_FORMAT_MTOM
*/
public static final String ATTACHMENT_ENCAPSULATION_FORMAT=
"attachment_encapsulation_format";
@@ -250,6 +251,11 @@
*/
public static final String ATTACHMENT_ENCAPSULATION_FORMAT_DIME=
"axis.attachment.style.dime";
+ /**
+ * Property value for setting attachment format as DIME.
+ */
+ public static final String ATTACHMENT_ENCAPSULATION_FORMAT_MTOM=
+ "axis.attachment.style.mtom";
/**
* Timeout property: should be accompanies by an integer
@@ -441,10 +447,12 @@
else if ( name.equals(ATTACHMENT_ENCAPSULATION_FORMAT) ) {
verifyStringProperty(name, value);
if(!value.equals(ATTACHMENT_ENCAPSULATION_FORMAT_MIME ) &&
+ !value.equals(ATTACHMENT_ENCAPSULATION_FORMAT_MTOM ) &&
!value.equals(ATTACHMENT_ENCAPSULATION_FORMAT_DIME ))
throw new JAXRPCException(
Messages.getMessage("badattachmenttypeerr", new String[] {
(String) value, ATTACHMENT_ENCAPSULATION_FORMAT_MIME + " "
+ +ATTACHMENT_ENCAPSULATION_FORMAT_MTOM + " "
+ATTACHMENT_ENCAPSULATION_FORMAT_DIME }));
}
else if (name.equals(CONNECTION_TIMEOUT_PROPERTY)) {
@@ -2144,6 +2152,8 @@
if(null != attachments) {
if( ATTACHMENT_ENCAPSULATION_FORMAT_MIME.equals(attachformat)) {
attachments.setSendType(Attachments.SEND_TYPE_MIME);
+ } else if ( ATTACHMENT_ENCAPSULATION_FORMAT_MTOM.equals(attachformat)) {
+ attachments.setSendType(Attachments.SEND_TYPE_MTOM);
} else if ( ATTACHMENT_ENCAPSULATION_FORMAT_DIME.equals(attachformat)) {
attachments.setSendType(Attachments.SEND_TYPE_DIME);
}
1.138 +7 -0 ws-axis/java/src/org/apache/axis/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/Constants.java,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -r1.137 -r1.138
--- Constants.java 28 Jan 2005 20:11:11 -0000 1.137
+++ Constants.java 31 Jul 2005 21:59:37 -0000 1.138
@@ -41,6 +41,7 @@
public static final String NS_PREFIX_WSDL_SOAP = "wsdlsoap";
public static final String NS_PREFIX_XMLSOAP = "apachesoap";
public static final String NS_PREFIX_XML = "xml";
+ public static final String NS_PREFIX_XOP = "xop";
// Axis Namespaces
public static final String NS_URI_AXIS = "http://xml.apache.org/axis/";
@@ -396,6 +397,12 @@
public static final String URI_DIME_OPEN_LAYOUT=
"http://schemas.xmlsoap.org/ws/2002/04/dime/open-layout";
+ // XOP/MTOM
+ public static final String URI_XOP_INCLUDE =
+ "http://www.w3.org/2004/08/xop/include";
+ public static final String ELEM_XOP_INCLUDE = "Include" ;
+
+
//
// WSDL SOAP Namespace
//
1.121 +8 -3 ws-axis/java/src/org/apache/axis/Message.java
Index: Message.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/Message.java,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- Message.java 30 May 2005 20:06:29 -0000 1.120
+++ Message.java 31 Jul 2005 21:59:37 -0000 1.121
@@ -74,6 +74,9 @@
/** DIME parts defined for messages. */
public static final String MIME_APPLICATION_DIME = "application/dime";
+ /** Content Type for MTOM/XOP */
+ public static final String CONTENT_TYPE_MTOM = "application/xop+xml";
+
/** Default Attachments Implementation class. */
public static final String DEFAULT_ATTACHMNET_IMPL="org.apache.axis.attachments.AttachmentsImpl";
@@ -317,9 +320,11 @@
String charsetPart = contentType.substring(delimiterIndex);
int charsetIndex = charsetPart.indexOf('=');
String charset = charsetPart.substring(charsetIndex + 1).trim();
- if ((charset.startsWith("\"") && charset.endsWith("\""))
- || (charset.startsWith("'") && charset.endsWith("'"))) {
- charset = charset.substring(1, charset.length() - 1);
+ if ((charset.startsWith("\"") || charset.startsWith("\'"))) {
+ charset = charset.substring(1, charset.length());
+ }
+ if ((charset.endsWith("\"") || charset.endsWith("\'"))) {
+ charset = charset.substring(0, charset.length()-1);
}
try {
setProperty(SOAPMessage.CHARACTER_SET_ENCODING, charset);
1.23 +17 -7 ws-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerDeserializer.java
Index: JAFDataHandlerDeserializer.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerDeserializer.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- JAFDataHandlerDeserializer.java 29 Jul 2004 21:40:27 -0000 1.22
+++ JAFDataHandlerDeserializer.java 31 Jul 2005 21:59:37 -0000 1.23
@@ -17,6 +17,7 @@
package org.apache.axis.encoding.ser;
import org.apache.axis.attachments.AttachmentUtils;
+import org.apache.axis.attachments.Attachments;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.DeserializerImpl;
@@ -24,6 +25,7 @@
import org.apache.axis.utils.Messages;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.AxisFault;
+import org.apache.axis.Constants;
import org.apache.commons.logging.Log;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -54,8 +56,10 @@
context.pushNewElement(myElement);
}
}
-// super.startElement(namespace, localName, qName, attributes, context);
+ populateDataHandler(context, namespace, localName, attributes);
+ }
+ private void populateDataHandler(DeserializationContext context, String namespace, String localName, Attributes attributes) {
SOAPConstants soapConstants = context.getSOAPConstants();
QName type = context.getTypeFromAttributes(namespace,
@@ -64,14 +68,14 @@
if (log.isDebugEnabled()) {
log.debug(Messages.getMessage("gotType00", "Deser", "" + type));
}
-
+
String href = attributes.getValue(soapConstants.getAttrHref());
if (href != null) {
Object ref = context.getObjectByRef(href);
try{
- ref = AttachmentUtils.getActivationDataHandler((org.apache.axis.Part)ref);
- }catch(org.apache.axis.AxisFault e){;}
-
+ ref = AttachmentUtils.getActivationDataHandler((org.apache.axis.Part)ref);
+ }catch(AxisFault e){;}
+
setValue(ref);
}
}
@@ -86,7 +90,13 @@
Attributes attributes,
DeserializationContext context)
throws SAXException {
- throw new SAXException(Messages.getMessage(
- "noSubElements", namespace + ":" + localName));
+ if(namespace.equals(Constants.URI_XOP_INCLUDE) &&
+ localName.equals(Constants.ELEM_XOP_INCLUDE)) {
+ populateDataHandler(context, namespace, localName, attributes);
+ return null;
+ } else {
+ throw new SAXException(Messages.getMessage(
+ "noSubElements", namespace + ":" + localName));
+ }
}
}
1.28 +19 -8 ws-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializer.java
Index: JAFDataHandlerSerializer.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializer.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- JAFDataHandlerSerializer.java 25 Feb 2004 14:02:37 -0000 1.27
+++ JAFDataHandlerSerializer.java 31 Jul 2005 21:59:37 -0000 1.28
@@ -77,15 +77,26 @@
attrs.removeAttribute(typeIndex);
}
- boolean doTheDIME = false;
- if(attachments.getSendType() == Attachments.SEND_TYPE_DIME)
- doTheDIME = true;
-
- attrs.addAttribute("", soapConstants.getAttrHref(), soapConstants.getAttrHref(),
- "CDATA", doTheDIME ? attachmentPart.getContentId() : attachmentPart.getContentIdRef() );
+ if(attachments.getSendType() == Attachments.SEND_TYPE_MTOM) {
+ context.setWriteXMLType(null);
+ context.startElement(name, attrs);
+ AttributesImpl attrs2 = new AttributesImpl();
+ attrs2.addAttribute("", soapConstants.getAttrHref(), soapConstants.getAttrHref(),
+ "CDATA", attachmentPart.getContentIdRef());
+ context.startElement(new QName(Constants.URI_XOP_INCLUDE, Constants.ELEM_XOP_INCLUDE), attrs2);
+ context.endElement();
+ context.endElement();
+ } else {
+ boolean doTheDIME = false;
+ if(attachments.getSendType() == Attachments.SEND_TYPE_DIME)
+ doTheDIME = true;
- context.startElement(name, attrs);
- context.endElement(); //There is no data to so end the element.
+ attrs.addAttribute("", soapConstants.getAttrHref(), soapConstants.getAttrHref(),
+ "CDATA", doTheDIME ? attachmentPart.getContentId() : attachmentPart.getContentIdRef() );
+
+ context.startElement(name, attrs);
+ context.endElement(); //There is no data to so end the element.
+ }
}
public String getMechanismType() { return Constants.AXIS_SAX; }