Author: dkulp
Date: Mon Mar 3 11:53:27 2008
New Revision: 633250
URL: http://svn.apache.org/viewvc?rev=633250&view=rev
Log:
Merged revisions 632453 via svnmerge from
https://svn.apache.org/repos/asf/incubator/cxf/trunk
........
r632453 | dkulp | 2008-02-29 16:52:49 -0500 (Fri, 29 Feb 2008) | 2 lines
Fix an issue with exceptions thrown from Providers not being put in a
soap:env/soap:body
........
Modified:
incubator/cxf/branches/2.0.x-fixes/ (props changed)
incubator/cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadProvider.java
incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java
Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
incubator/cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=633250&r1=633249&r2=633250&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Mon Mar 3 11:53:27 2008
@@ -333,6 +333,7 @@
}
sb.getOutFaultInterceptors().add(new StaxOutInterceptor());
+ sb.getOutFaultInterceptors().add(new SoapOutInterceptor(getBus()));
//Do not add any interceptors if it is Provider/Dispatch
if (!Boolean.TRUE.equals(binding.getProperty(DATABINDING_DISABLED))) {
Modified:
incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadProvider.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadProvider.java?rev=633250&r1=633249&r2=633250&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadProvider.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWDOMSourcePayloadProvider.java
Mon Mar 3 11:53:27 2008
@@ -21,14 +21,25 @@
import java.io.InputStream;
import javax.xml.namespace.QName;
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.Provider;
import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.soap.SOAPFaultException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.apache.cxf.helpers.DOMUtils;
+
+
//The following wsdl file is used.
//wsdlLocation =
"/trunk/testutils/src/main/resources/wsdl/hello_world_rpc_lit.wsdl"
@WebServiceProvider(portName = "SoapPortProviderRPCLit3", serviceName =
"SOAPServiceProviderRPCLit",
@@ -38,18 +49,18 @@
private static QName sayHi = new
QName("http://apache.org/hello_world_rpclit", "sayHi");
private static QName greetMe = new
QName("http://apache.org/hello_world_rpclit", "greetMe");
- private SOAPMessage sayHiResponse;
- private SOAPMessage greetMeResponse;
+ private Document sayHiResponse;
+ private Document greetMeResponse;
private MessageFactory factory;
public HWDOMSourcePayloadProvider() {
try {
factory = MessageFactory.newInstance();
InputStream is =
getClass().getResourceAsStream("resources/sayHiRpcLiteralResp.xml");
- sayHiResponse = factory.createMessage(null, is);
+ sayHiResponse = factory.createMessage(null,
is).getSOAPBody().extractContentAsDocument();
is.close();
is =
getClass().getResourceAsStream("resources/GreetMeRpcLiteralResp.xml");
- greetMeResponse = factory.createMessage(null, is);
+ greetMeResponse = factory.createMessage(null,
is).getSOAPBody().extractContentAsDocument();
is.close();
} catch (Exception ex) {
ex.printStackTrace();
@@ -58,19 +69,38 @@
public DOMSource invoke(DOMSource request) {
DOMSource response = new DOMSource();
- try {
-/* SOAPMessage msg = factory.createMessage();
- SOAPBody body = msg.getSOAPBody();
- body.addDocument((Document)request.getNode());*/
-
- Node n = request.getNode();
- if (n.getLocalName().equals(sayHi.getLocalPart())) {
-
response.setNode(sayHiResponse.getSOAPBody().extractContentAsDocument());
- } else if (n.getLocalName().equals(greetMe.getLocalPart())) {
-
response.setNode(greetMeResponse.getSOAPBody().extractContentAsDocument());
+
+ Node n = request.getNode();
+ if (n.getLocalName().equals(sayHi.getLocalPart())) {
+ response.setNode(sayHiResponse);
+ } else if (n.getLocalName().equals(greetMe.getLocalPart())) {
+ Element el = DOMUtils.getFirstElement(n);
+ String s = DOMUtils.getContent(el);
+ if (s.trim().equals("throwFault")) {
+ try {
+ SOAPFactory f = SOAPFactory.newInstance();
+ SOAPFault soapFault = f.createFault();
+
+ soapFault.setFaultString("Test Fault String ****");
+
+ Detail detail = soapFault.addDetail();
+ detail = soapFault.getDetail();
+
+ QName qName = new QName("http://www.Hello.org/greeter",
"TestFault", "ns");
+ DetailEntry de = detail.addDetailEntry(qName);
+
+ qName = new QName("http://www.Hello.org/greeter",
"ErrorCode", "ns");
+ SOAPElement errorElement = de.addChildElement(qName);
+ errorElement.setTextContent("errorcode");
+
+ throw new SOAPFaultException(soapFault);
+ } catch (SOAPException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
- } catch (Exception ex) {
- ex.printStackTrace();
+
+ response.setNode(greetMeResponse);
}
return response;
}
Modified:
incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java?rev=633250&r1=633249&r2=633250&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java
Mon Mar 3 11:53:27 2008
@@ -29,6 +29,7 @@
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.soap.SOAPFaultException;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.hello_world_rpclit.GreeterRPCLit;
@@ -40,7 +41,7 @@
@BeforeClass
public static void startServers() throws Exception {
- assertTrue("server did not launch correctly",
launchServer(Server.class));
+ assertTrue("server did not launch correctly",
launchServer(Server.class, true));
}
@Test
@@ -67,7 +68,10 @@
assertEquals(2, response.countAttachments());
}
- private void doGreeterRPCLit(SOAPServiceRPCLit service, QName portName,
int count) throws Exception {
+ private void doGreeterRPCLit(SOAPServiceRPCLit service,
+ QName portName,
+ int count,
+ boolean doFault) throws Exception {
String response1 = new String("TestGreetMeResponse");
String response2 = new String("TestSayHiResponse");
try {
@@ -80,6 +84,15 @@
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
+
+ if (doFault) {
+ try {
+ greeter.greetMe("throwFault");
+ } catch (SOAPFaultException ex) {
+ assertNotNull(ex.getFault().getDetail());
+
assertTrue(ex.getFault().getDetail().getDetailEntries().hasNext());
+ }
+ }
}
} catch (UndeclaredThrowableException ex) {
throw (Exception)ex.getCause();
@@ -98,7 +111,7 @@
SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
assertNotNull(service);
- doGreeterRPCLit(service, portName, 2);
+ doGreeterRPCLit(service, portName, 2, false);
}
@Test
@@ -112,7 +125,7 @@
SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
assertNotNull(service);
- doGreeterRPCLit(service, portName, 2);
+ doGreeterRPCLit(service, portName, 2, false);
}
@Test
@@ -126,7 +139,7 @@
SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
assertNotNull(service);
- doGreeterRPCLit(service, portName, 1);
+ doGreeterRPCLit(service, portName, 1, true);
}
@Test
@@ -164,7 +177,7 @@
SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
assertNotNull(service);
- doGreeterRPCLit(service, portName, 1);
+ doGreeterRPCLit(service, portName, 1, false);
}
@Test
@@ -178,7 +191,7 @@
SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
assertNotNull(service);
- doGreeterRPCLit(service, portName, 1);
+ doGreeterRPCLit(service, portName, 1, false);
}
@Test
@@ -192,7 +205,7 @@
SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName);
assertNotNull(service);
- doGreeterRPCLit(service, portName, 1);
+ doGreeterRPCLit(service, portName, 1, false);
}
}