Author: midon
Date: Thu Jun 26 19:28:43 2008
New Revision: 672087

URL: http://svn.apache.org/viewvc?rev=672087&view=rev
Log:
ODE-310: First implementation of fault for HTTP binding

Added:
    
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
      - copied, changed from r672086, 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpClientHelper.java
    
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpMethodConverterTest.java
      - copied, changed from r672086, 
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpClientHelperTest.java
Removed:
    
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpClientHelperTest.java
Modified:
    
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
    
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpClientHelper.java
    
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
    
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
    
ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/wsdl/WsdlUtils.java

Modified: 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java?rev=672087&r1=672086&r2=672087&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
 Thu Jun 26 19:28:43 2008
@@ -341,14 +341,7 @@
                             if (faultType != null) {
                                 if (__log.isWarnEnabled())
                                     __log.warn("Fault response: faultType=" + 
faultType + "\n" + DOMUtils.domToString(odeMsgEl));
-                                QName nonNullFT = new 
QName(Namespaces.ODE_EXTENSION_NS, "unknownFault");
-                                Fault f = 
odeMex.getOperation().getFault(faultType.getLocalPart());
-                                if (f != null && f.getMessage().getQName() != 
null)
-                                    nonNullFT = f.getMessage().getQName();
-                                else
-                                    __log.debug("Fault " + faultType + " isn't 
referenced in the service definition, unknown fault.");
-
-                                Message response = 
odeMex.createMessage(nonNullFT);
+                                Message response = 
odeMex.createMessage(faultType);
                                 response.setMessage(odeMsgEl);
 
                                 odeMex.replyWithFault(faultType, response);

Modified: 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpClientHelper.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpClientHelper.java?rev=672087&r1=672086&r2=672087&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpClientHelper.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpClientHelper.java
 Thu Jun 26 19:28:43 2008
@@ -25,6 +25,8 @@
 import org.apache.commons.httpclient.HttpState;
 import org.apache.commons.httpclient.URI;
 import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.StatusLine;
+import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
 import org.apache.commons.httpclient.methods.DeleteMethod;
 import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
@@ -37,6 +39,7 @@
 import org.apache.commons.httpclient.params.HostParams;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.commons.lang.StringUtils;
 import org.apache.ode.axis2.Properties;
 import org.apache.ode.axis2.util.URLEncodedTransformer;
 import org.apache.ode.axis2.util.UrlReplacementTransformer;
@@ -47,6 +50,7 @@
 import org.apache.ode.utils.wsdl.WsdlUtils;
 import org.apache.axis2.transport.http.HttpTransportProperties;
 import org.w3c.dom.Element;
+import org.w3c.dom.Document;
 
 import javax.wsdl.Binding;
 import javax.wsdl.BindingInput;
@@ -58,6 +62,8 @@
 import javax.wsdl.extensions.mime.MIMEContent;
 import javax.xml.namespace.QName;
 import java.io.UnsupportedEncodingException;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -66,16 +72,8 @@
 
 public class HttpClientHelper {
 
-    private static final String CONTENT_TYPE_TEXT_XML = "text/xml";
     private static final Log log = LogFactory.getLog(HttpClientHelper.class);
 
-    protected static final org.apache.ode.utils.wsdl.Messages msgs = 
Messages.getMessages(Messages.class);
-    protected Binding binding;
-
-    public HttpClientHelper(Binding binding) {
-        this.binding = binding;
-    }
-
     public void configure(HostConfiguration hostConfig, HttpState state, URI 
targetURI, HttpParams params) throws URIException {
         if (log.isDebugEnabled()) log.debug("Configuring http client...");
         // proxy configuration
@@ -89,143 +87,101 @@
 
     }
 
-    public HttpMethod buildHttpMethod(PartnerRoleMessageExchange odeMex, 
HttpParams params) throws UnsupportedEncodingException {
-        Operation operation = odeMex.getOperation();
-        BindingOperation bindingOperation = 
binding.getBindingOperation(operation.getName(), 
operation.getInput().getName(), operation.getOutput().getName());
-
-        // message to be sent
-        Element message = odeMex.getRequest().getMessage();
-        Message msgDef = operation.getInput().getMessage();
-
-        // base url
-        String url = ((MutableEndpoint) 
odeMex.getEndpointReference()).getUrl();
-
-        // extract part values into a map and check that all parts are 
assigned a value
-        Map<String, Element> partElements = extractPartElements(msgDef, 
message);
-
-        // http method type
-        // the operation may override the verb, this is an extension for 
RESTful BPEL
-        String verb = WsdlUtils.resolveVerb(binding, bindingOperation);
-
-        // build the http method itself
-        HttpMethod method = prepareHttpMethod(bindingOperation, verb, 
partElements, url, params);
-        return method;
-    }
-
-    protected Map<String, Element> extractPartElements(Message msgDef, Element 
message) {
-        Map<String, Element> partValues = new HashMap<String, Element>();
-        for (Iterator iterator = msgDef.getParts().values().iterator(); 
iterator.hasNext();) {
-            Part part = (Part) iterator.next();
-            Element partEl = DOMUtils.findChildByName(message, new QName(null, 
part.getName()));
-            if (partEl == null)
-                throw new 
IllegalArgumentException(msgs.msgOdeMessageMissingRequiredPart(part.getName()));
-            partValues.put(part.getName(), partEl);
-        }
-        return partValues;
+    /**
+     * Parse and convert a HTTP status line into an aml element.
+     *
+     * @param statusLine
+     * @return
+     * @throws HttpException
+     * @see #statusLineToElement(org.w3c.dom.Document, 
org.apache.commons.httpclient.StatusLine)
+     */
+    public Element statusLineToElement(String statusLine) throws HttpException 
{
+        return statusLineToElement(new StatusLine(statusLine));
+    }
+
+    public Element statusLineToElement(StatusLine statusLine) {
+        return statusLineToElement(DOMUtils.newDocument(), statusLine);
     }
 
     /**
-     * create and initialize the http method.
-     * Http Headers that may been passed in the params are not set in this 
method.
-     * Headers will be automatically set by HttpClient.
-     * See usages of HostParams.DEFAULT_HEADERS
-     * See 
org.apache.commons.httpclient.HttpMethodDirector#executeMethod(org.apache.commons.httpclient.HttpMethod)
+     * Convert a <a 
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1";>HTTP status 
line</a> into an xml element like this:
+     * <p/>
+     * < Status-line>
+     * < HTTP-Version>HTTP/1.1< /HTTP-Version>
+     * < Status-Code>200< /Status-Code>
+     * < Reason-Phrase>Success - The action was successfully received, 
understood, and accepted< /Reason-Phrase>
+     * < /Status-line></br>
+     *
+     * @param statusLine - the [EMAIL PROTECTED] 
org.apache.commons.httpclient.StatusLine} instance to be converted
+     * @param doc        - the document to use to create new nodes
+     * @return an Element
      */
-    protected HttpMethod prepareHttpMethod(BindingOperation bindingOperation, 
String verb, Map<String, Element> partValues,
-                                           final String rootUri, HttpParams 
params) throws UnsupportedEncodingException {
-        if (log.isDebugEnabled()) log.debug("Preparing http request...");
-        // convenience variables...
-        BindingInput bindingInput = bindingOperation.getBindingInput();
-        HTTPOperation httpOperation = (HTTPOperation) 
WsdlUtils.getOperationExtension(bindingOperation);
-        MIMEContent content = 
WsdlUtils.getMimeContent(bindingInput.getExtensibilityElements());
-        String contentType = content == null ? "" : content.getType();
-        boolean useUrlEncoded = WsdlUtils.useUrlEncoded(bindingInput) || 
PostMethod.FORM_URL_ENCODED_CONTENT_TYPE.equalsIgnoreCase(contentType);
-        boolean useUrlReplacement = WsdlUtils.useUrlReplacement(bindingInput);
-
-        final UrlReplacementTransformer replacementTransformer = new 
UrlReplacementTransformer();
-        final URLEncodedTransformer encodedTransformer = new 
URLEncodedTransformer();
-
-        // the http method to be built and returned
-        HttpMethod method = null;
-        // the 4 elements the http method may be made of
-        String relativeUri = httpOperation.getLocationURI();
-        String queryPath = null;
-        RequestEntity requestEntity = null;
-        String encodedParams = null;
-
-
-        if (useUrlReplacement) {
-            // insert part values in the url
-            relativeUri = replacementTransformer.transform(relativeUri, 
partValues);
-        } else if (useUrlEncoded) {
-            // encode part values
-            encodedParams = encodedTransformer.transform(partValues);
-        }
+    public Element statusLineToElement(Document doc, StatusLine statusLine) {
+        Element statusLineEl = doc.createElementNS(null, "Status-Line");
+        Element versionEl = doc.createElementNS(null, "HTTP-Version");
+        Element codeEl = doc.createElementNS(null, "Status-Code");
+        Element reasonEl = doc.createElementNS(null, "Reason-Phrase");
+
+        // wiring
+        doc.appendChild(statusLineEl);
+        statusLineEl.appendChild(versionEl);
+        statusLineEl.appendChild(codeEl);
+        statusLineEl.appendChild(reasonEl);
+
+        // values
+        versionEl.setTextContent(statusLine.getHttpVersion());
+        codeEl.setTextContent(String.valueOf(statusLine.getStatusCode()));
+        reasonEl.setTextContent(statusLine.getReasonPhrase());
 
-        // http-client api is not really neat
-        // something similar to the following would save some if/else 
manipulations.
-        // But we have to deal with it as-is.
-        //
-        //  method = new Method(verb);
-        //  method.setRequestEnity(..)
-        //  etc...
-        if ("GET".equalsIgnoreCase(verb) || "DELETE".equalsIgnoreCase(verb)) {
-            if ("GET".equalsIgnoreCase(verb)) {
-                method = new GetMethod();
-            } else if ("DELETE".equalsIgnoreCase(verb)) {
-                method = new DeleteMethod();
-            }
-            if (useUrlEncoded) {
-                queryPath = encodedParams;
-            }
+        return statusLineEl;
+    }
 
-            // Let http-client manage the redirection
-            // see 
org.apache.commons.httpclient.params.HttpClientParams.MAX_REDIRECTS
-            // default is 100
-            method.setFollowRedirects(true);
-        } else if ("POST".equalsIgnoreCase(verb) || 
"PUT".equalsIgnoreCase(verb)) {
-
-            if ("POST".equalsIgnoreCase(verb)) {
-                method = new PostMethod();
-            } else if ("PUT".equalsIgnoreCase(verb)) {
-                method = new PutMethod();
-            }
+    /**
+     * Build a "details" element that looks like this:
+     *
+     * @param method
+     * @return
+     * @throws IOException
+     */
+    public Element prepareDetailsElement(HttpMethod method) throws IOException 
{
+        return prepareDetailsElement(method, true);
+    }
 
-            // some body-building...
-            if (useUrlEncoded) {
-                requestEntity = new StringRequestEntity(encodedParams, 
PostMethod.FORM_URL_ENCODED_CONTENT_TYPE, 
method.getParams().getContentCharset());
-            } else if (contentType.endsWith(CONTENT_TYPE_TEXT_XML)) {
-                // assumption is made that there is a single part
-                // validation steps in the constructor must warranty that
-                Part part = (Part) 
bindingOperation.getOperation().getInput().getMessage().getParts().values().iterator().next();
-                Element partValue = partValues.get(part.getName());
-                // if the part has an element name, we must take the first 
element
-                if (part.getElementName() != null) {
-                    partValue = DOMUtils.getFirstChildElement(partValue);
+    /**
+     *
+     * @param method
+     * @param bodyIsXml if true the body will be parsed as xml else the body 
will be inserted as string
+     * @return
+     * @throws IOException
+     */
+    public Element prepareDetailsElement(HttpMethod method, boolean bodyIsXml) 
throws IOException {
+        Document doc = DOMUtils.newDocument();
+        Element detailsEl = doc.createElementNS(null, "details");
+        Element statusLineEl = statusLineToElement(doc, 
method.getStatusLine());
+        detailsEl.appendChild(statusLineEl);
+
+        // set the body if any
+        final InputStream bodyAsStream = method.getResponseBodyAsStream();
+        if (bodyAsStream != null) {
+            Element bodyEl = doc.createElementNS(null, "responseBody");
+            detailsEl.appendChild(bodyEl);
+            // first, try to parse the body as xml
+            // if it fails, put it as string in the body element
+            boolean exceptionDuringParsing = false;
+            if (bodyIsXml) {
+                try {
+                    Element parsedBodyEl = 
DOMUtils.parse(bodyAsStream).getDocumentElement();
+                    bodyEl.appendChild(parsedBodyEl);
+                } catch (Exception e) {
+                    String errmsg = "Unable to parse the response body as xml. 
Body will be inserted as string.";
+                    if (log.isDebugEnabled()) log.debug(errmsg, e);
+                    exceptionDuringParsing = true;
                 }
-                String xmlString = DOMUtils.domToString(partValue);
-                requestEntity = new 
ByteArrayRequestEntity(xmlString.getBytes(), contentType);
-            } else {
-                // should not happen because of HttpBindingValidator, but 
never say never
-                throw new IllegalArgumentException("Unsupported 
content-type!");
             }
-
-            // cast safely, PUT and POST are subclasses of 
EntityEnclosingMethod
-            final EntityEnclosingMethod enclosingMethod = 
(EntityEnclosingMethod) method;
-            enclosingMethod.setRequestEntity(requestEntity);
-            
enclosingMethod.setContentChunked(params.getBooleanParameter(Properties.PROP_HTTP_REQUEST_CHUNK,
 false));
-
-        } else {
-            // should not happen because of HttpBindingValidator, but never 
say never
-            throw new IllegalArgumentException("Unsupported HTTP method: " + 
verb);
+            if (!bodyIsXml || exceptionDuringParsing) {
+                bodyEl.setTextContent(method.getResponseBodyAsString());
+            }
         }
-
-        // link params together
-        method.getParams().setDefaults(params);
-
-        String completeUri = rootUri + (rootUri.endsWith("/") || 
relativeUri.startsWith("/") ? "" : "/") + relativeUri;
-        method.setPath(completeUri); // assumes that the path is properly 
encoded (URL safe).
-        method.setQueryString(queryPath);
-        return method;
+        return detailsEl;
     }
 }

Modified: 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java?rev=672087&r1=672086&r2=672087&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
 Thu Jun 26 19:28:43 2008
@@ -31,14 +31,13 @@
 import org.apache.ode.axis2.Properties;
 import org.apache.ode.bpel.epr.EndpointFactory;
 import org.apache.ode.bpel.epr.WSAEndpoint;
-import org.apache.ode.bpel.epr.WSDL11Endpoint;
-import org.apache.ode.bpel.epr.MutableEndpoint;
 import org.apache.ode.bpel.iapi.BpelServer;
 import org.apache.ode.bpel.iapi.EndpointReference;
 import org.apache.ode.bpel.iapi.MessageExchange;
 import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
 import org.apache.ode.bpel.iapi.ProcessConf;
 import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.bpel.iapi.Message;
 import org.apache.ode.utils.DOMUtils;
 import org.apache.ode.utils.Namespaces;
 import org.apache.ode.utils.wsdl.Messages;
@@ -53,12 +52,13 @@
 import javax.wsdl.Part;
 import javax.wsdl.Port;
 import javax.wsdl.Service;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Fault;
 import javax.xml.namespace.QName;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.util.Map;
-import java.util.HashMap;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 
@@ -77,12 +77,16 @@
     protected Scheduler scheduler;
     protected BpelServer server;
     protected ProcessConf pconf;
+    private String targetNamespace;
     protected QName serviceName;
     protected String portName;
     protected WSAEndpoint endpointReference;
     
-    protected HttpClientHelper clientHelper;
+    protected HttpClientHelper helper;
+    protected HttpMethodConverter httpMethodConverter;
 
+    protected Binding portBinding;
+    
     public HttpExternalService(ProcessConf pconf, QName serviceName, String 
portName, ExecutorService executorService, Scheduler scheduler, BpelServer 
server) {
         this.portName = portName;
         this.serviceName = serviceName;
@@ -91,14 +95,15 @@
         this.server = server;
         this.pconf = pconf;
         Definition definition = pconf.getDefinitionForService(serviceName);
+        targetNamespace = definition.getTargetNamespace();
         Service serviceDef = definition.getService(serviceName);
         if (serviceDef == null)
             throw new 
IllegalArgumentException(msgs.msgServiceDefinitionNotFound(serviceName));
         Port port = serviceDef.getPort(portName);
         if (port == null)
             throw new 
IllegalArgumentException(msgs.msgPortDefinitionNotFound(serviceName, portName));
-        Binding binding = port.getBinding();
-        if (binding == null)
+        portBinding = port.getBinding();
+        if (portBinding == null)
             throw new 
IllegalArgumentException(msgs.msgBindingNotFound(portName));
 
         // validate the http binding
@@ -106,7 +111,7 @@
             throw new 
IllegalArgumentException(msgs.msgNoHTTPBindingForPort(portName));
         }
         // throws an IllegalArgumentException if not valid
-        new HttpBindingValidator(binding).validate();
+        new HttpBindingValidator(this.portBinding).validate();
 
         // initial endpoint reference
         Element eprElmt = ODEService.genEPRfromWSDL(definition, serviceName, 
portName);
@@ -114,7 +119,8 @@
             throw new 
IllegalArgumentException(msgs.msgPortDefinitionNotFound(serviceName, portName));
         endpointReference = 
EndpointFactory.convertToWSA(ODEService.createServiceRef(eprElmt));
 
-        clientHelper = new HttpClientHelper(binding);
+        httpMethodConverter = new HttpMethodConverter(this.portBinding);
+        helper = new HttpClientHelper();
         connections = new MultiThreadedHttpConnectionManager();
     }
 
@@ -142,14 +148,15 @@
             final HttpParams params = 
Properties.HttpClient.translate(properties);
 
             // build the http method
-            final HttpMethod method = clientHelper.buildHttpMethod(odeMex, 
params);
+            final HttpMethod method = 
httpMethodConverter.createHttpRequest(odeMex, params);
 
             // create a client
             HttpClient client = new HttpClient(connections);
-            // don't forget to wire params so that IL properties are passed 
around
+            // don't forget to wire params so that EPR properties are passed 
around
             client.getParams().setDefaults(params);
 
-            clientHelper.configure(client.getHostConfiguration(), 
client.getState(), method.getURI(), params);
+            // configure the client (proxy, security, etc)
+            helper.configure(client.getHostConfiguration(), client.getState(), 
method.getURI(), params);
 
             // this callable encapsulates the http method execution and the 
process of the response
             final Callable executionCallable;
@@ -158,7 +165,7 @@
             boolean isTwoWay = odeMex.getMessageExchangePattern() == 
org.apache.ode.bpel.iapi.MessageExchange.MessageExchangePattern.REQUEST_RESPONSE;
             if (isTwoWay) {
                 // two way
-                executionCallable = new 
HttpExternalService.TwoWayCallable(client, method, 
odeMex.getMessageExchangeId(), odeMex.getOperation());
+                executionCallable = new 
HttpExternalService.TwoWayCallable(client, method, odeMex);
                 scheduler.registerSynchronizer(new Scheduler.Synchronizer() {
                     public void afterCompletion(boolean success) {
                         // If the TX is rolled back, then we don't send the 
request.
@@ -173,7 +180,7 @@
                 odeMex.replyAsync();
             } else {
                 // one way, just execute and forget
-                executionCallable = new 
HttpExternalService.OneWayCallable(client, method, 
odeMex.getMessageExchangeId(), odeMex.getOperation());
+                executionCallable = new 
HttpExternalService.OneWayCallable(client, method, odeMex);
                 executorService.submit(executionCallable);
                 odeMex.replyOneWayOk();
             }
@@ -194,14 +201,12 @@
 
     private class OneWayCallable implements Callable<Void> {
         HttpMethod method;
-        String mexId;
-        Operation operation;
+        PartnerRoleMessageExchange odeMex;
         HttpClient client;
 
-        public OneWayCallable(org.apache.commons.httpclient.HttpClient client, 
HttpMethod method, String mexId, Operation operation) {
+        public OneWayCallable(HttpClient client, HttpMethod method, 
PartnerRoleMessageExchange odeMex) {
             this.method = method;
-            this.mexId = mexId;
-            this.operation = operation;
+            this.odeMex = odeMex;
             this.client = client;
         }
 
@@ -212,7 +217,7 @@
                     log.debug("Executing http request : " + method.getName() + 
" " + method.getURI());
 
                 final int statusCode = client.executeMethod(method);
-                // invoke getResponseBody to force the loading of the body 
+                // invoke getResponseBody to force the loading of the body
                 // Actually the processResponse may happen in a separate 
thread and
                 // as a result the connection might be closed before the body 
processing (see the finally clause below).
                 byte[] responseBody = method.getResponseBody();
@@ -223,7 +228,6 @@
                 try {
                     scheduler.execIsolatedTransaction(new Callable<Void>() {
                         public Void call() throws Exception {
-                            PartnerRoleMessageExchange odeMex = 
(PartnerRoleMessageExchange) server.getEngine().getMessageExchange(mexId);
                             String errmsg = "Unable to execute http request : 
" + e.getMessage();
                             log.error(errmsg, e);
                             
odeMex.replyWithFailure(MessageExchange.FailureType.COMMUNICATION_ERROR, 
errmsg, null);
@@ -258,8 +262,8 @@
     }
 
     private class TwoWayCallable extends OneWayCallable {
-        public TwoWayCallable(org.apache.commons.httpclient.HttpClient client, 
HttpMethod method, String mexId, Operation operation) {
-            super(client, method, mexId, operation);
+        public TwoWayCallable(org.apache.commons.httpclient.HttpClient client, 
HttpMethod method, PartnerRoleMessageExchange odeMex) {
+            super(client, method, odeMex);
         }
 
         public void processResponse(final int statusCode) {
@@ -269,13 +273,13 @@
                     public Void call() throws Exception {
 
                         if (statusCode >= 200 && statusCode < 300) {
-                            success();
+                            _2xx_success();
                         } else if (statusCode >= 300 && statusCode < 400) {
-                            redirection();
+                            _3xx_redirection();
                         } else if (statusCode >= 400 && statusCode < 500) {
-                            badRequest();
+                            _4xx_badRequest();
                         } else if (statusCode >= 500 && statusCode < 600) {
-                            serverError();
+                            _5xx_serverError();
                         } else {
                             unmanagedStatus();
                         }
@@ -289,53 +293,92 @@
             }
         }
 
-        private void unmanagedStatus() {
-            PartnerRoleMessageExchange odeMex = (PartnerRoleMessageExchange) 
server.getEngine().getMessageExchange(mexId);
+        private void unmanagedStatus() throws IOException {
             String errmsg = "Unmanaged Status Code! " + method.getStatusLine();
             log.error(errmsg);
-            odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, 
null);
+            odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, 
helper.prepareDetailsElement(method));
         }
 
-        private void serverError() {
-            PartnerRoleMessageExchange odeMex = (PartnerRoleMessageExchange) 
server.getEngine().getMessageExchange(mexId);
-            QName type = new QName(Namespaces.ODE_EXTENSION_NS, 
"HttpRemoteServerFault");
-
-            Document odeMsg = DOMUtils.newDocument();
-            Element odeMsgEl = odeMsg.createElementNS(null, "message");
-            Element statusEl = odeMsg.createElementNS(null, "statusLine");
-            statusEl.setTextContent(String.valueOf(method.getStatusLine()));
-
-            odeMsg.appendChild(odeMsgEl);
-            odeMsgEl.appendChild(statusEl);
-            org.apache.ode.bpel.iapi.Message response = 
odeMex.createMessage(type);
-            response.setMessage(odeMsgEl);
+        /**
+         * For 500s if a fault is defined in the WSDL and the response body 
contains the corresponding xml doc, then reply with a fault ; else reply with 
failure.
+         *
+         * @throws IOException
+         */
+        private void _5xx_serverError() throws IOException {
+            String errmsg = "Internal Server Error! " + method.getStatusLine();
+            log.error(errmsg);
+
+            Operation opDef = odeMex.getOperation();
+            BindingOperation opBinding = 
portBinding.getBindingOperation(opDef.getName(), opDef.getInput().getName(), 
opDef.getOutput().getName());
+            if (opDef.getFaults().isEmpty()) {
+                errmsg = "Operation has no fault. This 500 error will be 
considered as a failure.";
+                if (log.isDebugEnabled()) log.debug(errmsg);
+                odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, 
errmsg, helper.prepareDetailsElement(method));
+            } else if (opBinding.getBindingFaults().isEmpty()) {
+                errmsg = "No fault binding. This 500 error will be considered 
as a failure.";
+                if (log.isDebugEnabled()) log.debug(errmsg);
+                odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, 
errmsg, helper.prepareDetailsElement(method));
+            } else if (method.getResponseBodyAsStream() == null) {
+                errmsg = "No body in the response. This 500 error will be 
considered as a failure.";
+                if (log.isDebugEnabled()) log.debug(errmsg);
+                odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, 
errmsg, helper.prepareDetailsElement(method));
+            } else {
+                final InputStream bodyAsStream = 
method.getResponseBodyAsStream();
+                try {
+                    Element bodyEl = 
DOMUtils.parse(bodyAsStream).getDocumentElement();
+                    QName bodyName = new QName(bodyEl.getNamespaceURI(), 
bodyEl.getNodeName());
+                    Fault faultDef = WsdlUtils.inferFault(opDef, bodyName);
+
+                    // is this fault bound with ODE extension?
+                    if 
(!WsdlUtils.isOdeFault(opBinding.getBindingFault(faultDef.getName()))) {
+                        errmsg = "Fault " + bodyName + " is not bound with " + 
new QName(Namespaces.ODE_HTTP_EXTENSION_NS, "fault") + ". This 500 error will 
be considered as a failure.";
+                        if (log.isDebugEnabled()) log.debug(errmsg);
+                        
odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, 
helper.prepareDetailsElement(method));
+                    } else {
+                        Part partDef = (Part) 
opBinding.getOperation().getFault(faultDef.getName()).getMessage().getParts().values().iterator().next();
+
+                        // build the element to be sent back
+                        Document odeMsg = DOMUtils.newDocument();
+                        Element odeMsgEl = odeMsg.createElementNS(null, 
"message");
+                        Element partEl = 
odeMsgEl.getOwnerDocument().createElementNS(null, partDef.getName());
+                        odeMsgEl.appendChild(partEl);
+                        // import the response body
+                        
partEl.appendChild(odeMsgEl.getOwnerDocument().importNode(bodyEl, true));
+
+                        QName faultType = new QName(targetNamespace, 
faultDef.getName());
+                        Message response = odeMex.createMessage(faultType);
+                        response.setMessage(odeMsgEl);
+                        // finally send the fault. We did it!
+                        odeMex.replyWithFault(faultType, response);
+                    }
+                } catch (Exception e) {
+                    errmsg = "Unable to parse the response body as xml. This 
500 error will be considered as a failure.";
+                    if (log.isDebugEnabled()) log.debug(errmsg, e);
+                    odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, 
errmsg, helper.prepareDetailsElement(method, false));
+                }
+            }
 
-            log.error("Http Server Error! " + method.getStatusLine());
-            odeMex.replyWithFault(type, response);
         }
 
-        private void badRequest() {
-            PartnerRoleMessageExchange odeMex = (PartnerRoleMessageExchange) 
server.getEngine().getMessageExchange(mexId);
+        private void _4xx_badRequest() throws IOException {
             String errmsg = "Bad Request! " + method.getStatusLine();
             log.error(errmsg);
-            odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, 
null);
+            odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, 
helper.prepareDetailsElement(method));
         }
 
-        private void redirection() {
-            PartnerRoleMessageExchange odeMex = (PartnerRoleMessageExchange) 
server.getEngine().getMessageExchange(mexId);
+        private void _3xx_redirection() throws IOException {
             String errmsg = "Redirections are not supported! " + 
method.getStatusLine();
             log.error(errmsg);
-            odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, 
null);
+            odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, errmsg, 
helper.prepareDetailsElement(method));
         }
 
-        private void success() {
+        private void _2xx_success() {
             if (log.isDebugEnabled()) log.debug("Http Status Line=" + 
method.getStatusLine());
-            PartnerRoleMessageExchange odeMex = (PartnerRoleMessageExchange) 
server.getEngine().getMessageExchange(mexId);
             if (log.isDebugEnabled()) log.debug("Received response for MEX " + 
odeMex);
             try {
                 final InputStream bodyAsStream = 
method.getResponseBodyAsStream();
                 if (bodyAsStream == null) {
-                    String errmsg = "Request body of a Two-way message may not 
be empty! Msg Id=" + mexId;
+                    String errmsg = "Request body of a Two-way message may not 
be empty! Msg Id=" + odeMex.getMessageExchangeId();
                     log.error(errmsg);
                     odeMex.replyWithFailure(MessageExchange.FailureType.OTHER, 
errmsg, null);
                     return;
@@ -347,7 +390,7 @@
                     try {
                         bodyElement = 
DOMUtils.parse(bodyAsStream).getDocumentElement();
                     } catch (Exception e) {
-                        String errmsg = "Unable to parse the request body : " 
+ e.getMessage();
+                        String errmsg = "Unable to parse the response body: " 
+ e.getMessage();
                         log.error(errmsg, e);
                         
odeMex.replyWithFailure(MessageExchange.FailureType.FORMAT_ERROR, errmsg, null);
                         return;
@@ -357,7 +400,7 @@
 
                         // we expect a single part per output message
                         // see 
org.apache.ode.axis2.httpbinding.HttpBindingValidator call in constructor
-                        Part part = (Part) 
operation.getOutput().getMessage().getParts().values().iterator().next();
+                        Part part = (Part) 
odeMex.getOperation().getOutput().getMessage().getParts().values().iterator().next();
 
                         Element partElement = processBodyElement(part, 
bodyElement);
                         odeResponse.setPart(part.getName(), partElement);

Copied: 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
 (from r672086, 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpClientHelper.java)
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java?p2=ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java&p1=ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpClientHelper.java&r1=672086&r2=672087&rev=672087&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpClientHelper.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
 Thu Jun 26 19:28:43 2008
@@ -19,7 +19,7 @@
 
 package org.apache.ode.axis2.httpbinding;
 
-import org.apache.commons.httpclient.Header;
+import org.apache.axis2.transport.http.HttpTransportProperties;
 import org.apache.commons.httpclient.HostConfiguration;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.HttpState;
@@ -34,18 +34,19 @@
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.commons.httpclient.params.HttpParams;
-import org.apache.commons.httpclient.params.HostParams;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.commons.lang.StringUtils;
 import org.apache.ode.axis2.Properties;
 import org.apache.ode.axis2.util.URLEncodedTransformer;
 import org.apache.ode.axis2.util.UrlReplacementTransformer;
-import org.apache.ode.bpel.epr.MutableEndpoint;
 import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
 import org.apache.ode.utils.DOMUtils;
 import org.apache.ode.utils.wsdl.Messages;
 import org.apache.ode.utils.wsdl.WsdlUtils;
-import org.apache.axis2.transport.http.HttpTransportProperties;
+import org.apache.ode.bpel.epr.MutableEndpoint;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFault;
 import org.w3c.dom.Element;
 
 import javax.wsdl.Binding;
@@ -54,42 +55,29 @@
 import javax.wsdl.Message;
 import javax.wsdl.Operation;
 import javax.wsdl.Part;
+import javax.wsdl.Fault;
 import javax.wsdl.extensions.http.HTTPOperation;
 import javax.wsdl.extensions.mime.MIMEContent;
 import javax.xml.namespace.QName;
 import java.io.UnsupportedEncodingException;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Collection;
 
-public class HttpClientHelper {
+public class HttpMethodConverter {
 
     private static final String CONTENT_TYPE_TEXT_XML = "text/xml";
     private static final Log log = LogFactory.getLog(HttpClientHelper.class);
 
-    protected static final org.apache.ode.utils.wsdl.Messages msgs = 
Messages.getMessages(Messages.class);
+    protected static final Messages msgs = 
Messages.getMessages(Messages.class);
     protected Binding binding;
 
-    public HttpClientHelper(Binding binding) {
+    public HttpMethodConverter(Binding binding) {
         this.binding = binding;
     }
 
-    public void configure(HostConfiguration hostConfig, HttpState state, URI 
targetURI, HttpParams params) throws URIException {
-        if (log.isDebugEnabled()) log.debug("Configuring http client...");
-        // proxy configuration
-        if (ProxyConf.isProxyEnabled(params, targetURI.getHost())) {
-            if (log.isDebugEnabled()) log.debug("ProxyConf");
-            ProxyConf.configure(hostConfig, state, 
(HttpTransportProperties.ProxyProperties) 
params.getParameter(Properties.PROP_HTTP_PROXY_PREFIX));
-        }
-
-        // security
-        // ...
-
-    }
-
-    public HttpMethod buildHttpMethod(PartnerRoleMessageExchange odeMex, 
HttpParams params) throws UnsupportedEncodingException {
+    public HttpMethod createHttpRequest(PartnerRoleMessageExchange odeMex, 
HttpParams params) throws UnsupportedEncodingException {
         Operation operation = odeMex.getOperation();
         BindingOperation bindingOperation = 
binding.getBindingOperation(operation.getName(), 
operation.getInput().getName(), operation.getOutput().getName());
 
@@ -112,18 +100,11 @@
         return method;
     }
 
-    protected Map<String, Element> extractPartElements(Message msgDef, Element 
message) {
-        Map<String, Element> partValues = new HashMap<String, Element>();
-        for (Iterator iterator = msgDef.getParts().values().iterator(); 
iterator.hasNext();) {
-            Part part = (Part) iterator.next();
-            Element partEl = DOMUtils.findChildByName(message, new QName(null, 
part.getName()));
-            if (partEl == null)
-                throw new 
IllegalArgumentException(msgs.msgOdeMessageMissingRequiredPart(part.getName()));
-            partValues.put(part.getName(), partEl);
-        }
-        return partValues;
+    public void parseHttpResponse(org.apache.ode.bpel.iapi.Message odeMessage, 
HttpMethod response, Operation op) {
+
     }
 
+
     /**
      * create and initialize the http method.
      * Http Headers that may been passed in the params are not set in this 
method.
@@ -142,24 +123,28 @@
         boolean useUrlEncoded = WsdlUtils.useUrlEncoded(bindingInput) || 
PostMethod.FORM_URL_ENCODED_CONTENT_TYPE.equalsIgnoreCase(contentType);
         boolean useUrlReplacement = WsdlUtils.useUrlReplacement(bindingInput);
 
-        final UrlReplacementTransformer replacementTransformer = new 
UrlReplacementTransformer();
-        final URLEncodedTransformer encodedTransformer = new 
URLEncodedTransformer();
-
         // the http method to be built and returned
         HttpMethod method = null;
+
         // the 4 elements the http method may be made of
         String relativeUri = httpOperation.getLocationURI();
         String queryPath = null;
-        RequestEntity requestEntity = null;
+        RequestEntity requestEntity;
         String encodedParams = null;
 
+        // ODE supports uri template in both port and operation location.
+        // so assemble the final url *before* replacement
+        String completeUri = rootUri;
+        if (StringUtils.isNotEmpty(relativeUri)) {
+            completeUri = completeUri + (completeUri.endsWith("/") || 
relativeUri.startsWith("/") ? "" : "/") + relativeUri;
+        }
 
         if (useUrlReplacement) {
             // insert part values in the url
-            relativeUri = replacementTransformer.transform(relativeUri, 
partValues);
+            completeUri = new 
UrlReplacementTransformer().transform(completeUri, partValues);
         } else if (useUrlEncoded) {
             // encode part values
-            encodedParams = encodedTransformer.transform(partValues);
+            encodedParams = new URLEncodedTransformer().transform(partValues);
         }
 
         // http-client api is not really neat
@@ -195,9 +180,8 @@
             if (useUrlEncoded) {
                 requestEntity = new StringRequestEntity(encodedParams, 
PostMethod.FORM_URL_ENCODED_CONTENT_TYPE, 
method.getParams().getContentCharset());
             } else if (contentType.endsWith(CONTENT_TYPE_TEXT_XML)) {
-                // assumption is made that there is a single part
-                // validation steps in the constructor must warranty that
-                Part part = (Part) 
bindingOperation.getOperation().getInput().getMessage().getParts().values().iterator().next();
+                // get the part to be put in the body
+                Part part = 
bindingOperation.getOperation().getInput().getMessage().getPart(content.getPart());
                 Element partValue = partValues.get(part.getName());
                 // if the part has an element name, we must take the first 
element
                 if (part.getElementName() != null) {
@@ -222,10 +206,23 @@
 
         // link params together
         method.getParams().setDefaults(params);
-
-        String completeUri = rootUri + (rootUri.endsWith("/") || 
relativeUri.startsWith("/") ? "" : "/") + relativeUri;
         method.setPath(completeUri); // assumes that the path is properly 
encoded (URL safe).
         method.setQueryString(queryPath);
         return method;
     }
-}
+
+
+    protected Map<String, Element> extractPartElements(Message msgDef, Element 
message) {
+        Map<String, Element> partValues = new HashMap<String, Element>();
+        for (Iterator iterator = msgDef.getParts().values().iterator(); 
iterator.hasNext();) {
+            Part part = (Part) iterator.next();
+            Element partEl = DOMUtils.findChildByName(message, new QName(null, 
part.getName()));
+            if (partEl == null)
+                throw new 
IllegalArgumentException(msgs.msgOdeMessageMissingRequiredPart(part.getName()));
+            partValues.put(part.getName(), partEl);
+        }
+        return partValues;
+    }
+
+
+}
\ No newline at end of file

Modified: 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java?rev=672087&r1=672086&r2=672087&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
 Thu Jun 26 19:28:43 2008
@@ -532,22 +532,7 @@
 
         // The detail is a dummy <detail> node containing the interesting 
fault element
         QName elName = flt.getDetail().getFirstElement().getQName();
-        for (Fault f : (Collection<Fault>)operation.getFaults().values()) {
-            if (f.getMessage() == null)
-                continue;  // should have checked in ctor
-
-            Collection<Part> parts = f.getMessage().getParts().values();
-            if (parts.isEmpty())
-                continue;  // should check this in ctor
-            Part p = parts.iterator().next();
-            if (p.getElementName() == null)
-                continue;  // should check this is ctor
-
-            if (p.getElementName().equals(elName))
-                return f;
-        }
-
-        return null;
+        return WsdlUtils.inferFault(operation, elName);
     }
 
 }

Copied: 
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpMethodConverterTest.java
 (from r672086, 
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpClientHelperTest.java)
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpMethodConverterTest.java?p2=ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpMethodConverterTest.java&p1=ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpClientHelperTest.java&r1=672086&r2=672087&rev=672087&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpClientHelperTest.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpMethodConverterTest.java
 Thu Jun 26 19:28:43 2008
@@ -24,13 +24,8 @@
 import org.apache.commons.httpclient.params.DefaultHttpParams;
 import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
 import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.ode.bpel.epr.MutableEndpoint;
-import org.apache.ode.bpel.iapi.BpelEngineException;
-import org.apache.ode.bpel.iapi.EndpointReference;
-import org.apache.ode.bpel.iapi.Message;
-import org.apache.ode.bpel.iapi.PartnerRoleChannel;
-import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
-import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.il.epr.MutableEndpoint;
+import org.apache.ode.bpel.iapi.*;
 import org.apache.ode.utils.DOMUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -54,15 +49,15 @@
 /**
  * @author <a href="mailto:[EMAIL PROTECTED]">Alexis Midon</a>
  */
-public class HttpClientHelperTest extends TestCase {
+public class HttpMethodConverterTest extends TestCase {
 
     protected Definition definition;
 
-    protected HttpClientHelper deliciousBuilder;
+    protected HttpMethodConverter deliciousBuilder;
     protected Binding deliciousBinding;
     protected Port deliciousPort;
 
-    protected HttpClientHelper dummyBuilder;
+    protected HttpMethodConverter dummyBuilder;
     protected Port dummyPort;
     protected Binding dummyBinding;
 
@@ -77,12 +72,12 @@
         Service deliciousService = definition.getService(new 
QName("http://ode/bpel/unit-test.wsdl";, "DeliciousService"));
         deliciousPort = deliciousService.getPort("TagHttpPort");
         deliciousBinding = deliciousPort.getBinding();
-        deliciousBuilder = new HttpClientHelper(deliciousBinding);
+        deliciousBuilder = new HttpMethodConverter(deliciousBinding);
 
         Service dummyService = definition.getService(new 
QName("http://ode/bpel/unit-test.wsdl";, "DummyService"));
         dummyPort = dummyService.getPort("DummyServiceHttpport");
         dummyBinding = dummyPort.getBinding();
-        dummyBuilder = new HttpClientHelper(dummyBinding);
+        dummyBuilder = new HttpMethodConverter(dummyBinding);
 
     }
 
@@ -103,7 +98,7 @@
         odeMex.op = deliciousBinding.getBindingOperation("getTag", null, 
null).getOperation();
         odeMex.req = new MockMessage(msgEl);
         odeMex.epr = new MockEPR(uri);
-        HttpMethod httpMethod = deliciousBuilder.buildHttpMethod(odeMex, new 
DefaultHttpParams());
+        HttpMethod httpMethod = deliciousBuilder.createHttpRequest(odeMex, new 
DefaultHttpParams());
 
 
         assertTrue("GET".equalsIgnoreCase(httpMethod.getName()));
@@ -124,7 +119,7 @@
         odeMex.req = new MockMessage(msgEl);
         odeMex.epr = new MockEPR(uri);
         try {
-            HttpMethod httpMethod = deliciousBuilder.buildHttpMethod(odeMex, 
new DefaultHttpParams());
+            HttpMethod httpMethod = deliciousBuilder.createHttpRequest(odeMex, 
new DefaultHttpParams());
             fail("IllegalArgumentException expected because message element is 
empty.");
         } catch (IllegalArgumentException e) {
             // expected behavior
@@ -150,7 +145,7 @@
         odeMex.op = dummyBinding.getBindingOperation("hello", null, 
null).getOperation();
         odeMex.req = new MockMessage(msgEl);
         odeMex.epr = new MockEPR(uri);
-        HttpMethod httpMethod = dummyBuilder.buildHttpMethod(odeMex, new 
DefaultHttpParams());
+        HttpMethod httpMethod = dummyBuilder.createHttpRequest(odeMex, new 
DefaultHttpParams());
         assertTrue("POST".equalsIgnoreCase(httpMethod.getName()));
         assertEquals("Generated URI does not match", expectedUri, 
httpMethod.getURI().toString());
 
@@ -260,10 +255,6 @@
             return null;
         }
 
-        public PartnerRoleChannel getChannel() {
-            return null;
-        }
-
         public EndpointReference getMyRoleEndpointReference() {
             return null;
         }
@@ -272,10 +263,6 @@
 
         }
 
-        public void replyAsync() {
-
-        }
-
         public void replyOneWayOk() {
 
         }
@@ -336,10 +323,6 @@
             return null;
         }
 
-        public boolean isTransactionPropagated() throws BpelEngineException {
-            return false;
-        }
-
         public void release() {
 
         }
@@ -347,5 +330,36 @@
         public void setProperty(String key, String value) {
 
         }
+
+        public PartnerRoleChannel getPartnerRoleChannel() {
+            return null;
+        }
+
+        public void replyAsync(String foreignKey) {
+        }
+
+        public InvocationStyle getInvocationStyle() {
+            return null;
+        }
+
+        public long getTimeout() {
+            return 0;
+        }
+
+        public void setTimeout(long timeout) {
+
+        }
+
+        public AckType getAckType() {
+            return null;
+        }
+
+        public boolean isTransactional() {
+            return false;
+        }
+
+        public boolean isSafe() {
+            return false;
+        }
     }
 }

Modified: 
ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/wsdl/WsdlUtils.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/wsdl/WsdlUtils.java?rev=672087&r1=672086&r2=672087&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/wsdl/WsdlUtils.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/wsdl/WsdlUtils.java
 Thu Jun 26 19:28:43 2008
@@ -19,28 +19,32 @@
 
 package org.apache.ode.utils.wsdl;
 
-import org.apache.ode.utils.stl.CollectionsX;
 import org.apache.ode.utils.Namespaces;
+import org.apache.ode.utils.stl.CollectionsX;
 import org.w3c.dom.Element;
 
 import javax.wsdl.Binding;
-import javax.wsdl.Port;
-import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingFault;
 import javax.wsdl.BindingInput;
-import javax.wsdl.Service;
+import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Operation;
+import javax.wsdl.Part;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.UnknownExtensibilityElement;
-import javax.wsdl.extensions.mime.MIMEContent;
-import javax.wsdl.extensions.mime.MIMEMultipartRelated;
+import javax.wsdl.extensions.http.HTTPAddress;
 import javax.wsdl.extensions.http.HTTPBinding;
 import javax.wsdl.extensions.http.HTTPOperation;
 import javax.wsdl.extensions.http.HTTPUrlEncoded;
 import javax.wsdl.extensions.http.HTTPUrlReplacement;
-import javax.wsdl.extensions.http.HTTPAddress;
+import javax.wsdl.extensions.mime.MIMEContent;
+import javax.wsdl.extensions.mime.MIMEMultipartRelated;
+import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap.SOAPOperation;
-import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.xml.namespace.QName;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -217,7 +221,7 @@
 
     /**
      * @return the [EMAIL PROTECTED] 
javax.wsdl.extensions.mime.MIMEContent#getType() type} of the instance of 
[EMAIL PROTECTED] javax.wsdl.extensions.mime.MIMEContent}
-     * contained in the extensibility element list. Or null if none.
+     *         contained in the extensibility element list. Or null if none.
      * @throws IllegalArgumentException if more than 1 MIMEContent is found.
      */
     public static MIMEContent getMimeContent(List extensibilityElements) {
@@ -264,6 +268,7 @@
      * <br/> If you do so, an [EMAIL PROTECTED] UnknownExtensibilityElement} 
will be added to the list of extensibility elements of the [EMAIL PROTECTED] 
javax.wsdl.BindingOperation}.
      * <br/> This method looks up for such an element and return the value of 
the verb attribute if the underlying [EMAIL PROTECTED] org.w3c.dom.Element} is 
[EMAIL PROTECTED] <binding xmlns="http://schemas.xmlsoap.org/wsdl/http/"/>}
      * or null.
+     *
      * @param bindingOperation
      */
     public static String getOperationVerb(BindingOperation bindingOperation) {
@@ -280,15 +285,58 @@
     }
 
     /**
+     *
+     * @param fault
+     * @return true if the given fault is bound with the [EMAIL PROTECTED] 
org.apache.ode.utils.Namespaces.ODE_HTTP_EXTENSION_NS}:fault element.
+     */
+    public static boolean isOdeFault(BindingFault fault) {
+        final Collection<UnknownExtensibilityElement> unknownExtElements = 
CollectionsX.filter(fault.getExtensibilityElements(), 
UnknownExtensibilityElement.class);
+        for (UnknownExtensibilityElement extensibilityElement : 
unknownExtElements) {
+            final Element e = extensibilityElement.getElement();
+            if 
(Namespaces.ODE_HTTP_EXTENSION_NS.equalsIgnoreCase(e.getNamespaceURI())
+                    && 
"fault".equals(extensibilityElement.getElement().getLocalName())) {
+                // name attribute is optional, but if any it must match the 
fault name
+                if (e.hasAttribute("name")) {
+                    return fault.getName().equals(e.getAttribute("name"));
+                } else {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Return the [EMAIL PROTECTED]  javax.wsdl.Fault} that has the given 
element as message part.
+     * @param operation the operation
+     * @param elName the qname to look for
+     * @return the first fault for which the element of message part matches 
the given qname
+     */
+    @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;
+    }
+
+
+    /**
      * ODE extends the wsdl spec by allowing definition of the HTTP verb at 
the operation level.
      * <br/>The current implementation implementations allows you to have a 
[EMAIL PROTECTED] <binding xmlns="http://schemas.xmlsoap.org/wsdl/http/"/>} 
element
      * at the port level <strong>and</strong> at the operation level. In such 
a case the operation's verb overrides the port's verb.
      * <br/> This method applies the later rule.
-     * <br/> If defined the operation's verb is returned, else the port's 
verb.  
+     * <br/> If defined the operation's verb is returned, else the port's verb.
+     *
      * @param binding
      * @param bindingOperation
      * @return If defined the operation's verb is returned, else the port's 
verb.
-     * @see #getOperationVerb(javax.wsdl.BindingOperation) 
+     * @see #getOperationVerb(javax.wsdl.BindingOperation)
      */
     public static String resolveVerb(Binding binding, BindingOperation 
bindingOperation) {
         final HTTPBinding httpBinding = (HTTPBinding) 
WsdlUtils.getBindingExtension(binding);


Reply via email to