You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2007/10/23 10:16:25 UTC

svn commit: r587416 - in /incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc: ./ src/main/java/org/apache/servicemix/cxfbc/ src/test/java/org/apache/servicemix/cxfbc/fault/ src/test/resources/org/apache/servicemix/cxfbc/fault/

Author: ffang
Date: Tue Oct 23 01:16:24 2007
New Revision: 587416

URL: http://svn.apache.org/viewvc?rev=587416&view=rev
Log:
[SM-1113]SOAP faults don't work when elementFormDefault is unqualified


Added:
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/CxfBcFaultTest.java   (with props)
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/PersonImpl.java   (with props)
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/person.wsdl   (with props)
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/xbean.xml   (with props)
Modified:
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml?rev=587416&r1=587415&r2=587416&view=diff
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/pom.xml Tue Oct 23 01:16:24 2007
@@ -331,6 +331,12 @@
 	                                    <extraarg>-verbose</extraarg>
         	                        </extraargs>
                                     </wsdlOption>
+                                    <wsdlOption>
+                                        <wsdl>${basedir}/src/test/resources/org/apache/servicemix/cxfbc/fault/person.wsdl</wsdl>
+                                        <extraargs>
+                                            <extraarg>-verbose</extraarg>
+                                        </extraargs>
+                                    </wsdlOption>
 
                                 </wsdlOptions>
 

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java?rev=587416&r1=587415&r2=587416&view=diff
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java Tue Oct 23 01:16:24 2007
@@ -36,10 +36,13 @@
 
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
 import com.ibm.wsdl.Constants;
 import org.apache.cxf.Bus;
 import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.binding.AbstractBindingFactory;
+import org.apache.cxf.binding.jbi.JBIFault;
 import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
 import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapActionOutInterceptor;
@@ -452,11 +455,10 @@
             }
             if (!ex.isOneWay()) {
                 if (exchange.getFault() != null) {
-                    Fault f = new Fault(new org.apache.cxf.common.i18n.Message(
+                    Fault f = new JBIFault(new org.apache.cxf.common.i18n.Message(
                             "Fault occured", (ResourceBundle) null));
 
-                    Element details = toElement(exchange.getFault()
-                            .getContent());
+                    Element details = toElement(exchange.getFault().getContent());
                     f.setDetail(details);
                     processFaultDetail(f, message);
                     message.put(BindingFaultInfo.class, faultWanted);
@@ -518,10 +520,30 @@
 
     private static Element toElement(Source src) throws Fault {
         try {
-            return new SourceTransformer().toDOMElement(src);
+            SourceTransformer transformer = new SourceTransformer();
+            Element ret = transformer.toDOMElement(src);
+            ret = removeEmptyDefaultTns(ret);
+            return ret;
         } catch (Exception e) {
             throw new Fault(e);
         }
+    }
+
+    private static Element removeEmptyDefaultTns(Element ret) {
+        //to make unquailied fault work
+        if (ret.hasAttribute("xmlns") 
+                && ret.getAttribute("xmlns").length() == 0) {
+            ret.removeAttribute("xmlns");
+        }
+        NodeList nodes = ret.getChildNodes();
+        for (int i = 0; i < nodes.getLength(); i++) {
+            if (nodes.item(i) instanceof Element) {
+                Element ele = (Element)nodes.item(i);
+                ele = removeEmptyDefaultTns(ele);
+                
+            }
+        }
+        return ret;
     }
 
     public void setBusCfg(String busCfg) {

Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/CxfBcFaultTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/CxfBcFaultTest.java?rev=587416&view=auto
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/CxfBcFaultTest.java (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/CxfBcFaultTest.java Tue Oct 23 01:16:24 2007
@@ -0,0 +1,58 @@
+/*
+ * 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.servicemix.cxfbc.fault;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+
+import org.apache.servicemix.samples.wsdl_first.Person;
+import org.apache.servicemix.samples.wsdl_first.PersonService;
+import org.apache.servicemix.samples.wsdl_first.UnknownPersonFault;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class CxfBcFaultTest extends SpringTestSupport {
+
+    public void testFault() throws Exception {
+        QName serviceName = new QName("http://servicemix.apache.org/samples/wsdl-first", 
+                "PersonService");
+        URL wsdlUrl = CxfBcFaultTest.class.getClassLoader().getResource(
+                "org/apache/servicemix/cxfbc/fault/person.wsdl");
+        PersonService service = new PersonService(wsdlUrl, serviceName);
+        Person person = service.getSoap();
+        Holder<String> personId = new Holder<String>();
+        Holder<String> ssn = new Holder<String>();
+        Holder<String> name = new Holder<String>();
+        personId.value = "";
+        try {
+            person.getPerson(personId, ssn, name);
+            fail();
+        } catch (UnknownPersonFault e) {
+            //should catch this Fault
+        }
+    }
+    
+    @Override
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        return new ClassPathXmlApplicationContext(
+            "org/apache/servicemix/cxfbc/fault/xbean.xml");
+    }
+
+}

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/CxfBcFaultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/CxfBcFaultTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/PersonImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/PersonImpl.java?rev=587416&view=auto
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/PersonImpl.java (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/PersonImpl.java Tue Oct 23 01:16:24 2007
@@ -0,0 +1,44 @@
+/*
+ * 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.servicemix.cxfbc.fault;
+
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
+import org.apache.servicemix.samples.wsdl_first.Person;
+import org.apache.servicemix.samples.wsdl_first.UnknownPersonFault;
+
+
+
+@WebService(serviceName = "PersonService", 
+            targetNamespace = "http://servicemix.apache.org/samples/wsdl-first", 
+            endpointInterface = "org.apache.servicemix.samples.wsdl_first.Person")
+public class PersonImpl implements Person {
+
+    public void getPerson(Holder<String> personId, Holder<String> ssn, Holder<String> name)
+        throws UnknownPersonFault {
+        if (personId.value == null || personId.value.length() == 0) {
+            org.apache.servicemix.samples.wsdl_first.types.UnknownPersonFault fault = 
+                new org.apache.servicemix.samples.wsdl_first.types.UnknownPersonFault();
+            fault.setPersonId(personId.value);
+            throw new UnknownPersonFault(null, fault);
+        }
+        name.value = "Guillaume";
+        ssn.value = "000-000-0000";
+    }
+
+}

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/PersonImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/fault/PersonImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/person.wsdl
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/person.wsdl?rev=587416&view=auto
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/person.wsdl (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/person.wsdl Tue Oct 23 01:16:24 2007
@@ -0,0 +1,97 @@
+<?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.
+
+-->
+<!-- $Rev$ $Date$ -->
+<wsdl:definitions name="wsdl-first"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:tns="http://servicemix.apache.org/samples/wsdl-first"
+	xmlns:typens="http://servicemix.apache.org/samples/wsdl-first/types"
+	targetNamespace="http://servicemix.apache.org/samples/wsdl-first">
+
+	<wsdl:types>
+		<xsd:schema targetNamespace="http://servicemix.apache.org/samples/wsdl-first/types">
+			<xsd:element name="GetPerson">
+			  <xsd:complexType>
+					<xsd:sequence>
+						<xsd:element name="personId" type="xsd:string"/>
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+			<xsd:element name="GetPersonResponse">
+			  <xsd:complexType>
+					<xsd:sequence>
+					    <xsd:element name="personId" type="xsd:string"/>
+						<xsd:element name="ssn" type="xsd:string"/>
+						<xsd:element name="name" type="xsd:string"/>
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+			<xsd:element name="UnknownPersonFault">
+			  <xsd:complexType>
+					<xsd:sequence>
+					    <xsd:element name="personId" type="xsd:string"/>
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+		</xsd:schema>
+  </wsdl:types>
+	
+	<wsdl:message name="GetPersonRequest">
+		<wsdl:part name="payload" element="typens:GetPerson"/>
+	</wsdl:message>
+	<wsdl:message name="GetPersonResponse">
+		<wsdl:part name="payload" element="typens:GetPersonResponse"/>
+	</wsdl:message>
+	<wsdl:message name="UnknownPersonFault">
+		<wsdl:part name="payload" element="typens:UnknownPersonFault"/>
+	</wsdl:message>
+
+    <wsdl:portType name="Person">
+		<wsdl:operation name="GetPerson">
+			<wsdl:input message="tns:GetPersonRequest"/>
+			<wsdl:output message="tns:GetPersonResponse"/>
+			<wsdl:fault name="UnknownPerson" message="tns:UnknownPersonFault"/>
+		</wsdl:operation>
+	</wsdl:portType>
+	
+    <wsdl:binding name="PersonSOAPBinding" type="tns:Person">
+    	<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="GetPerson">
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+			<wsdl:fault name="UnknownPerson">
+				<soap:fault use="literal" name="UnknownPerson" />
+			</wsdl:fault>
+       </wsdl:operation>
+   </wsdl:binding>
+
+	<wsdl:service name="PersonService">
+    	<wsdl:port binding="tns:PersonSOAPBinding" name="soap">
+           <soap:address location="http://localhost:8192/PersonService/" />
+       </wsdl:port>
+   </wsdl:service>
+
+</wsdl:definitions>

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/person.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/person.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/person.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/xbean.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/xbean.xml?rev=587416&view=auto
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/xbean.xml (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/xbean.xml Tue Oct 23 01:16:24 2007
@@ -0,0 +1,64 @@
+<?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.
+  
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+       xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
+       xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
+       xmlns:person="http://servicemix.apache.org/samples/wsdl-first">
+  
+  <sm:container id="jbi" embedded="true">
+    
+    <sm:endpoints>
+      <cxfse:endpoint>
+        <cxfse:pojo>
+          <bean class="org.apache.servicemix.cxfbc.fault.PersonImpl" />
+        </cxfse:pojo>
+        <cxfse:inInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfse:inInterceptors>
+        <cxfse:outInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfse:outInterceptors>
+        <cxfse:inFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfse:inFaultInterceptors>
+        <cxfse:outFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfse:outFaultInterceptors>
+      </cxfse:endpoint>
+      <cxfbc:consumer wsdl="org/apache/servicemix/cxfbc/fault/person.wsdl"
+                      targetService="person:PersonService"
+                      targetInterface="person:Person">
+         <cxfbc:inInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfbc:inInterceptors>
+        <cxfbc:outInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfbc:outInterceptors>
+        <cxfbc:inFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfbc:inFaultInterceptors>
+        <cxfbc:outFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfbc:outFaultInterceptors>
+       </cxfbc:consumer>
+    </sm:endpoints>
+    
+  </sm:container>
+</beans>

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/xbean.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/xbean.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/fault/xbean.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml