Author: mmao
Date: Wed Sep 12 04:19:23 2007
New Revision: 574887

URL: http://svn.apache.org/viewvc?rev=574887&view=rev
Log:
CXF-993 
 
  * Client should ignore the header if the optional soap header is not 
generated as a parameter of the method


Added:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Impl.java
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Test.java
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Server.java
    incubator/cxf/trunk/systests/src/test/resources/wsdl/cxf-993.wsdl
Modified:
    
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
    incubator/cxf/trunk/systests/pom.xml

Modified: 
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java?rev=574887&r1=574886&r2=574887&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
 (original)
+++ 
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
 Wed Sep 12 04:19:23 2007
@@ -98,6 +98,7 @@
             xtw.writeNamespace(soapVersion.getPrefix(), 
soapVersion.getNamespace());
             
             boolean preexistingHeaders = message.hasHeaders();
+
             if (preexistingHeaders) {
                 xtw.writeStartElement(soapVersion.getPrefix(), 
                                       soapVersion.getHeader().getLocalPart(),
@@ -172,10 +173,13 @@
             if (headers == null) {
                 return endedHeader;
             }            
-            
+
             for (SoapHeaderInfo header : headers) {
                 MessagePartInfo part = header.getPart();
-
+                if (part.getIndex() >= objs.size()) {
+                    // The optional out of band header is not a part of 
parameters of the method
+                    continue;
+                }
                 Object arg = objs.get(part);
                 objs.remove(part);
                 if (!(startedHeader || preexistingHeaders)) {

Modified: incubator/cxf/trunk/systests/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/pom.xml?rev=574887&r1=574886&r2=574887&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/pom.xml (original)
+++ incubator/cxf/trunk/systests/pom.xml Wed Sep 12 04:19:23 2007
@@ -65,6 +65,11 @@
                                       <extraarg>-V</extraarg>
                                     </extraargs-->
                                 </wsdlOption>
+
+                                <wsdlOption>
+                                    
<wsdl>${basedir}/src/test/resources/wsdl/cxf-993.wsdl</wsdl>
+                                </wsdlOption>
+
                             </wsdlOptions>
                         </configuration>
                         <goals>

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Impl.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Impl.java?rev=574887&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Impl.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Impl.java
 Wed Sep 12 04:19:23 2007
@@ -0,0 +1,35 @@
+/**
+ * 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.systest.cxf993;
+
+import testnotification.NotificationServicePort;
+
+/**
+ * This class was generated by the CXF 2.1-incubator-SNAPSHOT
+ * Wed Sep 12 16:41:52 CST 2007
+ * Generated source version: 2.1-incubator-SNAPSHOT
+ * 
+ */
+
+public class Cxf993Impl implements NotificationServicePort {
+    public String sendNotification(testnotification.SendNotification 
parameters) {
+        return "dumy";
+    }
+}

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Test.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Test.java?rev=574887&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Test.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Cxf993Test.java
 Wed Sep 12 04:19:23 2007
@@ -0,0 +1,55 @@
+/**
+ * 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.systest.cxf993;
+
+import java.net.URL;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import testnotification.NotificationService;
+import testnotification.NotificationServicePort;
+import testnotification.SendNotification;
+
+public class Cxf993Test extends AbstractBusClientServerTestBase {
+
+    private final QName serviceName = new QName("urn://testnotification", 
"NotificationService");
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", 
launchServer(Server.class));
+    }
+
+    @Test
+    public void testBasicConnection() throws Exception {
+        assertEquals("dumy", getPort().sendNotification(new 
SendNotification()));
+    }
+
+    private NotificationServicePort getPort() {
+        URL wsdl = getClass().getResource("/wsdl/cxf-993.wsdl");
+        assertNotNull("WSDL is null", wsdl);
+
+        NotificationService service = new NotificationService(wsdl, 
serviceName);
+        assertNotNull("Service is ull ", service);
+
+        return service.getNotificationServicePort();
+    }
+}

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Server.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Server.java?rev=574887&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Server.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/cxf993/Server.java
 Wed Sep 12 04:19:23 2007
@@ -0,0 +1,45 @@
+/**
+ * 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.systest.cxf993;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+
+    protected void run()  {
+        Object implementor = new Cxf993Impl();
+        String address = "http://localhost:9018/notification";;
+        Endpoint.publish(address, implementor);
+    }
+
+    public static void main(String[] args) {
+        try {
+            Server s = new Server();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}

Added: incubator/cxf/trunk/systests/src/test/resources/wsdl/cxf-993.wsdl
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/wsdl/cxf-993.wsdl?rev=574887&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/resources/wsdl/cxf-993.wsdl (added)
+++ incubator/cxf/trunk/systests/src/test/resources/wsdl/cxf-993.wsdl Wed Sep 
12 04:19:23 2007
@@ -0,0 +1,89 @@
+<?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.
+-->
+<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"; 
+                 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
+                 xmlns:s="http://www.w3.org/2001/XMLSchema"; 
+                 xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; 
+                 xmlns:tns="urn://testnotification" 
+                 xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"; 
+                 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"; 
+                 targetNamespace="urn://testnotification" 
+                 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";>
+    <wsdl:types>
+       <s:schema elementFormDefault="qualified" 
targetNamespace="urn://testnotification">
+           <s:element name="sendNotification">
+               <s:complexType>
+                   <s:sequence>
+                       <s:element minOccurs="0" maxOccurs="1" 
name="NotificationInfo">
+                           <s:complexType>
+                               <s:sequence>
+                                   <s:any/>
+                               </s:sequence>
+                           </s:complexType>
+                       </s:element>
+                   </s:sequence>
+               </s:complexType>
+           </s:element>
+           <s:element name="AuthCredentials" type="tns:AuthCredentials"/>
+           <s:complexType name="AuthCredentials">
+               <s:sequence>
+                   <s:element minOccurs="0" maxOccurs="1" name="username" 
type="s:string"/>
+                   <s:element minOccurs="0" maxOccurs="1" name="password" 
type="s:string"/>
+               </s:sequence>
+           </s:complexType>
+       </s:schema>
+    </wsdl:types>
+
+    <wsdl:message name="notificationInput">
+       <wsdl:part name="parameters" element="tns:sendNotification"/>
+    </wsdl:message>
+    <wsdl:message name="notificationOutput">
+       <wsdl:part name="parameters" type="s:string"/>
+    </wsdl:message>
+    <wsdl:message name="sendNotificationAuthCredentials">
+       <wsdl:part name="AuthCredentials" element="tns:AuthCredentials"/>
+    </wsdl:message>
+
+    <wsdl:portType name="NotificationServicePort">
+       <wsdl:operation name="sendNotification">
+           <wsdl:input message="tns:notificationInput"/>
+           <wsdl:output message="tns:notificationOutput"/>
+       </wsdl:operation>
+    </wsdl:portType>
+
+    <wsdl:binding name="NotificationServicePort" 
type="tns:NotificationServicePort">
+       <soap:binding transport="http://schemas.xmlsoap.org/soap/http"; 
style="document"/>
+       <wsdl:operation name="sendNotification">
+           <soap:operation 
soapAction="urn://testnotification/sendNotification" style="document"/>
+           <wsdl:input>
+               <soap:body use="literal"/>
+               <soap:header message="tns:sendNotificationAuthCredentials" 
part="AuthCredentials" use="literal"/>
+           </wsdl:input>
+           <wsdl:output>
+               <soap:body use="literal"/>
+           </wsdl:output>
+       </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="NotificationService">
+       <wsdl:port name="NotificationServicePort" 
binding="tns:NotificationServicePort">
+           <soap:address location="http://localhost:9018/notification"/>
+       </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file


Reply via email to