Author: bimargulies
Date: Wed Dec 12 19:45:11 2007
New Revision: 603809

URL: http://svn.apache.org/viewvc?rev=603809&view=rev
Log:
Fix anonymous type problem with explicit @WebReturn on a wrapped method.

Modified:
    
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties
    
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
    
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
    
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/RPCClientTest.java
    
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
    
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/hwdemo/GreeterImpl.java
    incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties
    
incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js

Modified: 
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties?rev=603809&r1=603808&r2=603809&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties
 (original)
+++ 
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/Messages.properties
 Wed Dec 12 19:45:11 2007
@@ -26,4 +26,5 @@
 MISSING_SERVICE_SCHEMA= Target namespace {0} specified for service {1} is not 
defined in the service model.
 MISSING_WRAPPER_TYPE= Part {2} in operation {1} of {0} has no schema type.
 IMPOSSIBLE_OUTPUT_TYPE= Output message {0} has type represented by {1}.
-ANONYMOUS_OUTPUT_TYPE= Output message {0} has anonymous type.
\ No newline at end of file
+ANONYMOUS_OUTPUT_TYPE= Output message {0} has anonymous type.
+NON_ELEMENT_ANON_TYPE_PART= Input message {0} has wrapped part {1} that has no 
element and no named type.
\ No newline at end of file

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=603809&r1=603808&r2=603809&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 Dec 12 19:45:11 2007
@@ -386,7 +386,6 @@
         XmlSchemaType type;
         
         if (isRPC) {
-            // in the RPC case, there is an extra level of element for the 
output message.
             utils.appendLine("cxfjsutils.trace('rpc element: ' + 
cxfjsutils.traceElementName(partElement));");
             utils.appendLine("partElement = 
cxfjsutils.getFirstElementChild(partElement);");
             utils.appendLine("cxfjsutils.trace('rpc element: ' + 
cxfjsutils.traceElementName(partElement));");
@@ -402,13 +401,15 @@
             if (type instanceof XmlSchemaComplexType) {
                 // if there are no response items, the type is likely to have 
no name and no particle.
                 XmlSchemaComplexType complexType = (XmlSchemaComplexType)type;
-                // if it is anonymous but not empty, we're in trouble here, as 
we have no way to talk
-                // about it. The code in getElementsForParts should have dealt 
with this.
-                String typeObjectName = null;
+                QName nameToDeserialize = null; 
                 if (null == complexType.getName()) {
-                    throw new RuntimeException("anonymous type unexpected.");
+                    nameToDeserialize = element.getElement().getQName();
+                } else {
+                    nameToDeserialize = complexType.getQName();
                 }
-                typeObjectName = 
nameManager.getJavascriptName(complexType.getQName());
+                
+                String typeObjectName = 
nameManager.getJavascriptName(nameToDeserialize);
+                
                 utils
                     .appendLine("var returnObject = " 
                                 + typeObjectName 
@@ -592,7 +593,8 @@
             }
             
             boolean empty = isEmptyType(type, diagnosticName);
-            if (!empty && type instanceof XmlSchemaComplexType && 
type.getName() == null) {
+            // In the bare case, if the type is nameless but contains but one 
element, concentrate on that.
+            if (!empty && type instanceof XmlSchemaComplexType && 
type.getName() == null && !isWrapped) {
                 XmlSchemaElement betterElement = 
getBuriedElement((XmlSchemaComplexType) type,
                                                                   
diagnosticName);
                 if (betterElement != null) {
@@ -660,7 +662,14 @@
             
             if (inputWrapperComplexType.getQName() == null) {
                 // we should be ignoring this for zero-argument wrappers.
-                inputWrapperClassName = 
nameManager.getJavascriptName(inputWrapperPartInfo.getName());
+                if (inputWrapperPartInfo.isElement()) {
+                    inputWrapperClassName = nameManager.
+                        
getJavascriptName(inputWrapperPartInfo.getElementQName());
+                } else {
+                    unsupportedConstruct("NON_ELEMENT_ANON_TYPE_PART", 
+                                         
inputWrapperPartInfo.getMessageInfo().getName(),
+                                         inputWrapperPartInfo.getName());
+                }
             } else {
                 inputWrapperClassName = 
nameManager.getJavascriptName(inputWrapperComplexType.getQName());
             }

Modified: 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java?rev=603809&r1=603808&r2=603809&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
 (original)
+++ 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
 Wed Dec 12 19:45:11 2007
@@ -21,8 +21,12 @@
 
 import java.io.File;
 import java.net.URL;
+
+import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
+import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
 import org.junit.Before;
 import org.junit.Test;
+import org.mozilla.javascript.Context;
 import org.springframework.context.support.GenericApplicationContext;
 
 /**
@@ -48,12 +52,34 @@
                    true);
     }
     
-    @Test
-    public void testCallSayHi() throws Exception {
+    private Void sayHiCaller(Context context) {
+        Notifier notifier = 
+            testUtilities.rhinoCallConvert("sayHiTest", Notifier.class, 
+                                           
testUtilities.javaToJS(endpoint.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);
+
+        // this method returns a String inside of an object, since there's an 
@WebResponse
+        String responseObject = 
testUtilities.rhinoEvaluateConvert("globalResponseObject.getResponseType()", 
+                                                                   
String.class);
+        assertEquals("Bonjour", responseObject);
+        return null;
     }
     
-    
+    @Test
+    public void testCallSayHi() throws Exception {
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+            public Void run(Context context) {
+                return sayHiCaller(context);
+            }
+        });
+    }
+
     public String getStaticResourceURL() throws Exception {
         File staticFile = new 
File(this.getClass().getResource("test.html").toURI());
         staticFile = staticFile.getParentFile();

Modified: 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/RPCClientTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/RPCClientTest.java?rev=603809&r1=603808&r2=603809&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/RPCClientTest.java
 (original)
+++ 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/RPCClientTest.java
 Wed Dec 12 19:45:11 2007
@@ -83,7 +83,6 @@
 
         // this method returns a String.
         String responseObject = 
testUtilities.rhinoEvaluateConvert("globalResponseObject", String.class);
-        // there is no response, this thing returns 'void'
         assertEquals("String Parameter", responseObject);
         SimpleRPCImpl impl = getBean(SimpleRPCImpl.class, "rpc-service");
         assertEquals("String Parameter", impl.getLastString());

Modified: 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java?rev=603809&r1=603808&r2=603809&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
 (original)
+++ 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
 Wed Dec 12 19:45:11 2007
@@ -28,7 +28,7 @@
  */
 @WebService(endpointInterface = 
"org.apache.cxf.javascript.fortest.SimpleDocLitWrapped",
             targetNamespace = "uri:org.apache.cxf.javascript.fortest")
-//@Features(features = "org.apache.cxf.feature.LoggingFeature")   
[EMAIL PROTECTED](features = "org.apache.cxf.feature.LoggingFeature") 
 public class SimpleDocLitWrappedImpl implements SimpleDocLitWrapped {
     
     private String lastString;

Modified: 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/hwdemo/GreeterImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/hwdemo/GreeterImpl.java?rev=603809&r1=603808&r2=603809&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/hwdemo/GreeterImpl.java
 (original)
+++ 
incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/hwdemo/GreeterImpl.java
 Wed Dec 12 19:45:11 2007
@@ -29,7 +29,7 @@
 @javax.jws.WebService(portName = "SoapPort", serviceName = "SOAPService", 
                       targetNamespace = 
"http://apache.org/hello_world_soap_http";, 
                       endpointInterface = 
"org.apache.hello_world_soap_http.Greeter")
-                  
[EMAIL PROTECTED](features = "org.apache.cxf.feature.LoggingFeature")      
 public class GreeterImpl implements Greeter {
 
     private static final Logger LOG = LogUtils.getL7dLogger(GreeterImpl.class);
@@ -39,8 +39,6 @@
      */
     public String greetMe(String me) {
         LOG.info("Executing operation greetMe");
-        System.out.println("Executing operation greetMe");
-        System.out.println("Message received: " + me + "\n");
         return "Hello " + me;
     }
     
@@ -49,8 +47,6 @@
      */
     public void greetMeOneWay(String me) {
         LOG.info("Executing operation greetMeOneWay");
-        System.out.println("Executing operation greetMeOneWay\n");
-        System.out.println("Hello there " + me);
     }
 
     /* (non-Javadoc)
@@ -58,7 +54,6 @@
      */
     public String sayHi() {
         LOG.info("Executing operation sayHi");
-        System.out.println("Executing operation sayHi\n");
         return "Bonjour";
     }
     
@@ -67,9 +62,6 @@
         faultDetail.setMajor((short)2);
         faultDetail.setMinor((short)1);
         LOG.info("Executing operation pingMe, throwing PingMeFault exception");
-        System.out.println("Executing operation pingMe, throwing PingMeFault 
exception\n");
         throw new PingMeFault("PingMeFault raised by server", faultDetail);
     }
-
-    
 }

Modified: 
incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties?rev=603809&r1=603808&r2=603809&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties 
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties Wed 
Dec 12 19:45:11 2007
@@ -23,10 +23,7 @@
 .level= INFO
 java.util.logging.ConsoleHandler.level = FINEST
 java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
-#org.apache.cxf.javascript.service.ServiceJavascriptBuilder.level=FINEST
-#org.apache.cxf.javascript.types.SchemaJavascriptBuilder.level=FINEST
-#org.apache.cxf.javascript.JavascriptTestUtilities.level=FINE
-#org.apache.cxf.javascript.JsXMLHttpRequest.level = FINE
-#org.apache.cxf.javascript.service.DocLitWrappedTest.level=FINE
+#org.apache.cxf.javascript.JavascriptTestUtilities.level=FINEST
+
 
 

Modified: 
incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js?rev=603809&r1=603808&r2=603809&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js
 (original)
+++ 
incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js
 Wed Dec 12 19:45:11 2007
@@ -21,3 +21,49 @@
 {
        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 testErrorCallback(httpStatus, httpStatusText) 
+{
+    org_apache_cxf_trace.trace("test error");
+       globalErrorStatus = httpStatus;
+       globalStatusText = httpStatusText;
+       globalNotifier.notify();
+}
+
+// Because there is an explicit response wrapper declared, we have a JavaScript
+// object here that wraps up the simple 'string'. It is easier to validate it
+// from Java, I think.
+function testSuccessCallback(responseObject) 
+{
+    org_apache_cxf_trace.trace("test success");
+       globalResponseObject = responseObject;
+       globalNotifier.notify();
+}
+
+function sayHiTest(url)
+{
+       org_apache_cxf_trace.trace("Enter sayHi.");
+       resetGlobals();
+       globalNotifier = new org_apache_cxf_notifier();
+       
+       var intf;
+    intf = new apache_org_hello_world_soap_http_Greeter();
+         
+       intf.url = url;
+    intf.sayHi(testSuccessCallback, testErrorCallback);
+    // Return the notifier as a convenience to the Java code.
+       return globalNotifier;
+}
+


Reply via email to