You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by em...@apache.org on 2010/06/28 08:17:32 UTC
svn commit: r958470 - in /cxf/trunk:
rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/
systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/
syste...
Author: ema
Date: Mon Jun 28 06:17:32 2010
New Revision: 958470
URL: http://svn.apache.org/viewvc?rev=958470&view=rev
Log:
[CXF-2860]:Accepts the soap fault request message from another endpoint whose FaultTo address is this endpoint
Added:
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/LoggingHandler.java
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultImpl.java
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultRequestTestCase.java
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/Server.java
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/handlers.xml
cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/soap_fault.wsdl
Modified:
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/CheckFaultInterceptor.java
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/CheckFaultInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/CheckFaultInterceptor.java?rev=958470&r1=958469&r2=958470&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/CheckFaultInterceptor.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/CheckFaultInterceptor.java Mon Jun 28 06:17:32 2010
@@ -62,7 +62,7 @@ public class CheckFaultInterceptor exten
throw new SoapFault(new Message("XML_STREAM_EXC", LOG), e,
message.getVersion().getSender());
}
- if (message.getVersion().getFault().equals(xmlReader.getName())) {
+ if (message.getVersion().getFault().equals(xmlReader.getName()) && isRequestor(message)) {
Endpoint ep = message.getExchange().get(Endpoint.class);
message.getInterceptorChain().abort();
if (ep.getInFaultObserver() != null) {
Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java?rev=958470&r1=958469&r2=958470&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java Mon Jun 28 06:17:32 2010
@@ -277,7 +277,7 @@ public class SOAPHandlerInterceptor exte
}
}
}
- if (msg.getSOAPPart().getEnvelope().getBody() != null
+ if (isRequestor(message) && msg.getSOAPPart().getEnvelope().getBody() != null
&& msg.getSOAPPart().getEnvelope().getBody().hasFault()) {
return null;
}
Added: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/LoggingHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/LoggingHandler.java?rev=958470&view=auto
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/LoggingHandler.java (added)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/LoggingHandler.java Mon Jun 28 06:17:32 2010
@@ -0,0 +1,101 @@
+/**
+ * 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.soapfault;
+
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+/*
+ * This simple SOAPHandler will output the contents of incoming
+ * and outgoing messages.
+ */
+public class LoggingHandler implements SOAPHandler<SOAPMessageContext> {
+
+ private PrintStream out;
+
+ public LoggingHandler() {
+ setLogStream(System.out);
+ }
+
+ protected final void setLogStream(PrintStream ps) {
+ out = ps;
+ }
+
+ public void init(Map c) {
+ }
+
+ public Set<QName> getHeaders() {
+ return null;
+ }
+
+ public boolean handleMessage(SOAPMessageContext smc) {
+ //System.out.println("LoggingHandler : handleMessage Called....");
+ logToSystemOut(smc);
+ return true;
+ }
+
+ public boolean handleFault(SOAPMessageContext smc) {
+ //System.out.println("LoggingHandler : handleFault Called....");
+ logToSystemOut(smc);
+ return true;
+ }
+
+ // nothing to clean up
+ public void close(MessageContext messageContext) {
+ //System.out.println("LoggingHandler : close() Called....");
+ }
+
+ // nothing to clean up
+ public void destroy() {
+ //System.out.println("LoggingHandler : destroy() Called....");
+ }
+
+ /*
+ * Check the MESSAGE_OUTBOUND_PROPERTY in the context
+ * to see if this is an outgoing or incoming message.
+ * Write a brief message to the print stream and
+ * output the message. The writeTo() method can throw
+ * SOAPException or IOException
+ */
+ protected void logToSystemOut(SOAPMessageContext smc) {
+ Boolean outboundProperty = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
+ if (outboundProperty.booleanValue()) {
+ //out.println("\nOutbound message:");
+ } else {
+ //out.println("\nInbound message:");
+ }
+
+ SOAPMessage message = smc.getMessage();
+ try {
+ message.writeTo(out);
+ //out.println();
+ } catch (Exception e) {
+ //out.println("Exception in handler: " + e);
+ e.printStackTrace();
+ }
+ }
+}
Added: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultImpl.java?rev=958470&view=auto
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultImpl.java (added)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultImpl.java Mon Jun 28 06:17:32 2010
@@ -0,0 +1,38 @@
+/**
+ * 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.soapfault;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+import org.apache.cxf.soapfault.SoapFaultPortType;
+import org.xmlsoap.schemas.soap.envelope.Fault;
+
+@WebService(endpointInterface = "org.apache.cxf.soapfault.SoapFaultPortType",
+ serviceName = "SoapFaultService")
+@HandlerChain(file = "./handlers.xml", name = "TestHandlerChain")
+public class SOAPFaultImpl implements SoapFaultPortType {
+ public void soapFault(Fault fault) {
+ System.out.println("Received soap fault message");
+ System.out.println("FaultString: " + fault.getFaultstring());
+ System.out.println("FaulCode: " + fault.getFaultcode());
+ }
+
+}
Added: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultRequestTestCase.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultRequestTestCase.java?rev=958470&view=auto
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultRequestTestCase.java (added)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/SOAPFaultRequestTestCase.java Mon Jun 28 06:17:32 2010
@@ -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.cxf.systest.soapfault;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.soapfault.SoapFaultPortType;
+import org.apache.cxf.soapfault.SoapFaultService;
+import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.xmlsoap.schemas.soap.envelope.Fault;
+
+public class SOAPFaultRequestTestCase extends AbstractClientServerTestBase {
+ private static final String PORT = Server.PORT;
+ private final QName portName = new QName("http://cxf.apache.org/soapfault", "SoapFaultPortType");
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly", launchServer(Server.class));
+ }
+
+ @Test
+ public void testSendSoapFaultRequest() throws Exception {
+
+ SoapFaultService service = new SoapFaultService();
+ assertNotNull(service);
+
+ SoapFaultPortType soapFaultPort = service.getPort(portName, SoapFaultPortType.class);
+ updateAddressPort(soapFaultPort, PORT);
+
+ Fault fault = new Fault();
+ fault.setFaultstring("ClientSetFaultString");
+ fault.setFaultcode(new QName("http://cxf.apache.org/soapfault", "ClientSetError"));
+ soapFaultPort.soapFault(fault);
+
+ }
+
+}
Added: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/Server.java?rev=958470&view=auto
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/Server.java (added)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/Server.java Mon Jun 28 06:17:32 2010
@@ -0,0 +1,48 @@
+/**
+ * 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.soapfault;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+
+public class Server extends AbstractBusTestServerBase {
+ public static final String PORT = allocatePort(Server.class);
+
+ protected void run() {
+ String address = "http://localhost:" + PORT + "/SoapFault";
+
+ Object implementor1 = new SOAPFaultImpl();
+ Endpoint.publish(address, implementor1);
+ }
+
+ 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: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/handlers.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/handlers.xml?rev=958470&view=auto
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/handlers.xml (added)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soapfault/handlers.xml Mon Jun 28 06:17:32 2010
@@ -0,0 +1,35 @@
+<?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.
+-->
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
+xmlns:cfg="http://cxf.apache.org/configuration/cfg"
+xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://java.sun.com/xml/ns/javaee">
+ <handler-chain>
+ <handler>
+ <handler-name>ph1</handler-name>
+ <handler-class>org.apache.cxf.systest.soapfault.LoggingHandler</handler-class>
+ <init-param>
+ <param-name>token</param-name>
+ <param-value>String</param-value>
+ </init-param>
+ </handler>
+ </handler-chain>
+</handler-chains>
Added: cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/soap_fault.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/soap_fault.wsdl?rev=958470&view=auto
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/soap_fault.wsdl (added)
+++ cxf/trunk/systests/uncategorized/src/test/resources/wsdl_systest/soap_fault.wsdl Mon Jun 28 06:17:32 2010
@@ -0,0 +1,63 @@
+<?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
+ xmlns:s="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://cxf.apache.org/soapfault"
+ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsaw="http://www.w3.org/2006/02/addressing/wsdl"
+ targetNamespace="http://cxf.apache.org/soapfault"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <s:schema>
+ <s:import namespace="http://schemas.xmlsoap.org/soap/envelope/"
+ schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"/>
+ </s:schema>
+ </types>
+ <message name="SoapFault">
+ <part name="fault" element="soapenv:Fault" />
+ </message>
+
+
+
+ <portType name="SoapFaultPortType">
+ <operation name="SoapFault">
+ <input name="SoapFault" message="tns:SoapFault" />
+ </operation>
+ </portType>
+
+
+
+ <binding name="SoapFault_SOAPBinding" type="tns:SoapFaultPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="SoapFault">
+ <input message="tns:Soapfault">
+ <soap:body use="literal"/>
+ </input>
+ </operation>
+ </binding>
+
+ <service name="SoapFaultService">
+ <port binding="tns:SoapFault_SOAPBinding" name="SoapFaultPortType">
+ <wsaw:UsingAddressing required="true"/>
+ <soap:address location="http://localhost:9099/SoapFault"/>
+ </port>
+ </service>
+</definitions>