You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2008/01/16 15:44:11 UTC

svn commit: r612472 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/attachment/ javascript/src/main/java/org/apache/cxf/javascript/ javascript/src/main/java/org/apache/cxf/javascript/service/ javascript/src/main/resources/org/apache/cxf...

Author: bimargulies
Date: Wed Jan 16 06:44:06 2008
New Revision: 612472

URL: http://svn.apache.org/viewvc?rev=612472&view=rev
Log:
Teach Javascript to send MtoM.

Added:
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java   (with props)
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoM.java   (with props)
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java   (with props)
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java   (with props)
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanWithDataHandler.java   (with props)
    incubator/cxf/trunk/rt/javascript/src/test/resources/MtoMBeans.xml   (with props)
    incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/MtoMTests.js   (with props)
Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
    incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java?rev=612472&r1=612471&r2=612472&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java Wed Jan 16 06:44:06 2008
@@ -103,7 +103,7 @@
             if (null == boundaryString) {
                 throw new IOException("Couldn't determine the boundary from the message!");
             }
-            boundary = boundaryString.getBytes();
+            boundary = boundaryString.getBytes("utf-8");
 
             stream = new PushbackInputStream(message.getContent(InputStream.class),
                     boundary.length * 2);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java?rev=612472&r1=612471&r2=612472&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java Wed Jan 16 06:44:06 2008
@@ -77,8 +77,9 @@
         if (boundaryIndex == boundary.length) {
             // boundary found
             boundaryFound = true;
+            int dashNext = inStream.read();
             // read the end of line character
-            if (inStream.read() == 45 && value == 45) {
+            if (dashNext == 45 && value == 45) {
                 // Last mime boundary should have a succeeding "--"
                 // as we are on it, read the terminating CRLF
                 inStream.read();

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java?rev=612472&r1=612471&r2=612472&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java Wed Jan 16 06:44:06 2008
@@ -27,11 +27,16 @@
 
 import javax.xml.namespace.QName;
 
+import org.w3c.dom.Attr;
+
 import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.databinding.source.mime.MimeAttribute;
 import org.apache.cxf.wsdl.WSDLConstants;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaObject;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.constants.Constants;
 
 /**
  * A set of functions that assist in JavaScript generation. This includes
@@ -212,6 +217,22 @@
     public static String javaScriptNameToken(String token) {
         return token;
     }
+    
+    private String getMtomContentTypes(XmlSchemaObject schemaObject) {
+        if (schemaObject == null) {
+            return null;
+        }
+        
+        Map metaInfoMap = schemaObject.getMetaInfoMap();
+        if (metaInfoMap != null) {
+            Map attribMap = (Map)metaInfoMap.get(Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES);
+            Attr ctAttr = (Attr)attribMap.get(MimeAttribute.MIME_QNAME);
+            if (ctAttr != null) {
+                return ctAttr.getValue();
+            }
+        }
+        return null;
+    }
 
     /**
      * Given an element, generate the serialization code.
@@ -228,6 +249,7 @@
         boolean nillable = elementInfo.isNillable();
         boolean optional = elementInfo.isOptional();
         boolean array = elementInfo.isArray();
+        String mtomContentTypes = getMtomContentTypes(elementInfo.getParticle());
         String jsVar = referencePrefix + elementInfo.getJavascriptName();
         appendLine("// block for local variables");
         startBlock(); // allow local variables.
@@ -263,42 +285,7 @@
         }
         
         if (elementInfo.isAnyType()) {
-            // name a variable for convenience.
-            appendLine("var anyHolder = " + jsVar + ";");
-            appendLine("var anySerializer;");
-            appendLine("var typeAttr = '';");
-            // we look in the global array for a serializer.
-            startIf("anyHolder != null");
-            startIf("!anyHolder.raw"); // no serializer for raw.
-            // In anyType, the QName is for the type, not an element.
-            appendLine("anySerializer = "
-                       + "cxfjsutils.interfaceObject.globalElementSerializers[anyHolder.qname];");
-            endBlock();
-            startIf("anyHolder.xsiType");
-            appendLine("var typePrefix = 'cxfjst" + anyTypePrefixCounter + "';");
-            anyTypePrefixCounter++;
-            appendLine("var typeAttr = 'xmlns:' + typePrefix + '=\\\''"
-                       + " + anyHolder.namespaceURI + '\\\'';");
-            appendLine("typeAttr = typeAttr + ' xsi:type=\\\'' + typePrefix + ':' "
-                       + "+ anyHolder.localName + '\\\'';");
-            endBlock();
-            startIf("anySerializer");
-            appendExpression(jsVar 
-                             + ".serialize(cxfjsutils, '" 
-                             + elementInfo.getXmlName() + "', typeAttr)");
-            appendElse(); // simple type or raw
-            appendExpression("'<" + elementInfo.getXmlName() + " ' + typeAttr + " + "'>'");
-            startIf("!anyHolder.raw");
-            appendExpression("cxfjsutils.escapeXmlEntities(" + jsVar + ")");
-            appendElse();
-            appendExpression("anyHolder.xml");
-            endBlock();
-            appendString("</" + elementInfo.getXmlName() + ">");
-            endBlock();
-            appendElse(); // nil (from null holder)
-            appendString("<" + elementInfo.getXmlName() 
-                         + " " + XmlSchemaUtils.XSI_NIL + "/>");
-            endBlock();
+            serializeAnyTypeElement(elementInfo, jsVar);
         } else if (type instanceof XmlSchemaComplexType) {
             // it has a value
             // pass the extra null in the slot for the 'extra namespaces' needed
@@ -308,7 +295,11 @@
                              + elementInfo.getXmlName() + "', null)");
         } else { // simple type
             appendString("<" + elementInfo.getXmlName() + ">");
-            appendExpression("cxfjsutils.escapeXmlEntities(" + jsVar + ")");
+            if (mtomContentTypes != null) {
+                appendExpression("cxfjsutils.packageMtom(" + jsVar + ")");
+            } else {
+                appendExpression("cxfjsutils.escapeXmlEntities(" + jsVar + ")");
+            }
             appendString("</" + elementInfo.getXmlName() + ">");
         }
         
@@ -327,6 +318,45 @@
             endBlock();
         }
         endBlock(); // local variables
+    }
+
+    private void serializeAnyTypeElement(ParticleInfo elementInfo, String jsVar) {
+        // name a variable for convenience.
+        appendLine("var anyHolder = " + jsVar + ";");
+        appendLine("var anySerializer;");
+        appendLine("var typeAttr = '';");
+        // we look in the global array for a serializer.
+        startIf("anyHolder != null");
+        startIf("!anyHolder.raw"); // no serializer for raw.
+        // In anyType, the QName is for the type, not an element.
+        appendLine("anySerializer = "
+                   + "cxfjsutils.interfaceObject.globalElementSerializers[anyHolder.qname];");
+        endBlock();
+        startIf("anyHolder.xsiType");
+        appendLine("var typePrefix = 'cxfjst" + anyTypePrefixCounter + "';");
+        anyTypePrefixCounter++;
+        appendLine("var typeAttr = 'xmlns:' + typePrefix + '=\\\''"
+                   + " + anyHolder.namespaceURI + '\\\'';");
+        appendLine("typeAttr = typeAttr + ' xsi:type=\\\'' + typePrefix + ':' "
+                   + "+ anyHolder.localName + '\\\'';");
+        endBlock();
+        startIf("anySerializer");
+        appendExpression(jsVar 
+                         + ".serialize(cxfjsutils, '" 
+                         + elementInfo.getXmlName() + "', typeAttr)");
+        appendElse(); // simple type or raw
+        appendExpression("'<" + elementInfo.getXmlName() + " ' + typeAttr + " + "'>'");
+        startIf("!anyHolder.raw");
+        appendExpression("cxfjsutils.escapeXmlEntities(" + jsVar + ")");
+        appendElse();
+        appendExpression("anyHolder.xml");
+        endBlock();
+        appendString("</" + elementInfo.getXmlName() + ">");
+        endBlock();
+        appendElse(); // nil (from null holder)
+        appendString("<" + elementInfo.getXmlName() 
+                     + " " + XmlSchemaUtils.XSI_NIL + "/>");
+        endBlock();
     }
 
     /**

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=612472&r1=612471&r2=612472&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java Wed Jan 16 06:44:06 2008
@@ -336,6 +336,7 @@
                     + "("  + responseCallbackParams
                     + ((parameterList.length() > 0 && !currentOperation.isOneWay()) 
                         ? ", " : "") + parameterList + ") {\n");
+        utils.appendLine("this.client = new CxfApacheOrgClient(this.jsutils);");
         utils.appendLine("var xml = null;");
         if (inputMessage != null) {
             utils.appendLine("var args = new Array(" + inputParameterNames.size() + ");");
@@ -351,7 +352,7 @@
                              + "_serializeInput"
                              + "(this.jsutils, args);");
         }
-        utils.appendLine("this.client = new CxfApacheOrgClient(this.jsutils);");
+
         // we need to pass the caller's callback functions to our callback
         // functions.
         if (!currentOperation.isOneWay()) {

Modified: incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js?rev=612472&r1=612471&r2=612472&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js Wed Jan 16 06:44:06 2008
@@ -290,6 +290,8 @@
 function CxfApacheOrgClient(utils) {
 	utils.trace("Client constructor");
     this.utils = utils;
+    utils.client = this; // we aren't worried about multithreading!
+    this.mtomparts = [];
     this.soapAction = "";
     this.messageType = "CALL";
     // handler functions
@@ -304,6 +306,79 @@
     this.READY_STATE_DONE = 4;
 }
 
+const org_apache_cxf_pad_string_PAD_LEFT  = 0;
+const org_apache_cxf_pad_string_PAD_RIGHT = 1;
+const org_apache_cxf_pad_string_PAD_BOTH  = 2;
+
+function org_apache_cxf_pad_string(string, len, pad, type) {
+	var append = new String();
+
+	len = isNaN(len) ? 0 : len - string.length;
+	pad = typeof(pad) == 'string' ? pad : ' ';
+
+	if (type == org_apache_cxf_pad_string_PAD_BOTH) {
+		string = org_apache_cxf_pad_sring(Math.floor(len / 2) + string.length,
+				pad, org_apache_cxf_pad_string_PAD_LEFT);
+		return (org_apache_cxf_pad_string(Math.ceil(len / 2) + string.length,
+				pad, org_apache_cxf_pad_string_PAD_RIGHT));
+	}
+
+	while ((len -= pad.length) > 0)
+		append += pad;
+	append += pad.substr(0, len + pad.length);
+
+	return (type == org_apache_cxf_pad_string_PAD_LEFT
+			? append.concat(string)
+			: string.concat(append));
+}
+
+/*
+ * Generate a uniformly distributed random integer within the range <min> ..
+ * <max>. (min) - Lower limit: random >= min (default: 0) (max) - Upper limit:
+ * random <= max (default: 1)
+ */
+function org_apache_cxf_random_int(min, max) {
+    if (! isFinite(min)) min = 0;
+    if (! isFinite(max)) max = 1;
+    return Math.floor((Math.random () % 1) * (max - min + 1) + min);
+}
+
+function org_apache_cxf_random_hex_string(len)
+{
+	var random = org_apache_cxf_random_int(0, Math.pow (16, len) - 1);
+    return org_apache_cxf_pad_string(random.toString(16), len, '0', org_apache_cxf_pad_string_PAD_LEFT);
+}
+
+
+function org_apache_cxf_make_uuid(type) {
+	switch ((type || 'v4').toUpperCase()) {
+		// Version 4 UUID (Section 4.4 of RFC 4122)
+		case 'V4' :
+			var tl = org_apache_cxf_random_hex_string(8);
+			// time_low
+			var tm = org_apache_cxf_random_hex_string(4);
+			// time_mid
+			var thav = '4' + org_apache_cxf_random_hex_string(3);
+			// time_hi_and_version
+			var cshar = org_apache_cxf_random_int(0, 0xFF);
+			// clock_seq_hi_and_reserved
+			cshar = ((cshar & ~(1 << 6)) | (1 << 7)).toString(16);
+			var csl = org_apache_cxf_random_hex_string(2);
+			// clock_seq_low
+			var n = org_apache_cxf_random_hex_string(12);
+			// node
+
+			return (tl + '-' + tm + '-' + thav + '-' + cshar + csl + '-' + n);
+
+			// Nil UUID (Section 4.1.7 of RFC 4122)
+		case 'NIL' :
+			return '00000000-0000-0000-0000-000000000000';
+	}
+	return null;
+}
+
+const ORG_APACHE_CXF_MTOM_REQUEST_HEADER = 'Content-Type: application/xop+xml; type="text/xml"; charset=utf-8\r\n';
+
 // Caller must avoid stupid mistakes like 'GET' with a request body.
 // This does not support attempts to cross-script.
 // This imposes a relatively straightforward set of HTTP options.
@@ -345,8 +420,19 @@
 
 	this.utils.trace("about to open " + this.method + " " + this.url);
     this.req.open(this.method, this.url, !this.sync);
-
-    this.req.setRequestHeader("Content-Type", "application/xml");   
+ 
+    var mimeBoundary;
+    
+    // we can't do binary MTOM, but we can do 'text/plain' !
+	if(this.mtomparts.length > 0) {
+		var uuid = org_apache_cxf_make_uuid('v4');
+		mimeBoundary = '@_bOuNDaRy_' + uuid;
+		var ctHeader = 'Multipart/Related; start-info="text/xml"; type="application/xop+xml"; boundary="' + mimeBoundary + '"';
+    	this.req.setRequestHeader("Content-Type", ctHeader);
+		
+	} else {
+    	this.req.setRequestHeader("Content-Type", "application/xml");
+	}
 
     if (headers) { // must be array indexed by header field.
         for (var h in headers) {
@@ -366,10 +452,23 @@
     // NOTE: we do not call the onerror callback for a synchronous error
     // at request time. We let the request object throw as it will. 
     // onError will only be called for asynchronous errors.
-    this.utils.trace("about to send " + this.method + " " + this.url);
-    this.utils.trace(requestXML);
+    this.utils.trace("about to send data" + this.method + " " + this.url);
+    var dataToSend;
+    if(this.mtomparts.length == 0) {
+    	dataToSend = requestXML;
+    } else {
+    	dataToSend = "--" + mimeBoundary + "\r\n";
+    	dataToSend = dataToSend + ORG_APACHE_CXF_MTOM_REQUEST_HEADER + "\r\n";
+    	dataToSend = dataToSend + requestXML;
+    	for(var bx in this.mtomparts) {
+    		var part = this.mtomparts[bx];
+    		dataToSend += "\r\n\r\n--" + mimeBoundary + "\r\n";
+    		dataToSend += part;
+    	}
+   		dataToSend += "--" + mimeBoundary + "--\r\n";
+    }
     
-    this.req.send(requestXML);
+    this.req.send(dataToSend);
 }
 
 CxfApacheOrgClient.prototype.request = org_apache_cxf_client_request;
@@ -414,7 +513,18 @@
 	}
 }
 
-CxfApacheOrgClient.prototype.onReadyState = org_apache_cxf_client_onReadyState; 
+CxfApacheOrgClient.prototype.onReadyState = org_apache_cxf_client_onReadyState;
+
+function org_apache_cxf_package_mtom(value) {
+	var uuid = org_apache_cxf_make_uuid('v4');
+    var placeholder = '<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" '
+        +'href="cid:' + uuid + '" />';
+    var mtomObject = 'Content-Type: text/plain; charset="utf-8";\r\nContent-ID: <' + uuid + '>\r\n\r\n' + value + '\r\n';
+    this.client.mtomparts.push(mtomObject);
+	return placeholder;
+}
+
+CxfApacheOrgUtil.prototype.packageMtom = org_apache_cxf_package_mtom; 
 
 // Holder object used for xs:any
 // The namespaceURI and localName identify the global element from the schema.

Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java?rev=612472&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java Wed Jan 16 06:44:06 2008
@@ -0,0 +1,138 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+import javax.mail.util.ByteArrayDataSource;
+
+import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
+import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
+import org.apache.cxf.javascript.fortest.MtoM;
+import org.apache.cxf.javascript.fortest.MtoMImpl;
+import org.apache.cxf.javascript.fortest.MtoMParameterBeanNoDataHandler;
+import org.apache.cxf.javascript.fortest.MtoMParameterBeanWithDataHandler;
+import org.junit.Before;
+import org.junit.Test;
+import org.mozilla.javascript.Context;
+import org.springframework.context.support.GenericApplicationContext;
+
+/*
+ * We end up here with a part with isElement == true, a non-array element, 
+ * but a complex type for an array of the element.
+ */
+
+public class MtoMTest extends JavascriptRhinoTest {
+
+    MtoMImpl implementor;
+
+    public MtoMTest() throws Exception {
+        super();
+    }
+
+    @Override
+    protected void additionalSpringConfiguration(GenericApplicationContext context) throws Exception {
+    }
+    
+    @Override
+    protected String[] getConfigLocations() {
+        return new String[] {"classpath:MtoMBeans.xml"};
+    }
+    
+    @Before
+    public void before() throws Exception {
+        setupRhino("mtom-service-endpoint", 
+                   "/org/apache/cxf/javascript/MtoMTests.js",
+                   true);
+        implementor = (MtoMImpl)rawImplementor;
+        implementor.reset();
+    }
+    
+    private Void acceptMtoMString(Context context) throws IOException {
+        Notifier notifier = 
+            testUtilities.rhinoCallConvert("testMtoMString", Notifier.class, 
+                                           testUtilities.javaToJS(getAddress()));
+        boolean notified = notifier.waitForJavascript(1000 * 10);
+        assertTrue(notified);
+        Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
+        assertNull(errorStatus);
+        String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
+        assertNull(errorText);
+        assertEquals("disorganized<organized", implementor.getLastDHBean().getOrdinary());
+        InputStream dis = implementor.getLastDHBean().getNotXml10().getInputStream();
+        byte[] bytes = new byte[2048];
+        int byteCount = dis.read(bytes, 0, 2048);
+        String stuff = new String(bytes, 0, byteCount);
+        assertEquals("<html>\u0027</html>", stuff);
+        return null;
+    }
+
+    @org.junit.Ignore
+    @Test
+    public void jaxwsClientExperimentExpectAutoBase64() {
+        MtoM client = getBean(MtoM.class, "mtom-client");
+        assertNotNull(client);
+        MtoMParameterBeanNoDataHandler param = new MtoMParameterBeanNoDataHandler();
+        param.setOrdinary("blither<blather");
+        param.setNotXml10("<html>\u0027</html>");
+        client.receiveNonXmlNoDH(param);
+        MtoMParameterBeanNoDataHandler got = implementor.getLastBean();
+        assertEquals(param.getOrdinary(), got.getOrdinary());
+        assertEquals(param.getNotXml10(), got.getNotXml10());
+    }
+
+    // doesn't run right in mvn, only a devo tool, anyhow.
+    @org.junit.Ignore
+    @Test
+    public void jaxwsClientExperiment() throws IOException {
+        MtoM client = getBean(MtoM.class, "mtom-client");
+        assertNotNull(client);
+        MtoMParameterBeanWithDataHandler param = new MtoMParameterBeanWithDataHandler();
+        param.setOrdinary("blither<blather");
+        byte[] notXmlBytes = "Hello\u0027Sailor".getBytes("utf-8");
+        DataHandler byteDataHandler = 
+            new DataHandler(new ByteArrayDataSource(notXmlBytes,
+                            "text/plain"));
+        param.setNotXml10(byteDataHandler);
+        client.receiveNonXmlDH(param);
+        MtoMParameterBeanWithDataHandler got = implementor.getLastDHBean();
+        InputStream dis = got.getNotXml10().getInputStream();
+        byte[] bytes = new byte[2048];
+        int byteCount = dis.read(bytes, 0, 2048);
+        String stuff = new String(bytes, 0, byteCount);
+        assertEquals(param.getOrdinary(), got.getOrdinary());
+        assertEquals("Hello\u0027Sailor", stuff);
+    }
+    
+    @Test
+    public void acceptMtoMStringTest() {
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+            public Void run(Context context) {
+                try {
+                    return acceptMtoMString(context);
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        });
+    }
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoM.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoM.java?rev=612472&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoM.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoM.java Wed Jan 16 06:44:06 2008
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.cxf.javascript.fortest;
+
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+/**
+ * 
+ */
+@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+@WebService(targetNamespace = "uri:org.apache.cxf.javascript.fortest")
+public interface MtoM {
+    void receiveNonXmlDH(@WebParam(name = "theArg") MtoMParameterBeanWithDataHandler param);
+    void receiveNonXmlNoDH(@WebParam(name = "theArg") MtoMParameterBeanNoDataHandler param);
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoM.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoM.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java?rev=612472&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java Wed Jan 16 06:44:06 2008
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.cxf.javascript.fortest;
+
+import javax.jws.WebService;
+import javax.xml.ws.soap.MTOM;
+
+/**
+ * 
+ */
+@org.apache.cxf.feature.Features(features = "org.apache.cxf.feature.LoggingFeature")   
+@WebService(targetNamespace = "uri:org.apache.cxf.javascript.fortest")
+@MTOM
+public class MtoMImpl implements MtoM {
+    
+    private MtoMParameterBeanNoDataHandler lastBean;
+    private MtoMParameterBeanWithDataHandler lastDHBean;
+
+    public void reset() {
+        lastBean = null;
+        lastDHBean = null;
+    }
+
+    public MtoMParameterBeanNoDataHandler getLastBean() {
+        return lastBean;
+    }
+
+    public void receiveNonXmlDH(MtoMParameterBeanNoDataHandler param) {
+        lastBean = param;
+    }
+
+    public MtoMParameterBeanWithDataHandler getLastDHBean() {
+        return lastDHBean;
+    }
+
+    public void receiveNonXmlDH(MtoMParameterBeanWithDataHandler param) {
+        lastDHBean = param;
+    }
+
+    public void receiveNonXmlNoDH(MtoMParameterBeanNoDataHandler param) {
+        lastBean = param;
+    }
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java?rev=612472&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java Wed Jan 16 06:44:06 2008
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.cxf.javascript.fortest;
+
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * 
+ */
+@XmlType(namespace = "uri:org.apache.cxf.javascript.testns")
+public class MtoMParameterBeanNoDataHandler {
+    private String ordinary;
+    private String notXml10;
+    
+    public String getOrdinary() {
+        return ordinary;
+    }
+    public void setOrdinary(String ordinary) {
+        this.ordinary = ordinary;
+    }
+    
+    @XmlMimeType("text/plain")
+    @XmlSchemaType(name = "base64Binary")
+    public String getNotXml10() {
+        return notXml10;
+    }
+    public void setNotXml10(String notXml10) {
+        this.notXml10 = notXml10;
+    }
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanWithDataHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanWithDataHandler.java?rev=612472&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanWithDataHandler.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanWithDataHandler.java Wed Jan 16 06:44:06 2008
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.cxf.javascript.fortest;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * 
+ */
+@XmlType(namespace = "uri:org.apache.cxf.javascript.testns")
+public class MtoMParameterBeanWithDataHandler {
+    private String ordinary;
+    private DataHandler notXml10;
+    
+    public String getOrdinary() {
+        return ordinary;
+    }
+    public void setOrdinary(String ordinary) {
+        this.ordinary = ordinary;
+    }
+    
+    @XmlMimeType("text/plain")
+    @XmlSchemaType(name = "base64Binary")
+    public DataHandler getNotXml10() {
+        return notXml10;
+    }
+    public void setNotXml10(DataHandler notXml10) {
+        this.notXml10 = notXml10;
+    }
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanWithDataHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanWithDataHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/javascript/src/test/resources/MtoMBeans.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/MtoMBeans.xml?rev=612472&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/MtoMBeans.xml (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/MtoMBeans.xml Wed Jan 16 06:44:06 2008
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:jaxws="http://cxf.apache.org/jaxws"
+  xsi:schemaLocation="
+           http://cxf.apache.org/jaxws                                 
+              http://cxf.apache.org/schemas/jaxws.xsd
+           http://www.springframework.org/schema/beans
+              http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+              
+  <import resource="classpath:META-INF/cxf/cxf.xml" />
+  <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+  <import resource="classpath:META-INF/cxf/cxf-extension-xml.xml" />
+  <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+  <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+  <import resource="classpath:META-INF/cxf/cxf-extension-javascript-client.xml" />
+
+              
+ <jaxws:server id="mtom-service-endpoint" 
+    address="http://localhost:8808/mtom" >
+    <jaxws:serviceBean>
+      <bean class='org.apache.cxf.javascript.fortest.MtoMImpl'/>
+    </jaxws:serviceBean>
+ </jaxws:server>
+ 
+ <jaxws:client id="mtom-client" 
+ 			   address="http://localhost:8808/mtom" 
+ 			   serviceClass="org.apache.cxf.javascript.fortest.MtoM">
+    <jaxws:inInterceptors>
+			<bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
+		</jaxws:inInterceptors>
+		<jaxws:outInterceptors>
+			<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
+		</jaxws:outInterceptors>
+	</jaxws:client>
+ 
+ </beans>
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/javascript/src/test/resources/MtoMBeans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/test/resources/MtoMBeans.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/javascript/src/test/resources/MtoMBeans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/MtoMTests.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/MtoMTests.js?rev=612472&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/MtoMTests.js (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/MtoMTests.js Wed Jan 16 06:44:06 2008
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+function assertionFailed(explanation)
+{
+ 	var assert = new Assert(explanation); // this will throw out in Java.
+}
+
+var globalNotifier = null;
+var globalErrorStatus = null;
+var globalErrorStatusText = null;
+var globalResponseObject = null;
+
+function resetGlobals() {
+	globalNotifier = null;
+	globalErrorStatus = null;
+	globalErrorStatusText = null;
+	globalResponseObject = null;
+}
+
+function errorCallback(httpStatus, httpStatusText) 
+{
+	globalErrorStatus = httpStatus;
+	globalStatusText = httpStatusText;
+	globalNotifier.notify();
+}
+
+function successCallback(responseObject) 
+{
+	globalResponseObject = responseObject;
+	globalNotifier.notify();
+}
+
+function testMtoMString(url) {
+	globalNotifier = new org_apache_cxf_notifier();
+
+	var service = new org_apache_cxf_javascript_fortest_MtoM();
+	service.url = url;
+	var param = new org_apache_cxf_javascript_testns_mtoMParameterBeanWithDataHandler();
+	param.setOrdinary("disorganized<organized");
+	param.setNotXml10("<html>\u0027</html>");
+	// 'DH' means that the client side will use a DataHandler
+	service.receiveNonXmlDH(successCallback, errorCallback, param);
+	return globalNotifier;
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/MtoMTests.js
------------------------------------------------------------------------------
    svn:eol-style = native