Author: veithen Date: Fri Aug 12 18:44:22 2011 New Revision: 1157211 URL: http://svn.apache.org/viewvc?rev=1157211&view=rev Log: AXIS2-5034: Implemented a fix for AXIS2-4533 that doesn't break the fault processing logic in ADB.
Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/faults.wsdl (with props) axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java (with props) Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=1157211&r1=1157210&r2=1157211&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original) +++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Fri Aug 12 18:44:22 2011 @@ -115,6 +115,15 @@ public class WSDL11ToAxisServiceBuilder public static final int COMPONENT_MESSAGE = 2; public static final int COMPONENT_BINDING = 3; + /** + * Parameter used on {@link AxisMessage} objects to track the value of the <tt>name</tt> + * attribute of the <tt>wsdl:fault</tt>. Note that this is more like a workaround. The problem + * is that {@link AxisMessage} stores the faults as a simple list. A better fix would be to + * replace that by a map with the fault name as key, similar to what WSDL4J does (see + * {@link Operation#getFaults()}). + */ + private static final String FAULT_NAME = "faultName"; + protected static final Log log = LogFactory .getLog(WSDL11ToAxisServiceBuilder.class); private static final boolean isTraceEnabled = log.isTraceEnabled(); @@ -1182,7 +1191,7 @@ public class WSDL11ToAxisServiceBuilder AxisMessage tempMessage; for (int i = 0; i < faultMessages.size(); i++) { tempMessage = (AxisMessage) faultMessages.get(i); - if (name.equals(tempMessage.getName())) { + if (name.equals(tempMessage.getParameterValue(FAULT_NAME))) { return tempMessage; } @@ -1550,10 +1559,11 @@ public class WSDL11ToAxisServiceBuilder Fault fault = (Fault) faults.get(faultKeyIterator.next()); AxisMessage axisFaultMessage = new AxisMessage(); addDocumentation(axisFaultMessage,fault.getDocumentationElement()); + axisFaultMessage.addParameter(FAULT_NAME, fault.getName()); Message faultMessage = fault.getMessage(); if (null != faultMessage) { axisFaultMessage - .setName(fault.getName()); + .setName(faultMessage.getQName().getLocalPart()); copyExtensibleElements(faultMessage.getExtensibilityElements(), dif, axisFaultMessage, PORT_TYPE_OPERATION_FAULT); Added: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/faults.wsdl URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/faults.wsdl?rev=1157211&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/faults.wsdl (added) +++ axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/faults.wsdl Fri Aug 12 18:44:22 2011 @@ -0,0 +1,91 @@ +<?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="TestWS" + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:tns="urn:test" + targetNamespace="urn:test"> + + <types> + <xs:schema targetNamespace="urn:test"> + <xs:element name="input"> + <xs:complexType> + <xs:sequence/> + </xs:complexType> + </xs:element> + <xs:element name="output"> + <xs:complexType> + <xs:sequence/> + </xs:complexType> + </xs:element> + <xs:element name="error"> + <xs:complexType> + <xs:sequence/> + </xs:complexType> + </xs:element> + </xs:schema> + </types> + + <message name="inputMessage"> + <part name="parameters" element="tns:input" /> + </message> + <message name="outputMessage"> + <part name="reponse" element="tns:output" /> + </message> + <message name="errorMessage"> + <part name="fault" element="tns:error" /> + </message> + + <portType name="TestPortType"> + <operation name="test"> + <input message="tns:inputMessage" /> + <output message="tns:outputMessage" /> + <fault message="tns:errorMessage" name="error1" /> + <fault message="tns:errorMessage" name="error2" /> + </operation> + </portType> + + <binding name="TestSOAP11Binding" type="tns:TestPortType"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> + <operation name="test"> + <soap:operation soapAction="urn:test" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + <fault name="error1"> + <soap:fault name="error1" use="literal"/> + </fault> + <fault name="error2"> + <soap:fault name="error2" use="literal" /> + </fault> + </operation> + </binding> + + <service name="TestService"> + <port name="TestSOAP11Port" binding="tns:TestSOAP11Binding"> + <soap:address location="http://localhost:8080/service" /> + </port> + </service> +</definitions> Propchange: axis/axis2/java/core/trunk/modules/kernel/test-resources/wsdl/faults.wsdl ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java?rev=1157211&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java (added) +++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java Fri Aug 12 18:44:22 2011 @@ -0,0 +1,57 @@ +/* + * 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.axis2.description; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.List; + +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +public class WSDL11ToAxisServiceBuilderTest extends TestCase { + /** + * Tests processing of an operation that declares multiple faults referring to the same message. + * In this case, {@link WSDL11ToAxisServiceBuilder} must correctly populate the + * {@link AxisMessage} object for both faults. In particular, + * {@link AxisMessage#getElementQName()} must return consistent information. This is a + * regression test for AXIS2-4533. + * + * @throws Exception + */ + public void testMultipleFaultsWithSameMessage() throws Exception { + InputStream in = new FileInputStream("test-resources/wsdl/faults.wsdl"); + try { + AxisService service = new WSDL11ToAxisServiceBuilder(in).populateService(); + AxisOperation operation = service.getOperation(new QName("urn:test", "test")); + assertNotNull(operation); + List<AxisMessage> faultMessages = operation.getFaultMessages(); + assertEquals(2, faultMessages.size()); + AxisMessage error1 = faultMessages.get(0); + AxisMessage error2 = faultMessages.get(1); + assertEquals("errorMessage", error1.getName()); + assertEquals("errorMessage", error2.getName()); + assertEquals(new QName("urn:test", "error"), error1.getElementQName()); + assertEquals(new QName("urn:test", "error"), error2.getElementQName()); + } finally { + in.close(); + } + } +} Propchange: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java ------------------------------------------------------------------------------ svn:eol-style = native