Author: objectiser
Date: 2010-11-16 19:07:15 -0500 (Tue, 16 Nov 2010)
New Revision: 1113
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/SOAPMessageAdapter.java
Log:
Removed dependency on another ODE class.
Modified: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/SOAPMessageAdapter.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/SOAPMessageAdapter.java 2010-11-16
23:45:23 UTC (rev 1112)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/SOAPMessageAdapter.java 2010-11-17
00:07:15 UTC (rev 1113)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.utils.wsdl.WsdlUtils;
import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl;
import org.jboss.soa.si.MessageAdapter;
import org.w3c.dom.Document;
@@ -35,6 +34,8 @@
import javax.wsdl.*;
import javax.wsdl.extensions.ElementExtensible;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.http.HTTPBinding;
import javax.wsdl.extensions.soap.SOAPBinding;
import javax.wsdl.extensions.soap.SOAPHeader;
import javax.xml.namespace.QName;
@@ -89,10 +90,10 @@
if (binding == null)
throw new RuntimeException("No binding for port "+portName);
- if (!WsdlUtils.useSOAPBinding(port)) {
+ if (!useSOAPBinding(port)) {
throw new RuntimeException("No SOAP binding for port"+portName);
}
- soapBinding = (SOAPBinding) WsdlUtils.getBindingExtension(port);
+ soapBinding = (SOAPBinding)getBindingExtension(port);
String style = soapBinding.getStyle();
@@ -642,7 +643,7 @@
}
QName elName=new QName(element.getNamespaceURI(), element.getLocalName());
- return WsdlUtils.inferFault(operation, elName);
+ return inferFault(operation, elName);
}
@@ -782,4 +783,50 @@
public static <C extends Collection<T>, S, T extends S> C filter(C dest,
Collection<S> src, Class<T> t) {
return filter(dest, src.iterator(), t);
}
+
+ @SuppressWarnings("unchecked")
+ public static Fault inferFault(Operation operation, QName elName) {
+ for (Fault f : (Collection<Fault>) operation.getFaults().values()) {
+ if (f.getMessage() == null) continue;
+ Collection<Part> parts = f.getMessage().getParts().values();
+ if (parts.isEmpty()) continue;
+ Part p = parts.iterator().next();
+ if (p.getElementName() == null) continue;
+ if (p.getElementName().equals(elName)) return f;
+ }
+ return null;
+ }
+
+ public static ExtensibilityElement getBindingExtension(Binding binding) {
+ Collection bindings = new ArrayList();
+ filter(bindings, binding.getExtensibilityElements(), HTTPBinding.class);
+ filter(bindings, binding.getExtensibilityElements(), SOAPBinding.class);
+ if (bindings.size() == 0) {
+ return null;
+ } else if (bindings.size() > 1) {
+ // exception if multiple bindings found
+ throw new IllegalArgumentException("Binding
"+binding.getQName()+" has multiple binding elements");
+ } else {
+ // retrieve the single element
+ ExtensibilityElement result = (ExtensibilityElement)
bindings.iterator().next();
+ return result;
+ }
+ }
+
+ public static ExtensibilityElement getBindingExtension(Port port) {
+ Binding binding = port.getBinding();
+ if (binding == null) {
+ throw new IllegalArgumentException("Binding not found: port
"+port.getName()+".");
+ }
+ return getBindingExtension(binding);
+ }
+
+ public static boolean useSOAPBinding(Binding binding) {
+ ExtensibilityElement element = getBindingExtension(binding);
+ return SOAPBinding.class.isAssignableFrom(element.getClass());
+ }
+
+ public static boolean useSOAPBinding(Port port) {
+ return useSOAPBinding(port.getBinding());
+ }
}
Show replies by date