summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-03-31 12:22:14 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-03-31 12:22:14 +0000
commit5e0bdd14667eeb43e281feab56f2c16b474388a0 (patch)
tree5315f0ca5d4fc338215cb424b28c10e9dfb33ba8 /sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache
parentdb33feaa382fbde736c39ac8270be3e9a506c3a1 (diff)
Start getting JAX-WS WS binding working with application exceptions
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@929499 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache')
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java23
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSServiceBindingProvider.java23
2 files changed, 29 insertions, 17 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java
index fd53de6a2c..fcf4f472ff 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java
@@ -44,10 +44,10 @@ import javax.xml.ws.soap.SOAPFaultException;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
-import org.w3c.dom.Document;
import org.w3c.dom.Node;
/**
@@ -120,7 +120,7 @@ public class JAXWSBindingInvoker implements Invoker, DataExchangeSemantics {
if (body != null) {
SOAPFault fault = body.getFault();
if (fault != null) {
- setFault(msg, fault);
+// setFault(msg, fault);
} else {
// The 1st child element
msg.setBody(body.getChildElements().next());
@@ -128,8 +128,7 @@ public class JAXWSBindingInvoker implements Invoker, DataExchangeSemantics {
}
} catch (SOAPFaultException e) {
- e.printStackTrace();
- setFault(msg, e.getFault());
+ setFault(msg, e);
} catch (WebServiceException e) {
msg.setFaultBody(e);
} catch (SOAPException e) {
@@ -141,14 +140,16 @@ public class JAXWSBindingInvoker implements Invoker, DataExchangeSemantics {
return msg;
}
- private void setFault(Message msg, SOAPFault fault) {
+ private void setFault(Message msg, SOAPFaultException e) {
+ SOAPFault fault = e.getFault();
Detail detail = fault.getDetail();
- if (detail == null) {
- return;
- }
- for (Iterator i = detail.getDetailEntries(); i.hasNext();) {
- DetailEntry entry = (DetailEntry)i.next();
- msg.setFaultBody(entry);
+ if (detail != null) {
+ for (Iterator i = detail.getDetailEntries(); i.hasNext();) {
+ DetailEntry entry = (DetailEntry)i.next();
+ FaultException fe = new FaultException(e.getMessage(), entry.getFirstChild(), e);
+ fe.setFaultName(entry.getElementQName());
+ msg.setFaultBody(fe);
+ }
}
}
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSServiceBindingProvider.java
index 3055f1a14a..048a9820cc 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSServiceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSServiceBindingProvider.java
@@ -18,8 +18,13 @@
*/
package org.apache.tuscany.sca.binding.ws.jaxws;
+import javax.xml.namespace.QName;
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Provider;
@@ -33,6 +38,7 @@ import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
@@ -57,10 +63,6 @@ public class JAXWSServiceBindingProvider implements ServiceBindingProvider, Prov
FactoryExtensionPoint modelFactories,
DataBindingExtensionPoint dataBindings) {
- if (servletHost == null) {
- throw new ServiceRuntimeException("No Servlet host is avaible for HTTP web services");
- }
-
this.messageFactory = modelFactories.getFactory(MessageFactory.class);
this.soapMessageFactory = modelFactories.getFactory(javax.xml.soap.MessageFactory.class);
@@ -141,9 +143,18 @@ public class JAXWSServiceBindingProvider implements ServiceBindingProvider, Prov
requestMsg.setBody(body);
requestMsg.setOperation(operation);
Message responseMsg = endpoint.invoke(operation, requestMsg);
- Element element = responseMsg.getBody();
SOAPMessage response = soapMessageFactory.createMessage();
- response.getSOAPBody().addChildElement(soapFactory.createElement(element));
+ if (responseMsg.isFault()) {
+ FaultException fe = responseMsg.getBody();
+ SOAPFault fault = response.getSOAPBody().addFault(new QName(response.getSOAPBody().getNamespaceURI(), "Server"), "unknown");
+ Detail d = fault.addDetail();
+ DetailEntry de = d.addDetailEntry(fe.getFaultName());
+ SOAPElement dece = de.addChildElement("message");
+ dece.addTextNode(fe.getMessage());
+ } else {
+ Element element = responseMsg.getBody();
+ response.getSOAPBody().addChildElement(soapFactory.createElement(element));
+ }
return response;
} catch (SOAPException e) {
throw new ServiceRuntimeException(e);