Author: dkulp
Date: Mon Nov  2 15:22:51 2009
New Revision: 831917

URL: http://svn.apache.org/viewvc?rev=831917&view=rev
Log:
Merged revisions 831688 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r831688 | bimargulies | 2009-11-01 10:43:30 -0500 (Sun, 01 Nov 2009) | 1 line
  
  CXF-2513. Javascript generated code has to ignore env:Header (and anything 
else that shows up ahead of env:Body).
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    
cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
    
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
    
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java
    
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
    
cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js

Propchange: cxf/branches/2.2.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=831917&r1=831916&r2=831917&view=diff
==============================================================================
--- 
cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
 (original)
+++ 
cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
 Mon Nov  2 15:22:51 2009
@@ -468,6 +468,14 @@
                 utils.appendLine("element = 
this.jsutils.getFirstElementChild(element);");
                 utils.appendLine("this.jsutils.trace('first element child: ' "
                                  + "+ 
this.jsutils.traceElementName(element));");
+                // loop to find the body.
+                utils.startWhile("!this.jsutils.isNodeNamedNS(element, "
+                                 + 
"'http://schemas.xmlsoap.org/soap/envelope/', 'Body')");
+                utils.appendLine("element = 
this.jsutils.getNextElementSibling(element);");
+                utils.startIf("element == null");
+                utils.appendLine("throw 'No env:Body in message.'");
+                utils.endBlock();
+                utils.endBlock();
                 // Go down one more from the body to the response item.
                 utils.appendLine("element = 
this.jsutils.getFirstElementChild(element);");
                 utils.appendLine("this.jsutils.trace('part element: ' "

Modified: 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java?rev=831917&r1=831916&r2=831917&view=diff
==============================================================================
--- 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
 (original)
+++ 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
 Mon Nov  2 15:22:51 2009
@@ -140,6 +140,37 @@
     }
     
     @Test
+    public void callFunctionWithHeader() {
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+
+            public Void run(Context context) {
+                LOG.info("About to call testDummyHeader " + getAddress());
+                Notifier notifier = 
+                    testUtilities.rhinoCallConvert("testDummyHeader", 
Notifier.class, 
+                                                   
testUtilities.javaToJS(getAddress()), 
+                                                   
testUtilities.javaToJS("narcissus"),
+                                                   null);
+                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);
+
+                Scriptable responseObject = 
(Scriptable)testUtilities.rhinoEvaluate("globalResponseObject");
+                assertNotNull(responseObject);
+                // by default, for doc/lit/wrapped, we end up with a part 
object with a slot named 
+                // 'return'.
+                String returnValue = 
testUtilities.rhinoCallMethodInContext(String.class, responseObject,
+                                                                             
"getReturn");
+                assertEquals("narcissus", returnValue);
+                return null;
+            }
+            
+        });
+    }
+    
+    @Test
     public void callIntReturnMethod() {
         testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
             public Void run(Context context) {

Modified: 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java?rev=831917&r1=831916&r2=831917&view=diff
==============================================================================
--- 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java
 (original)
+++ 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java
 Mon Nov  2 15:22:51 2009
@@ -52,6 +52,9 @@
     TestBean1 functionReturnTestBean1();
     
     @WebMethod
+    String echoWithHeader(@WebParam(name = "what") String what);
+    
+    @WebMethod
     int basicTypeFunctionReturnInt(@WebParam(name = "s") String s, 
                                    @WebParam(name = "i") int i, 
                                    @WebParam(name = "l") long l, 

Modified: 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java?rev=831917&r1=831916&r2=831917&view=diff
==============================================================================
--- 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
 (original)
+++ 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
 Mon Nov  2 15:22:51 2009
@@ -19,7 +19,17 @@
 
 package org.apache.cxf.javascript.fortest;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Resource;
 import javax.jws.WebService;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.headers.Header;
+import org.apache.cxf.jaxb.JAXBDataBinding;
 
 /**
  * 
@@ -28,6 +38,8 @@
             targetNamespace = "uri:org.apache.cxf.javascript.fortest")
 public class SimpleDocLitWrappedImpl implements SimpleDocLitWrapped {
     
+    @Resource
+    private WebServiceContext context;
     private String lastString;
     private int lastInt;
     private long lastLong;
@@ -38,6 +50,20 @@
     private SpecificGenericClass lastSpecificGeneric;
     private GenericGenericClass<Double> lastGenericGeneric;
     private InheritanceTestDerived lastInheritanceTestDerived;
+    
+    public String echoWithHeader(String what) {
+        List<Header> headers = new ArrayList<Header>();
+        Header dummyHeader;
+        try {
+            dummyHeader = new Header(new QName("uri:org.apache.cxf", "dummy"), 
"decapitated",
+                                            new JAXBDataBinding(String.class));
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+        headers.add(dummyHeader);
+        context.getMessageContext().put(Header.HEADER_LIST, headers);
+        return what;
+    }
 
     /** {...@inheritdoc}*/
     public int basicTypeFunctionReturnInt(String s, int i, long l, float f, 
double d) {

Modified: 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js?rev=831917&r1=831916&r2=831917&view=diff
==============================================================================
--- 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js
 (original)
+++ 
cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js
 Mon Nov  2 15:22:51 2009
@@ -134,4 +134,18 @@
        intf.inheritanceTestFunction(test1SuccessCallback, test1ErrorCallback, 
derived);
 
        return globalNotifier;
+}
+
+function testDummyHeader(url, stringArg) 
+{
+       org_apache_cxf_trace.trace("Enter testDummyHeader.");
+       resetGlobals();
+       globalNotifier = new org_apache_cxf_notifier();
+       
+       var intf = new org_apache_cxf_javascript_fortest_SimpleDocLitWrapped();
+       intf.url = url;
+       // param order from the interface
+       intf.echoWithHeader(test1SuccessCallback, test1ErrorCallback, 
stringArg);
+    // Return the notifier as a convenience to the Java code.
+       return globalNotifier;
 }
\ No newline at end of file


Reply via email to