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 th...@apache.org on 2005/06/30 04:43:09 UTC
svn commit: r202469 - in /webservices/axis/trunk/java/modules:
samples/test/org/apache/axis/engine/EchoRawMTOMTest.java
xml/src/org/apache/axis/attachments/MIMEHelper.java
xml/src/org/apache/axis/om/MIMEOutputUtils.java
Author: thilina
Date: Wed Jun 29 19:43:07 2005
New Revision: 202469
URL: http://svn.apache.org/viewcvs?rev=202469&view=rev
Log:
MTOM changes. Fix the bug of writing an additional CRLF.
Now the sample works fine up to engine.send() in the response.
Modified:
webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis/attachments/MIMEHelper.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/MIMEOutputUtils.java
Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java?rev=202469&r1=202468&r2=202469&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java Wed Jun 29 19:43:07 2005
@@ -48,7 +48,7 @@
private EndpointReference targetEPR =
new EndpointReference(AddressingConstants.WSA_TO,
"http://127.0.0.1:"
- + (UtilServer.TESTING_PORT + 1)
+ + (UtilServer.TESTING_PORT+1)
+ "/axis/services/EchoXMLService/echoMTOMtoBase64");
private Log log = LogFactory.getLog(getClass());
private QName serviceName = new QName("EchoXMLService");
@@ -92,13 +92,15 @@
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+ OMElement rpcWrapEle = fac.createOMElement("methodeWrap",omNs);
OMElement data = fac.createOMElement("data", omNs);
byte[] byteArray = new byte[] { 13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
98 };
DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
OMTextImpl textData = new OMTextImpl(dataHandler, true);
data.addChild(textData);
- return data;
+ rpcWrapEle.addChild(data);
+ return rpcWrapEle;
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/attachments/MIMEHelper.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/attachments/MIMEHelper.java?rev=202469&r1=202468&r2=202469&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/attachments/MIMEHelper.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/attachments/MIMEHelper.java Wed Jun 29 19:43:07 2005
@@ -234,8 +234,6 @@
private MimeBodyPart getMimeBodyPart() throws OMException {
MimeBodyPart mimeBodyPart = null;
-
-
//String Line = pushbackInStream.readLine();
MimeBodyPartInputStream partStream;
try {
@@ -285,7 +283,6 @@
String partContentID;
try {
partContentID = nextMimeBodyPart.getContentID();
-
bodyPartsMap.put(partContentID, nextMimeBodyPart);
return nextMimeBodyPart;
} catch (MessagingException e) {
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/MIMEOutputUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/MIMEOutputUtils.java?rev=202469&r1=202468&r2=202469&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/MIMEOutputUtils.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/MIMEOutputUtils.java Wed Jun 29 19:43:07 2005
@@ -25,55 +25,57 @@
import javax.mail.internet.ContentType;
import javax.mail.internet.MimeBodyPart;
import javax.xml.stream.XMLStreamException;
+
/**
* @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
*/
public class MIMEOutputUtils {
-
+
private static byte[] CRLF = { 13, 10 };
-
+
static String SOAP_PART_CONTENT_ID = "<SOAPPart>";
-
+
public static void complete(OutputStream outStream,
OutputStream bufferedSoapOutStream, LinkedList binaryNodeList,
String boundary) throws XMLStreamException {
try {
startWritingMime(outStream, boundary);
-
-
- DataHandler dh = new DataHandler(bufferedSoapOutStream.toString(),
- "text/xml");
- MimeBodyPart rootMimeBodyPart = new MimeBodyPart();
- rootMimeBodyPart.setDataHandler(dh);
- rootMimeBodyPart.addHeader("Content-Type", "application/xop+xml");
- rootMimeBodyPart.addHeader("Content-Transfer-Encoding", "8bit");
- rootMimeBodyPart.addHeader("Content-ID", SOAP_PART_CONTENT_ID);
-
- writeBodyPart(outStream, rootMimeBodyPart, boundary);
-
- Iterator binaryNodeIterator = binaryNodeList.iterator();
- while (binaryNodeIterator.hasNext()) {
- OMText binaryNode = (OMText) binaryNodeIterator.next();
- writeBodyPart(outStream, createMimeBodyPart(binaryNode), boundary);
- }
- finishWritingMime(outStream);
+
+ DataHandler dh = new DataHandler(bufferedSoapOutStream.toString(),
+ "text/xml");
+ MimeBodyPart rootMimeBodyPart = new MimeBodyPart();
+ rootMimeBodyPart.setDataHandler(dh);
+ rootMimeBodyPart.addHeader("Content-Type", "application/xop+xml");
+ rootMimeBodyPart.addHeader("Content-Transfer-Encoding", "8bit");
+ rootMimeBodyPart.addHeader("Content-ID", SOAP_PART_CONTENT_ID);
+
+ writeBodyPart(outStream, rootMimeBodyPart, boundary);
+
+ Iterator binaryNodeIterator = binaryNodeList.iterator();
+ while (binaryNodeIterator.hasNext()) {
+ OMText binaryNode = (OMText) binaryNodeIterator.next();
+ writeBodyPart(outStream, createMimeBodyPart(binaryNode),
+ boundary);
+ }
+ finishWritingMime(outStream);
} catch (IOException e) {
- throw new OMException("Problem with the OutputStream."+e.toString());
+ throw new OMException("Problem with the OutputStream."
+ + e.toString());
} catch (MessagingException e) {
- throw new OMException("Problem writing Mime Parts."+e.toString());
+ throw new OMException("Problem writing Mime Parts." + e.toString());
}
}
-
+
private static MimeBodyPart createMimeBodyPart(OMText node)
- throws MessagingException {
+ throws MessagingException {
MimeBodyPart mimeBodyPart = new MimeBodyPart();
mimeBodyPart.setDataHandler(node.getDataHandler());
mimeBodyPart.addHeader("Content-Transfer-Encoding", "binary");
mimeBodyPart.addHeader("Content-ID", "<" + node.getContentID() + ">");
return mimeBodyPart;
-
+
}
-
+
/**
* @throws IOException
* This will write the boundary to output Stream
@@ -83,17 +85,17 @@
outStream.write(new byte[] { 45, 45 });
outStream.write(boundary.getBytes());
}
-
+
/**
* @throws IOException
* This will write the boundary with CRLF
*/
private static void startWritingMime(OutputStream outStream, String boundary)
- throws IOException {
+ throws IOException {
writeMimeBoundary(outStream, boundary);
- outStream.write(CRLF);
+ //outStream.write(CRLF);
}
-
+
/**
* this will write a CRLF for the earlier boudary then the BodyPart data
* with headers followed by boundary. Writes only the boundary. No more
@@ -110,16 +112,16 @@
outStream.write(CRLF);
writeMimeBoundary(outStream, boundary);
}
-
+
/**
* @throws IOException
* This will write "--" to the end of last boundary
*/
private static void finishWritingMime(OutputStream outStream)
- throws IOException {
+ throws IOException {
outStream.write(new byte[] { 45, 45 });
}
-
+
public static String getContentTypeForMime(String boundary) {
ContentType contentType = new ContentType();
contentType.setPrimaryType("multipart");
@@ -132,5 +134,5 @@
contentType.setParameter("startinfo", "application/xop+xml");
return contentType.toString();
}
-
+
}