cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r773146 - in /cxf/trunk/rt/bindings/soap/src: main/java/org/apache/cxf/binding/soap/ main/java/org/apache/cxf/binding/soap/interceptor/ test/java/org/apache/cxf/binding/soap/ test/resources/org/apache/cxf/binding/soap/
Date Sat, 09 May 2009 01:01:44 GMT
Author: dkulp
Date: Sat May  9 01:01:43 2009
New Revision: 773146

URL: http://svn.apache.org/viewvc?rev=773146&view=rev
Log:
[CXF-2213] Use 1/0 for mustUnderstand for soap11 and true/false for soap12
Patch from Marat Bedretdinov applied

Added:
    cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.wsdl
  (with props)
    cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.xml
  (with props)
Modified:
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap11.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap12.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapVersion.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
    cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
    cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapOutInterceptorTest.java
    cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap11.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap11.java?rev=773146&r1=773145&r2=773146&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap11.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap11.java Sat May
 9 01:01:43 2009
@@ -134,6 +134,10 @@
         return "mustUnderstand";
     }
 
+    public String getAttrValueMustUnderstand(boolean value) {
+        return value ? "1" : "0";
+    }
+    
     public QName getReceiver() {
         return new QName(SOAP_NAMESPACE, "Server");
     }

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap12.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap12.java?rev=773146&r1=773145&r2=773146&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap12.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/Soap12.java Sat May
 9 01:01:43 2009
@@ -117,6 +117,10 @@
         return "mustUnderstand";
     }
 
+    public String getAttrValueMustUnderstand(boolean value) {
+        return value ? "true" : "false";
+    }
+
     public QName getReceiver() {
         return new QName(SOAP_NAMESPACE, "Receiver");
     }

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapVersion.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapVersion.java?rev=773146&r1=773145&r2=773146&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapVersion.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapVersion.java
Sat May  9 01:01:43 2009
@@ -52,6 +52,8 @@
 
     String getAttrNameMustUnderstand();
     
+    String getAttrValueMustUnderstand(boolean value);
+    
     // Role related properties
     //-------------------------------------------------------------------------
     String getAttrNameRole();

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java?rev=773146&r1=773145&r2=773146&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
Sat May  9 01:01:43 2009
@@ -321,11 +321,13 @@
                                    soapVersion.getAttrNameRole(),
                                    soapHeader.getActor());
                 }
-                if (soapHeader.isMustUnderstand()) {
+                boolean mu = soapHeader.isMustUnderstand();
+                if (mu) {
+                    String mul = soapVersion.getAttrValueMustUnderstand(mu); 
                     super.writeAttribute(soapPrefix,
                                    soapVersion.getNamespace(),
                                    soapVersion.getAttrNameMustUnderstand(),
-                                   "true");                                        
+                                   mul);                                        
                 }
             }
         }

Modified: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java?rev=773146&r1=773145&r2=773146&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
Sat May  9 01:01:43 2009
@@ -72,7 +72,7 @@
 
     @Test
     public void testHandleMessageSucc() throws Exception {
-        prepareSoapMessage();
+        prepareSoapMessage("test-soap-header.xml");
         dsi.getUnderstoodHeaders().add(RESERVATION);
         dsi.getUnderstoodHeaders().add(PASSENGER);
 
@@ -84,7 +84,7 @@
 
     @Test
     public void testHandleMessageFail() throws Exception {
-        prepareSoapMessage();
+        prepareSoapMessage("test-soap-header.xml");
 
         dsi.getUnderstoodHeaders().add(RESERVATION);
 
@@ -104,9 +104,10 @@
     }
 
     @Test
-    public void testHandleMessageWithHeaderParam() throws Exception {
-        prepareSoapMessage();
+    public void testHandleMessageWithSoapHeader11Param() throws Exception {
+        prepareSoapMessage("test-soap-header.xml");
         dsi.getUnderstoodHeaders().add(RESERVATION);
+        
         ServiceInfo serviceInfo = getMockedServiceModel(getClass().getResource("test-soap-header.wsdl")
             .toString());
 
@@ -122,11 +123,30 @@
             .isCalledGetUnderstood());
     }
 
-    private void prepareSoapMessage() throws Exception {
+    @Test
+    public void testHandleMessageWithSoapHeader12Param() throws Exception {
+        prepareSoapMessage("test-soap-12-header.xml");
+        dsi.getUnderstoodHeaders().add(RESERVATION);
+        ServiceInfo serviceInfo = getMockedServiceModel(getClass().getResource("test-soap-12-header.wsdl")
+            .toString());
+
+        BindingInfo binding = serviceInfo.getBinding(new QName("http://org.apache.cxf/headers",
+                                                               "headerTesterSOAPBinding"));
+        BindingOperationInfo bop = binding.getOperation(new QName("http://org.apache.cxf/headers",
+                                                                  "inHeader"));
+        soapMessage.getExchange().put(BindingOperationInfo.class, bop);
+
+        soapMessage.getInterceptorChain().doIntercept(soapMessage);
+        assertEquals("DummaySoapInterceptor getRoles has been called!", true, dsi.isCalledGetRoles());
+        assertEquals("DummaySoapInterceptor getUnderstood has been called!", true, dsi
+            .isCalledGetUnderstood());
+    }
+    
+    private void prepareSoapMessage(String payloadFileName) throws Exception {
 
         soapMessage = TestUtil.createEmptySoapMessage(Soap12.getInstance(), chain);
         ByteArrayDataSource bads = new ByteArrayDataSource(this.getClass()
-            .getResourceAsStream("test-soap-header.xml"), "Application/xop+xml");
+            .getResourceAsStream(payloadFileName), "Application/xop+xml");
         String cid = AttachmentUtil.createContentID("http://cxf.apache.org");
         soapMessage.setContent(Attachment.class, new AttachmentImpl(cid, new DataHandler(bads)));
         soapMessage.setContent(XMLStreamReader.class, XMLInputFactory.newInstance()

Modified: cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapOutInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapOutInterceptorTest.java?rev=773146&r1=773145&r2=773146&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapOutInterceptorTest.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapOutInterceptorTest.java
Sat May  9 01:01:43 2009
@@ -55,7 +55,7 @@
 
     @Test
     public void testHandleMessage() throws Exception {
-        prepareSoapMessage();
+        prepareSoapMessage("test-soap-header.xml");
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         soapMessage.setContent(OutputStream.class, out);
@@ -72,18 +72,43 @@
 
         InputStream bis = new ByteArrayInputStream(out.toByteArray());
         XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(bis);
-        assertInputStream(xmlReader);
+        assertInputStream(xmlReader, Soap11.getInstance());
     }
 
-    private void assertInputStream(XMLStreamReader xmlReader) throws Exception {
+    @Test
+    public void testHandleMessage12() throws Exception {
+        prepareSoapMessage("test-soap-12-header.xml");
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        soapMessage.setContent(OutputStream.class, out);
+        soapMessage.setContent(XMLStreamWriter.class, StaxUtils.createXMLStreamWriter(out));
+        
+        soapMessage.getInterceptorChain().doIntercept(soapMessage);
+        
+        assertNotNull(soapMessage.getHeaders());
+
+        Exception oe = (Exception)soapMessage.getContent(Exception.class);
+        if (oe != null) {
+            throw oe;
+        }
+
+        InputStream bis = new ByteArrayInputStream(out.toByteArray());
+        XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(bis);
+        assertInputStream(xmlReader, Soap12.getInstance());
+    }
+
+    private void assertInputStream(XMLStreamReader xmlReader, SoapVersion version) throws
Exception {
         assertEquals(XMLStreamReader.START_ELEMENT, xmlReader.nextTag());
-        assertEquals(Soap12.getInstance().getEnvelope(), xmlReader.getName());
+        assertEquals(version.getEnvelope(), xmlReader.getName());
 
         assertEquals(XMLStreamReader.START_ELEMENT, xmlReader.nextTag());
-        assertEquals(Soap12.getInstance().getHeader(), xmlReader.getName());
+        assertEquals(version.getHeader(), xmlReader.getName());
 
         assertEquals(XMLStreamReader.START_ELEMENT, xmlReader.nextTag());
         assertEquals("reservation", xmlReader.getLocalName());
+        assertEquals(version.getAttrValueMustUnderstand(true), 
+                     xmlReader.getAttributeValue(version.getNamespace(), 
+                                                 version.getAttrNameMustUnderstand()));
 
         assertEquals(XMLStreamReader.START_ELEMENT, xmlReader.nextTag());
         assertEquals("reference", xmlReader.getLocalName());
@@ -93,10 +118,11 @@
         // assertEquals(Soap12.getInstance().getBody(), xmlReader.getName());
     }
 
-    private void prepareSoapMessage() throws IOException {
+    
+    private void prepareSoapMessage(String payloadFileName) throws IOException {
         soapMessage = TestUtil.createEmptySoapMessage(Soap12.getInstance(), chain);
 
-        soapMessage.setContent(InputStream.class, getClass().getResourceAsStream("test-soap-header.xml"));
+        soapMessage.setContent(InputStream.class, getClass().getResourceAsStream(payloadFileName));
     }
 
 }

Added: cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.wsdl?rev=773146&view=auto
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.wsdl
(added)
+++ cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.wsdl
Sat May  9 01:01:43 2009
@@ -0,0 +1,94 @@
+<?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.
+-->
+<definitions name="soap_header" targetNamespace="http://org.apache.cxf/headers"
+	     xmlns:m="http://travelcompany.example.org/reservation"
+	     xmlns:n="http://mycompany.example.com/employees"
+	     xmlns="http://schemas.xmlsoap.org/wsdl/" 
+	     xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
+	     xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+	     xmlns:tns="http://org.apache.cxf/headers"
+	     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+	     xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+	<types>
+		<schema targetNamespace="http://org.apache.cxf/headers"
+			xmlns="http://www.w3.org/2001/XMLSchema"
+			xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+			<element name="inHeader">
+				<complexType>
+					<sequence>
+						<element name="" type="xsd:string"/>
+					</sequence>
+				</complexType>
+			</element>
+			<element name="inHeaderResponse">
+			 <complexType/>
+			</element>
+		</schema>
+		
+		<schema targetNamespace="http://mycompany.example.com/employees"
+			xmlns="http://www.w3.org/2001/XMLSchema"
+			xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">			
+			<element name="passenger">
+				<complexType>
+					<sequence>
+						<element name="name" type="xsd:string"/>
+					</sequence>
+				</complexType>
+			</element>
+		</schema>
+		
+	</types>
+
+    <message name="inHeaderRequest">
+	<part element="tns:inHeader" name="me"/>
+	<part element="n:passenger" name="passenger"/>
+    </message>
+    <message name="inHeaderResponse">
+	<part element="tns:inHeaderResponse" name="the_response"/>
+    </message>
+
+    <portType name="headerTester">
+	<operation name="inHeader">
+	    <input message="tns:inHeaderRequest" name="inHeaderRequest"/>
+	    <output message="tns:inHeaderResponse" name="inHeaderResponse"/>
+	</operation>
+    </portType>
+
+    <binding name="headerTesterSOAPBinding" type="tns:headerTester">
+    <soap12:binding style="document" transport="http://www.w3.org/2003/05/soap/bindings/HTTP/"/>
+    <operation name="inHeader">
+        <soap12:operation soapAction="" style="document"/>
+          <input name="inHeaderRequest">
+            <soap12:body parts="me" use="literal"/>
+            <soap12:header message="tns:inHeaderRequest" part="passenger" 
+                           use="literal"/>
+          </input>
+          <output name="inHeaderResponse">
+              <soap12:body use="literal"/>
+          </output>
+    </operation>
+    </binding>
+
+    <service name="HeaderService">
+      <port binding="tns:headerTesterSOAPBinding" name="SoapPort">
+        <soap12:address location="http://org.apache.cxf/headers/"/>
+      </port>
+    </service>
+</definitions>

Propchange: cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.xml?rev=773146&view=auto
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.xml
(added)
+++ cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.xml
Sat May  9 01:01:43 2009
@@ -0,0 +1,56 @@
+<!--
+    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.
+-->
+<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
+    <!-- before header test for processing comment here -->
+    <env:Header>
+        <!-- header test for processing comment here -->
+        <m:reservation xmlns:m="http://travelcompany.example.org/reservation"
+            env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true">
+            <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference>
+            <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime>
+        </m:reservation>
+        <n:passenger xmlns:n="http://mycompany.example.com/employees"
+            env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true">
+            <n:name>Bob</n:name>
+        </n:passenger>
+    </env:Header>
+    <!-- before body test for processing comment here -->
+    <env:Body>
+        <!-- boyd test for processing comment here -->
+        <p:itinerary xmlns:p="http://travelcompany.example.org/reservation/travel">
+            <p:departure>
+                <p:departing>New York</p:departing>
+                <p:arriving>Los Angeles</p:arriving>
+                <p:departureDate>2001-12-14</p:departureDate>
+                <p:departureTime>late afternoon</p:departureTime>
+                <p:seatPreference>aisle</p:seatPreference>
+            </p:departure>
+            <p:return>
+                <p:departing>Los Angeles</p:departing>
+                <p:arriving>New York</p:arriving>
+                <p:departureDate>2001-12-20</p:departureDate>
+                <p:departureTime>mid-morning</p:departureTime>
+                <p:seatPreference />
+            </p:return>
+        </p:itinerary>
+        <q:lodging xmlns:q="http://travelcompany.example.org/reservation/hotels">
+            <q:preference>none</q:preference>
+        </q:lodging>
+    </env:Body>
+</env:Envelope>
\ No newline at end of file

Propchange: cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-12-header.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml?rev=773146&r1=773145&r2=773146&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml
(original)
+++ cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml
Sat May  9 01:01:43 2009
@@ -16,17 +16,17 @@
     specific language governing permissions and limitations
     under the License.
 -->
-<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
+<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
     <!-- before header test for processing comment here -->
     <env:Header>
         <!-- header test for processing comment here -->
         <m:reservation xmlns:m="http://travelcompany.example.org/reservation"
-            env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true">
+            env:actor="http://schemas.xmlsoap.org/soap/actor/next" env:mustUnderstand="1">
             <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference>
             <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime>
         </m:reservation>
         <n:passenger xmlns:n="http://mycompany.example.com/employees"
-            env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true">
+            env:actor="http://schemas.xmlsoap.org/soap/actor/next" env:mustUnderstand="1">
             <n:name>Bob</n:name>
         </n:passenger>
     </env:Header>



Mime
View raw message