cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r606620 - in /incubator/cxf/trunk/rt/javascript: ./ src/main/java/org/apache/cxf/javascript/ src/main/java/org/apache/cxf/javascript/service/ src/main/java/org/apache/cxf/javascript/types/ src/main/resources/org/apache/cxf/javascript/ src/t...
Date Sun, 23 Dec 2007 21:48:05 GMT
Author: bimargulies
Date: Sun Dec 23 13:48:04 2007
New Revision: 606620

URL: http://svn.apache.org/viewvc?rev=606620&view=rev
Log:
Pass the first test of xs:any from JavaScript to Java. In spite of JAXB's best efforts.

Modified:
    incubator/cxf/trunk/rt/javascript/   (props changed)
    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/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
    incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
    incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
    incubator/cxf/trunk/rt/javascript/src/test/resources/wsdl/hello_world_any.wsdl

Propchange: incubator/cxf/trunk/rt/javascript/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Dec 23 13:48:04 2007
@@ -1,7 +1,8 @@
-target
-.settings
-.checkstyle
-.classpath
-.pmd
-.project
-.ruleset
+target
+.settings
+.checkstyle
+.classpath
+.pmd
+.project
+.ruleset
+*.launch

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=606620&r1=606619&r2=606620&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
Sun Dec 23 13:48:04 2007
@@ -258,8 +258,10 @@
         // now for the thing itself.
         if (type instanceof XmlSchemaComplexType) {
             // it has a value
-            appendExpression(jsVar + ".serialize(cxfjsutils, '" 
-                             + elementInfo.getXmlName() + "')");
+            // pass the extra null in the slot for the 'extra namespaces' needed by 'any'.
+            appendExpression(jsVar 
+                             + ".serialize(cxfjsutils, '" 
+                             + elementInfo.getXmlName() + "', null)");
         } else { // simple type
             QName typeName = type.getQName();
             appendString("<" + elementInfo.getXmlName() + ">");
@@ -311,7 +313,7 @@
         appendLine("anySerializer = "
                              + "cxfjsutils.interfaceObject.globalElementSerializers[anyHolder.qname];");
         appendLine("anyXmlTag = '" + prefix + ":' + anyHolder.localName;");
-        appendLine("anyXmlNsDef = 'xmlns:" + prefix + "=' + anyHolder.namespaceURI;");
+        appendLine("anyXmlNsDef = 'xmlns:" + prefix + "=\\'' + anyHolder.namespaceURI" +
" + '\\'';");
         appendLine("anyStartTag = '<' + anyXmlTag + ' ' + anyXmlNsDef + '>';");
         appendLine("anyEndTag = '</' + anyXmlTag + '>';");
         appendLine("anyEmptyTag = '<' + anyXmlTag + ' ' + anyXmlNsDef + '/>';");
@@ -341,7 +343,7 @@
         
         startIf("anySerializer"); // if no constructor, a simple type.
             // it has a value
-        appendExpression("anySerializer(cxfjsutils, anyXmlTag)"); 
+        appendExpression("anySerializer.call(" + varRef + ", cxfjsutils, anyXmlTag, anyXmlNsDef)");

         appendElse();
         appendExpression("anyStartTag");
         appendExpression("cxfjsutils.escapeXmlEntities(" + varRef + ")");

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=606620&r1=606619&r2=606620&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
Sun Dec 23 13:48:04 2007
@@ -319,7 +319,7 @@
                     +  opFunctionGlobalName
                     + "("  + responseCallbackParams
                     + ((parameterList.length() > 0 && !currentOperation.isOneWay())

-                        ? ", " + parameterList : "") + ") {\n");
+                        ? ", " : "") + parameterList + ") {\n");
         utils.appendLine("var xml = null;");
         if (inputMessage != null) {
             utils.appendLine("var args = new Array(" + inputParameterNames.size() + ");");

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=606620&r1=606619&r2=606620&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
Sun Dec 23 13:48:04 2007
@@ -296,7 +296,7 @@
         code.append("//\n");
         code.append("// Serialize " + name + "\n");
         code.append("//\n");
-        code.append("function " + functionName + "(cxfjsutils, elementName) {\n");
+        code.append("function " + functionName + "(cxfjsutils, elementName, extraNamespaces)
{\n");
         utils.startXmlStringAccumulator("xml");
         utils.startIf("elementName != null");
         utils.appendString("<");
@@ -307,6 +307,9 @@
             utils.appendString(" ");
             utils.appendString(moreNamespaces);
         }
+        utils.startIf("extraNamespaces");
+        utils.appendExpression("' ' + extraNamespaces");
+        utils.endBlock();
         utils.appendString(">");
         utils.endBlock();
         code.append(bodyCode);

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=606620&r1=606619&r2=606620&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
Sun Dec 23 13:48:04 2007
@@ -405,14 +405,14 @@
 CxfApacheOrgClient.prototype.onReadyState = org_apache_cxf_client_onReadyState; 
 
 // Holder object used for xs:any
-// The QName of the element goes into 'qname'
+// The namespaceURI and localName identify the global element from the schema.
 // The object to go with it goes into object.
 // If the Any is an array, put the array into the object slot.
 
-function org_apache_cxf_any_holder(qname, object) {
-	this.typeMarker = "org_apache_cxf_any_holder"; 
-	this.qname = qname;
+function org_apache_cxf_any_holder(namespaceURI, localName, object) {
+	this.typeMarker = "org_apache_cxf_any_holder";
+	this.namespaceURI = namespaceURI;
+	this.localName = localName;
+	this.qname = "{" + namespaceURI + "}" + localName;
 	this.object = object;
-	this.namespaceURI = this.qname.split(":", 1)[0];
-	this.localName = this.qname.split(":", 1)[1]; 
 }

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java?rev=606620&r1=606619&r2=606620&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
Sun Dec 23 13:48:04 2007
@@ -22,10 +22,13 @@
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
 import org.apache.cxf.javascript.fortest.AnyImpl;
 import org.junit.Before;
 import org.junit.Test;
+import org.mozilla.javascript.Context;
 import org.springframework.context.support.GenericApplicationContext;
+import uri.cxf_apache_org.jstest.types.any.alts.Alternative1;
 
 /*
  * We end up here with a part with isElement == true, a non-array element, 
@@ -61,10 +64,28 @@
         implementor.reset();
     }
     
+    private Void acceptOneChalk(Context context) {
+        LOG.info("About to call accept1 with Chalk" + endpoint.getAddress());
+        testUtilities.rhinoCall("testAny1ToServerChalk",  
+                                testUtilities.javaToJS(endpoint.getAddress()));
+        assertEquals("before chalk", implementor.getBefore());
+        Object someAlternative = implementor.getAny1value();
+        assertTrue(someAlternative instanceof Alternative1);
+        Alternative1 a1 = (Alternative1) someAlternative;
+        assertEquals("bismuth", a1.getChalk());
+        assertEquals("after chalk", implementor.getAfter());
+        return null;
+    }
+    
     @Test
-    public void testServerStartup() throws Exception {
-        LOG.fine("log something");
-        // no need to do anything, just see what happens on init!
+    public void callAcceptOneChalk() {
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+            public Void run(Context context) {
+                return acceptOneChalk(context);
+            }
+        });
     }
+
+
 
 }

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java?rev=606620&r1=606619&r2=606620&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
Sun Dec 23 13:48:04 2007
@@ -162,7 +162,7 @@
     }
     
     private Void onewayCaller(Context context) {
-        LOG.info("About to call actionMethod" + endpoint.getAddress());
+        LOG.info("About to call onewayMethod" + endpoint.getAddress());
         testUtilities.rhinoCall("actionMethodTest",  
                                 testUtilities.javaToJS(endpoint.getAddress()),
                                 "corrigan");

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java?rev=606620&r1=606619&r2=606620&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
Sun Dec 23 13:48:04 2007
@@ -369,8 +369,12 @@
             responseText = contentChars.toString();
             LOG.fine(responseText);
             
+            // For a one-way message or whatever, there may not be a content type.
             // throw away any encoding modifier.
-            String contentType = connection.getContentType().split(";")[0];
+            String contentType = "";
+            if (connection.getContentType() != null) {
+                contentType = connection.getContentType().split(";")[0];
+            }
             
             if ("text/xml".equals(contentType)
                 || "application/xml".equals(contentType) 

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java?rev=606620&r1=606619&r2=606620&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
Sun Dec 23 13:48:04 2007
@@ -34,6 +34,7 @@
 /**
  * 
  */
+@org.apache.cxf.feature.Features(features = "org.apache.cxf.feature.LoggingFeature")   
 public class AnyImpl implements AcceptAny {
 
     private Object any1value;
@@ -171,6 +172,10 @@
             r.setAny(null);
         }
         return r;
+    }
+
+    public void dummyAlts(uri.cxf_apache_org.jstest.types.any.alts.Alternative1 in) {
+        // not used, just here to force some types into sight.
     }
 }
 

Modified: incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js?rev=606620&r1=606619&r2=606620&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
Sun Dec 23 13:48:04 2007
@@ -36,5 +36,15 @@
 
 function testAny1ToServerChalk(url)
 {
+	var service = new cxf_apache_org_jstest_any_AcceptAny();
+	service.url = url;
+	var param = new cxf_apache_org_jstest_types_any_acceptAny1();
+	param.setBefore("before chalk");
+	var anyOb = new cxf_apache_org_jstest_types_any_alts_alternative1();
+	anyOb.setChalk("bismuth");
+	var holder = new org_apache_cxf_any_holder("uri:cxf.apache.org:jstest:types:any:alts", "alternative1",
anyOb);
+	param.setAny(holder);
+	param.setAfter("after chalk");
+	service.acceptAny1(param);
 }
 

Modified: incubator/cxf/trunk/rt/javascript/src/test/resources/wsdl/hello_world_any.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/wsdl/hello_world_any.wsdl?rev=606620&r1=606619&r2=606620&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/wsdl/hello_world_any.wsdl (original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/wsdl/hello_world_any.wsdl Sun Dec
23 13:48:04 2007
@@ -23,37 +23,51 @@
 	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 	xmlns:tns="uri:cxf.apache.org:jstest:any"
 	xmlns:x1="uri:cxf.apache.org:jstest:types:any"
+	xmlns:alts="uri:cxf.apache.org:jstest:types:any:alts"
 	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
 	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 	<wsdl:types>
-		<schema targetNamespace="uri:cxf.apache.org:jstest:types:any"
-			xmlns="http://www.w3.org/2001/XMLSchema"
-			xmlns:tns="uri:cxf.apache.org:jstest:types:any"
-			elementFormDefault="qualified">
-
+	    <schema targetNamespace="uri:cxf.apache.org:jstest:types:any:alts"
+	    		xmlns="http://www.w3.org/2001/XMLSchema"
+			          xmlns:tns="uri:cxf.apache.org:jstest:types:any:alts"
+			    elementFormDefault="qualified">
+			    
 			<simpleType name="MyStringType">
 				<restriction base="string">
 					<maxLength value="30" />
 				</restriction>
 			</simpleType>
 
-			<complexType name="alternative1">
-				<sequence>
-					<element name="chalk" type="string" />
-				</sequence>
-			</complexType>
-
-			<complexType name="alternative2">
-				<sequence>
-					<element name="cheese" type="int" />
-				</sequence>
-			</complexType>
+			<element name="restrictedStringAlternative"
+				type="tns:MyStringType" />
+
+			<element name="alternative1">
+				<complexType>
+					<sequence>
+						<element name="chalk" type="string" />
+					</sequence>
+				</complexType>
+			</element>
+
+			<element name="alternative2">
+				<complexType>
+					<sequence>
+						<element name="cheese" type="int" />
+					</sequence>
+				</complexType>
+			</element>
+
+	    </schema>
+		<schema targetNamespace="uri:cxf.apache.org:jstest:types:any"
+			xmlns="http://www.w3.org/2001/XMLSchema"
+			xmlns:tns="uri:cxf.apache.org:jstest:types:any"
+			elementFormDefault="qualified">
 
 			<element name="acceptAny1">
 				<complexType>
 					<sequence>
 						<element name='before' type='string' />
-						<any minOccurs='1' />
+						<any minOccurs='1' namespace='##other' />
 						<element name='after' type='string' />
 					</sequence>
 				</complexType>
@@ -63,7 +77,7 @@
 				<complexType>
 					<sequence>
 						<element name='before' type='string' />
-						<any minOccurs='1' maxOccurs='10' />
+						<any minOccurs='1' maxOccurs='10'  namespace='##other'/>
 						<element name='after' type='string' />
 					</sequence>
 				</complexType>
@@ -73,24 +87,24 @@
 				<complexType>
 					<sequence>
 						<element name='before' type='string' />
-						<any minOccurs='0' maxOccurs='1' />
+						<any minOccurs='0' maxOccurs='1'  namespace='##other' />
 						<element name='after' type='string' />
 					</sequence>
 				</complexType>
 			</element>
-			
-        <element name='returnAny1'>
-			<complexType/>
-		</element>
-		
-		<element name='returnAnyN'>
-			<complexType/>
-		</element>
-		
-		<element name='returnAnyOptional'>
-			<complexType/>
-		</element>
-			
+
+			<element name='returnAny1'>
+				<complexType />
+			</element>
+
+			<element name='returnAnyN'>
+				<complexType />
+			</element>
+
+			<element name='returnAnyOptional'>
+				<complexType />
+			</element>
+
 		</schema>
 
 	</wsdl:types>
@@ -106,7 +120,7 @@
 	<wsdl:message name="acceptAnyOptional">
 		<wsdl:part name="in" element="x1:acceptAnyOptional" />
 	</wsdl:message>
-	
+
 	<wsdl:message name="returnAny1">
 		<wsdl:part name="in" element="x1:returnAny1" />
 	</wsdl:message>
@@ -130,6 +144,13 @@
 	<wsdl:message name="returnAnyOptionalResponse">
 		<wsdl:part name="out" element="x1:acceptAnyOptional" />
 	</wsdl:message>
+	
+	<!--  dummy message to get the alts package into the JAXB universe. -->
+	<!--  there has to be a better way to do this. -->
+	
+	<wsdl:message name="dummyAlts">
+		<wsdl:part name="in" element="alts:alternative1"/>
+	</wsdl:message>
 
 	<wsdl:portType name="AcceptAny">
 		<wsdl:operation name="acceptAny1">
@@ -147,18 +168,27 @@
 
 		<wsdl:operation name="returnAny1">
 			<wsdl:input name="returnAny1" message="tns:returnAny1" />
-			<wsdl:output name="returnAny1Response" message="tns:returnAny1Response" />
+			<wsdl:output name="returnAny1Response"
+				message="tns:returnAny1Response" />
 		</wsdl:operation>
 
 		<wsdl:operation name="returnAnyN">
 			<wsdl:input name="returnAnyN" message="tns:returnAnyN" />
-			<wsdl:output name="returnAnyNResponse" message="tns:returnAnyNResponse" />
+			<wsdl:output name="returnAnyNResponse"
+				message="tns:returnAnyNResponse" />
 		</wsdl:operation>
 
 		<wsdl:operation name="returnAnyOptional">
-			<wsdl:input name="returnAnyOptional" message="tns:returnAnyOptional" />
-			<wsdl:output name="returnAnyOptionalResponse" message="tns:returnAnyOptionalResponse"
/>
+			<wsdl:input name="returnAnyOptional"
+				message="tns:returnAnyOptional" />
+			<wsdl:output name="returnAnyOptionalResponse"
+				message="tns:returnAnyOptionalResponse" />
 		</wsdl:operation>
+		
+		<!--  dummy -->
+	    <wsdl:operation name="dummyAlts">
+	    	<wsdl:input name="dummyAlts" message="tns:dummyAlts"/>
+	    </wsdl:operation>
 
 	</wsdl:portType>
 	<wsdl:binding name="AcceptAny" type="tns:AcceptAny">
@@ -189,12 +219,12 @@
 			<wsdl:input>
 				<soap:body use="literal" />
 			</wsdl:input>
-			
+
 			<wsdl:output>
 				<soap:body use="literal" />
 			</wsdl:output>
 		</wsdl:operation>
-		
+
 		<wsdl:operation name="returnAnyN">
 			<soap:operation style="document" />
 			<wsdl:input>
@@ -212,6 +242,13 @@
 			<wsdl:output>
 				<soap:body use="literal" />
 			</wsdl:output>
+		</wsdl:operation>
+		
+		<wsdl:operation name="dummyAlts">
+			<soap:operation style="document"/>
+			<wsdl:input>
+				<soap:body use="literal"/>
+			</wsdl:input>
 		</wsdl:operation>
 
 	</wsdl:binding>



Mime
View raw message