Author: boisvert
Date: Mon Feb 12 12:26:01 2007
New Revision: 506618

URL: http://svn.apache.org/viewvc?view=rev&rev=506618
Log:
1) Fix bug where response message is validated against request message 
definition (SoapMessageConverter.createSoapResponse)
2) Improve error reporting

Modified:
    incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Messages.java
    incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEService.java
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/P2PMexContextImpl.java
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Messages.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Messages.java?view=diff&rev=506618&r1=506617&r2=506618
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Messages.java 
(original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Messages.java 
Mon Feb 12 12:26:01 2007
@@ -145,92 +145,94 @@
 
     public String msgDAOInstantiationFailed(String className) {
         return format("Error instantiating DAO Connection Factory class {0}.", 
className);
-        
+
     }
 
     public Throwable msgOdeMessageMissingRequiredPart(String partName) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Message is missing required part: {0}", partName);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgServiceDefinitionNotFound(QName serviceName) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Servicd definition not found: {0}.", serviceName);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgPortDefinitionNotFound(QName serviceName, String 
portName) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Port definition not found: service {0} port {1}.", 
serviceName, portName);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgBindingOperationNotFound(QName serviceName, String 
portName, String name) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Binding operation not found: service {0} port {1} 
name {2}.", serviceName, portName, name);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgBindingInputNotFound(QName serviceName, String 
portName, String name) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Binding input not found: service {0} port {1} name 
{2}.", serviceName, portName, name);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgBindingNotFound(QName serviceName, String portName) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Binding not found: service {0} port {1}.", 
serviceName, portName);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgNoSOAPBindingForPort(String name) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("No SOAP binding for port: {0}.", name);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgSoapHeaderReferencesUnkownPart(String part) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("SOAP header references unknown part: {0}.", part);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgBindingDefinesNonElementDocListParts() {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Binding defines non-element document literal 
part(s)");
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgUnexpectedElementInSOAPBody(QName name, QName 
elementName) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Unexpected element in SOAP body: message {0} 
element {1}.", name, elementName);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgSOAPBodyDoesNotContainAllRequiredParts() {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("SOAP body does not contain all required parts");
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgSOAPBodyDoesNotContainRequiredPart(String name) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("SOAP body does not contain required part: {0}.", 
name);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgSoapHeaderMissingRequiredElement(QName elementType) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("SOAP header missing required element: {0}.", 
elementType);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgBindingOutputNotFound(QName serviceName, String 
portName, String name) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Binding output not found: service {0} port {1} name 
{2}.", serviceName, portName, name);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgUndefinedFault(QName serviceName, String portName, 
String name, QName faultName) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Undefined fault: service {0} port {1} name {2} 
fault {3}.", serviceName, portName, name, faultName);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgOdeMessagePartMissingRequiredElement(QName 
serviceName, String portName, String name, QName elementName) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("Message part is missing required element: service 
{0} port {1} name {2} element {3}.",
+                          serviceName, portName, name, elementName);
+        return new IllegalArgumentException(s);
     }
 
     public Throwable msgSoapBodyDoesNotContainExpectedPartWrapper(QName 
serviceName, String portName, QName rpcWrapQName) {
-        // TODO Auto-generated method stub
-        return null;
+        String s = format("SOAP body does not contain expected part wrapper: 
service {0} port {1} wrapper {2}",
+                          serviceName, portName, rpcWrapQName);
+        return new IllegalArgumentException(s);
     }
 
 }

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEService.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEService.java?view=diff&rev=506618&r1=506617&r2=506618
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEService.java 
(original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEService.java 
Mon Feb 12 12:26:01 2007
@@ -84,7 +84,7 @@
         _serviceRef = 
EndpointFactory.convertToWSA(createServiceRef(genEPRfromWSDL(_wsdlDef, 
serviceName, portName)));
         _converter = new 
SoapMessageConverter(OMAbstractFactory.getSOAP11Factory(), def, serviceName, 
portName,
                 _isReplicateEmptyNS);
-        
+
     }
 
     public void onAxisMessageExchange(MessageContext msgContext, 
MessageContext outMsgContext, SOAPFactory soapFactory)
@@ -127,9 +127,9 @@
                 success = false;
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            __log.error("Exception occured while invoking ODE", e);
             success = false;
-            throw new AxisFault("An exception occured when invoking ODE.", e);
+            throw new OdeFault("An exception occured when invoking ODE.", e);
         } finally {
             if (success) {
                 __log.debug("Commiting ODE MEX " + odeMex);
@@ -137,7 +137,7 @@
                     if (__log.isDebugEnabled()) __log.debug("Commiting 
transaction.");
                     _txManager.commit();
                 } catch (Exception e) {
-                    __log.error("COMMIT FAILED!", e);
+                    __log.error("Commit failed", e);
                     success = false;
                 }
             }
@@ -146,7 +146,7 @@
                 try {
                     _txManager.rollback();
                 } catch (Exception e) {
-                    throw new AxisFault("ROLLBACK FAILED!", e);
+                    throw new OdeFault("Rollback failed", e);
                 }
             }
 
@@ -179,29 +179,31 @@
                             if (__log.isDebugEnabled()) __log.debug("Starting 
transaction.");
                             _txManager.begin();
                         } catch (Exception ex) {
-                            throw new AxisFault("Error starting transaction!", 
ex);
+                            throw new OdeFault("Error starting transaction!", 
ex);
                         }
                         try {
                             onResponse(odeMex, outMsgContext);
                             commit = true;
                         } catch (AxisFault af) {
+                            __log.error("Error processing response for MEX " + 
odeMex, af);
                             commit = true;
                             throw af;
                         } catch (Exception e) {
-                            throw new AxisFault("An exception occured when 
invoking ODE.", e);
+                            __log.error("Error processing response for MEX " + 
odeMex, e);
+                            throw new OdeFault("An exception occured when 
invoking ODE.", e);
                         } finally {
                             if (commit)
                                 try {
                                     if (__log.isDebugEnabled()) 
__log.debug("Comitting transaction.");
                                     _txManager.commit();
                                 } catch (Exception e) {
-                                    throw new AxisFault("Commit failed!", e);
+                                    throw new OdeFault("Commit failed!", e);
                                 }
                             else
                                 try {
                                     _txManager.rollback();
                                 } catch (Exception ex) {
-                                    throw new AxisFault("Rollback failed!", 
ex);
+                                    throw new OdeFault("Rollback failed!", ex);
                                 }
 
                         }
@@ -210,7 +212,7 @@
             }
         }
         if (!success)
-            throw new AxisFault("Message was either unroutable or timed out!");
+            throw new OdeFault("Message was either unroutable or timed out!");
     }
 
     public void notifyResponse(MyRoleMessageExchange mex) {
@@ -234,25 +236,25 @@
     private void onResponse(MyRoleMessageExchange mex, MessageContext 
msgContext) throws AxisFault {
         switch (mex.getStatus()) {
             case FAULT:
-                if (__log.isDebugEnabled()) 
+                if (__log.isDebugEnabled())
                     __log.debug("Generated FAULT response message: " +
                         mex.getFault());
-                throw new AxisFault(new QName(null,"Server"),
+                throw new AxisFault(mex.getFault(),
                         mex.getFaultExplanation(), null, null,
                         
_converter.createSoapFault(mex.getFaultResponse().getMessage(), mex.getFault(), 
mex.getOperation()));
             case ASYNC:
             case RESPONSE:
                 _converter.createSoapResponse(msgContext.getEnvelope(), 
mex.getResponse().getMessage(),
                         mex.getOperation());
-                if (__log.isDebugEnabled()) 
+                if (__log.isDebugEnabled())
                     __log.debug("Generated response message " +
                         msgContext.getEnvelope());
                 writeHeader(msgContext, mex);
                 break;
             case FAILURE:
-                throw new AxisFault("Message exchange failure!");
+                throw new OdeFault("Message exchange failure");
             default:
-                __log.warn("Received ODE message exchange in unexpected state: 
" + mex.getStatus());
+                throw new OdeFault("Received ODE message exchange in 
unexpected state: " + mex.getStatus());
         }
     }
 
@@ -347,7 +349,7 @@
 
     /**
      * Get the EPR of this service from the WSDL.
-     * 
+     *
      * @param name
      *            service name
      * @param portName
@@ -386,7 +388,7 @@
 
     /**
      * Create-and-copy a service-ref element.
-     * 
+     *
      * @param elmt
      * @return wrapped element
      */

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/P2PMexContextImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/P2PMexContextImpl.java?view=diff&rev=506618&r1=506617&r2=506618
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/P2PMexContextImpl.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/P2PMexContextImpl.java
 Mon Feb 12 12:26:01 2007
@@ -88,8 +88,8 @@
         if (__log.isDebugEnabled())
             __log.debug("Received Async reply to " + myRoleMex);
 
-        // Note that when we created the MyRoleMessageExchange, we gave the 
PartnerRoleMex Id 
-        // as the client id. 
+        // Note that when we created the MyRoleMessageExchange, we gave the 
PartnerRoleMex Id
+        // as the client id.
         PartnerRoleMessageExchange pmex = myRoleMex.getClientId() == null ? 
null : _waiters.remove(myRoleMex.getClientId());
         if (pmex == null) {
             if (__log.isDebugEnabled())
@@ -98,10 +98,10 @@
             return;
         }
 
-        
+
         if (__log.isDebugEnabled())
             __log.debug("for async reply, found matching P2P Partner Mex " + 
pmex);
-        
+
         handleResponse(pmex, myRoleMex);
 
     }
@@ -114,19 +114,19 @@
                 target.getServiceName(), pmex.getOperationName());
 
         if(__log.isDebugEnabled())
-            __log.debug("Invoking (P2P) service " + odeMex.getServiceName() + 
" with operation " +  
+            __log.debug("Invoking (P2P) service " + odeMex.getServiceName() + 
" with operation " +
                     odeMex.getOperationName());
 
         copyHeader(pmex, odeMex);
 
-        
+
         odeMex.invoke(pmex.getRequest());
-        
+
         if (__log.isDebugEnabled())
-            __log.debug("invoke of (P2P) service " + odeMex.getServiceName() + 
" with operation " +  
+            __log.debug("Invoked (P2P) service " + odeMex.getServiceName() + " 
with operation " +
                     odeMex.getOperationName() + "; MyRoleMex status = " + 
odeMex.getStatus());
 
-        
+
         if (odeMex.getStatus() != MessageExchange.Status.ASYNC) {
             if (__log.isDebugEnabled())
                 __log.debug("invoke of P2P service did not result in ASYNC 
state, removing waiter for " + pmex);

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java?view=diff&rev=506618&r1=506617&r2=506618
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
 Mon Feb 12 12:26:01 2007
@@ -25,6 +25,7 @@
 import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.MessageReceiver;
+import org.apache.ode.axis2.OdeFault;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Operation;
@@ -94,7 +95,7 @@
     String url = null;
     Service service = wsdlDefinition.getService(wsdlServiceName);
     if (service == null) {
-      throw new AxisFault("Unable to find service " + wsdlServiceName + " from 
service WSDL definition " + wsdlDefinition.getDocumentBaseURI());
+      throw new OdeFault("Unable to find service " + wsdlServiceName + " from 
service WSDL definition " + wsdlDefinition.getDocumentBaseURI());
     }
     Port port = service.getPort(portName);
     for (Object oext : port.getExtensibilityElements()) {
@@ -102,12 +103,12 @@
         url = ((SOAPAddress)oext).getLocationURI();
     }
     if (url == null) {
-      throw new AxisFault("Could not extract any soap:address from service 
WSDL definition " + wsdlServiceName +
+      throw new OdeFault("Could not extract any soap:address from service WSDL 
definition " + wsdlServiceName +
               " (necessary to establish the process target address)!");
     }
     String serviceName = parseURLForService(url);
     if (serviceName == null) {
-      throw new AxisFault("The soap:address used for service WSDL definition " 
+ wsdlServiceName +
+      throw new OdeFault("The soap:address used for service WSDL definition " 
+ wsdlServiceName +
               " and port " + portName + " should be of the form 
http://hostname:port/ode/processes/myProcessEndpointName";);
     }
     return serviceName;

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java?view=diff&rev=506618&r1=506617&r2=506618
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
 Mon Feb 12 12:26:01 2007
@@ -19,6 +19,25 @@
 
 package org.apache.ode.axis2.service;
 
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.activation.DataHandler;
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
@@ -34,6 +53,7 @@
 import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ode.axis2.OdeFault;
 import org.apache.ode.axis2.deploy.DeploymentPoller;
 import org.apache.ode.axis2.hooks.ODEAxisService;
 import org.apache.ode.axis2.util.OMUtils;
@@ -109,7 +129,7 @@
                     OMElement zip = zipPart.getFirstElement();
                     if (!zipPart.getQName().getLocalPart().equals("package") ||
                             !zip.getQName().getLocalPart().equals("zip"))
-                        throw new AxisFault("Your message should contain a 
part named 'package' with a zip element");
+                        throw new OdeFault("Your message should contain a part 
named 'package' with a zip element");
 
                     OMText binaryNode = (OMText) zip.getFirstOMChild();
                     binaryNode.setOptimize(true);
@@ -126,7 +146,7 @@
                         // Check that we have a deploy.xml
                         File deployXml = new File(dest, "deploy.xml");
                         if (!deployXml.exists())
-                            throw new AxisFault("The deployment doesn't appear 
to contain a deployment " +
+                            throw new OdeFault("The deployment doesn't appear 
to contain a deployment " +
                                     "descriptor in its root directory named 
deploy.xml, aborting.");
 
                         Collection<QName> deployed = _store.deploy(dest);
@@ -161,7 +181,7 @@
                     String pkg = part.getText();
                     File deploymentDir = new File(_deployPath, pkg);
                     if (!deploymentDir.exists())
-                        throw new AxisFault("Couldn't find deployment package 
" + pkg + " in directory " + _deployPath);
+                        throw new OdeFault("Couldn't find deployment package " 
+ pkg + " in directory " + _deployPath);
 
                     try {
                         // We're going to create a directory under the 
deployment root and put
@@ -205,7 +225,7 @@
                     OMElement qnamePart = 
messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
                     ProcessConf process = 
_store.getProcessConfiguration(OMUtils.getTextAsQName(qnamePart));
                     if (process == null) {
-                       throw new AxisFault("Could not find process: " + 
qnamePart.getTextAsQName());                           
+                       throw new OdeFault("Could not find process: " + 
qnamePart.getTextAsQName());
                     }
                     String packageName = 
_store.getProcessConfiguration(OMUtils.getTextAsQName(qnamePart)).getPackage();
                     OMElement response = 
factory.createOMElement("packageName", null);
@@ -217,9 +237,9 @@
                 Throwable source = t;
                 while (source.getCause() != null && source.getCause() != 
source) source = source.getCause();
                 __log.warn("Invocation of operation " + operation + " failed", 
t);
-                throw new AxisFault("Invocation of operation " + operation + " 
failed: " + source.toString(), t);
+                throw new OdeFault("Invocation of operation " + operation + " 
failed: " + source.toString(), t);
             }
-            if (unknown) throw new AxisFault("Unknown operation: '"
+            if (unknown) throw new OdeFault("Unknown operation: '"
                     + messageContext.getAxisOperation().getName() + "'");
         }
 
@@ -248,7 +268,7 @@
                 }
                 zis.close();
             } catch (IOException e) {
-                throw new AxisFault("An error occured on deployment.", e);
+                throw new OdeFault("An error occured on deployment.", e);
             }
         }
 

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java?view=diff&rev=506618&r1=506617&r2=506618
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
 Mon Feb 12 12:26:01 2007
@@ -33,6 +33,7 @@
 import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ode.axis2.OdeFault;
 import org.apache.ode.axis2.hooks.ODEAxisService;
 import org.apache.ode.axis2.util.OMUtils;
 import org.apache.ode.bpel.engine.ProcessAndInstanceManagementImpl;
@@ -78,7 +79,7 @@
         try {
             WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
             wsdlReader.setFeature("javax.wsdl.verbose", false);
-            
+
             def = wsdlReader.readWSDL(rootpath + "/pmapi.wsdl");
             AxisService processService = ODEAxisService.createService(
                     axisConfig, new QName("http://www.apache.org/ode/pmapi";, 
"ProcessManagementService"),
@@ -127,9 +128,9 @@
                 engine.send(outMsgContext);
             }
         } catch (IllegalAccessException e) {
-            throw new AxisFault("Couldn't invoke method named " + methodName + 
" in management interface!", e);
+            throw new OdeFault("Couldn't invoke method named " + methodName + 
" in management interface!", e);
         } catch (InvocationTargetException e) {
-            throw new AxisFault("Invocation of method " + methodName + " in 
management interface failed!", e);
+            throw new OdeFault("Invocation of method " + methodName + " in 
management interface failed!", e);
         }
     }
 
@@ -178,17 +179,17 @@
                 return beanFactory.getMethod("parse", XMLStreamReader.class)
                         .invoke(elmt.getXMLStreamReaderWithoutCaching());
             } catch (ClassNotFoundException e) {
-                throw new AxisFault("Couldn't find class " + 
clazz.getCanonicalName() + ".Factory to instantiate xml bean", e);
+                throw new OdeFault("Couldn't find class " + 
clazz.getCanonicalName() + ".Factory to instantiate xml bean", e);
             } catch (IllegalAccessException e) {
-                throw new AxisFault("Couldn't access class " + 
clazz.getCanonicalName() + ".Factory to instantiate xml bean", e);
+                throw new OdeFault("Couldn't access class " + 
clazz.getCanonicalName() + ".Factory to instantiate xml bean", e);
             } catch (InvocationTargetException e) {
-                throw new AxisFault("Couldn't access xml bean parse method on 
class " + clazz.getCanonicalName() + ".Factory " +
+                throw new OdeFault("Couldn't access xml bean parse method on 
class " + clazz.getCanonicalName() + ".Factory " +
                         "to instantiate xml bean", e);
             } catch (NoSuchMethodException e) {
-                throw new AxisFault("Couldn't find xml bean parse method on 
class " + clazz.getCanonicalName() + ".Factory " +
+                throw new OdeFault("Couldn't find xml bean parse method on 
class " + clazz.getCanonicalName() + ".Factory " +
                         "to instantiate xml bean", e);
             }
-        } else throw new AxisFault("Couldn't use element " + elmt + " to 
obtain a management method parameter.");
+        } else throw new OdeFault("Couldn't use element " + elmt + " to obtain 
a management method parameter.");
     }
 
     private static OMElement convertToOM(SOAPFactory soapFactory, Object obj) 
throws AxisFault {
@@ -196,7 +197,7 @@
             try {
                 return new 
StAXOMBuilder(((XmlObject)obj).newInputStream()).getDocumentElement();
             } catch (XMLStreamException e) {
-                throw new AxisFault("Couldn't serialize result to an outgoing 
messages.", e);
+                throw new OdeFault("Couldn't serialize result to an outgoing 
messages.", e);
             }
         } else if (obj instanceof List) {
             OMElement listElmt = soapFactory.createOMElement("list", null);
@@ -206,7 +207,7 @@
                 listElmt.addChild(stuffElmt);
             }
             return listElmt;
-        } else throw new AxisFault("Couldn't convert object " + obj + " into a 
response element.");
+        } else throw new OdeFault("Couldn't convert object " + obj + " into a 
response element.");
     }
 
     private static boolean hasResponse(AxisOperation op) {
@@ -237,7 +238,7 @@
         for (Method method : clazz.getMethods()) {
             if (method.getName().equals(methodName)) return method;
         }
-        throw new AxisFault("Couldn't find any method named " + methodName + " 
in interface " + clazz.getName());
+        throw new OdeFault("Couldn't find any method named " + methodName + " 
in interface " + clazz.getName());
     }
 
     private static Object parseType(Class clazz, String str) {

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java?view=diff&rev=506618&r1=506617&r2=506618
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
 Mon Feb 12 12:26:01 2007
@@ -52,6 +52,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.axis2.Messages;
+import org.apache.ode.axis2.OdeFault;
 import org.apache.ode.utils.DOMUtils;
 import org.apache.ode.utils.stl.CollectionsX;
 import org.w3c.dom.Element;
@@ -59,9 +60,9 @@
 /**
  * SOAP/ODE Message converter. Uses WSDL binding information to convert the 
protocol-neutral ODE representation into a SOAP
  * representation and vice versa.
- * 
+ *
  * @author Maciej Szefler ( m s z e f l e r (at) g m a i l . c o m )
- * 
+ *
  */
 public class SoapMessageConverter {
 
@@ -106,20 +107,20 @@
 
         _serviceDef = _def.getService(serviceName);
         if (_serviceDef == null)
-            throw new 
AxisFault(__msgs.msgServiceDefinitionNotFound(serviceName));
+            throw new 
OdeFault(__msgs.msgServiceDefinitionNotFound(serviceName));
         _port = _serviceDef.getPort(portName);
         if (_port == null)
-            throw new AxisFault(__msgs.msgPortDefinitionNotFound(serviceName, 
portName));
+            throw new OdeFault(__msgs.msgPortDefinitionNotFound(serviceName, 
portName));
         _binding = _port.getBinding();
         if (_binding == null)
-            throw new AxisFault(__msgs.msgBindingNotFound(serviceName, 
portName));
+            throw new OdeFault(__msgs.msgBindingNotFound(serviceName, 
portName));
 
 
         Collection<SOAPBinding> soapBindings = 
CollectionsX.filter(_binding.getExtensibilityElements(), SOAPBinding.class);
         if (soapBindings.isEmpty())
-            throw new AxisFault(__msgs.msgNoSOAPBindingForPort(_portName));
+            throw new OdeFault(__msgs.msgNoSOAPBindingForPort(_portName));
         else if (soapBindings.size() > 1) {
-            throw new 
AxisFault(__msgs.msgMultipleSoapBindingsForPort(_portName));
+            throw new 
OdeFault(__msgs.msgMultipleSoapBindingsForPort(_portName));
         }
 
         _soapBinding = (SOAPBinding) soapBindings.iterator().next();
@@ -139,11 +140,11 @@
         BindingOperation bop = _binding.getBindingOperation(op.getName(), 
null, null);
 
         if (bop == null)
-            throw new 
AxisFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, 
op.getName()));
+            throw new 
OdeFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, 
op.getName()));
 
         BindingInput bi = bop.getBindingInput();
         if (bi == null)
-            throw new AxisFault(__msgs.msgBindingInputNotFound(_serviceName, 
_portName, op.getName()));
+            throw new OdeFault(__msgs.msgBindingInputNotFound(_serviceName, 
_portName, op.getName()));
 
         List<SOAPHeader> soapHeaders = getSOAPHeaders(bi);
         for (SOAPHeader sh : soapHeaders)
@@ -156,7 +157,7 @@
                     : soapEnv.getBody();
             createSoapBody(sb, soapBody, op.getInput().getMessage(), message, 
op.getName());
         }
-        
+
     }
 
     public void createSoapResponse(SOAPEnvelope soapEnv, Element message, 
Operation op) throws AxisFault {
@@ -170,23 +171,23 @@
         BindingOperation bop = 
_binding.getBindingOperation(op.getName(),null,null);
 
         if (bop == null)
-            throw new 
AxisFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, 
op.getName()));
+            throw new 
OdeFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, 
op.getName()));
 
         BindingOutput bo = bop.getBindingOutput();
         if (bo == null)
-            throw new AxisFault(__msgs.msgBindingOutputNotFound(_serviceName, 
_portName, op.getName()));
+            throw new OdeFault(__msgs.msgBindingOutputNotFound(_serviceName, 
_portName, op.getName()));
 
         List<SOAPHeader> soapHeaders = getSOAPHeaders(bo);
         for (SOAPHeader sh : soapHeaders)
-            createSoapHeader(soapEnv, sh, op.getInput().getMessage(), message);
+            createSoapHeader(soapEnv, sh, op.getOutput().getMessage(), 
message);
 
         SOAPBody soapBody = getSOAPBody(bo);
         if (soapBody != null) {
             org.apache.axiom.soap.SOAPBody sb = soapEnv.getBody() == null ? 
_soapFactory.createSOAPBody(soapEnv) : soapEnv.getBody();
-            createSoapBody(sb, soapBody, op.getInput().getMessage(), message, 
op.getName() + "Response");
+            createSoapBody(sb, soapBody, op.getOutput().getMessage(), message, 
op.getName() + "Response");
         }
-        
-        
+
+
     }
 
     @SuppressWarnings("unchecked")
@@ -195,26 +196,26 @@
 
         if (headerdef.getPart() == null)
             return;
-        
+
         if (payloadMessageHeader && msgdef.getPart(headerdef.getPart()) == 
null)
-            throw new 
AxisFault(__msgs.msgSoapHeaderReferencesUnkownPart(headerdef.getPart()));
+            throw new 
OdeFault(__msgs.msgSoapHeaderReferencesUnkownPart(headerdef.getPart()));
 
-        Element srcPartEl = DOMUtils.findChildByName(message, new 
QName(payloadMessageHeader 
+        Element srcPartEl = DOMUtils.findChildByName(message, new 
QName(payloadMessageHeader
                 ? null : FOREIGN_HEADER_PART_NS, headerdef.getPart()));
 
         // We don't complain about missing header data unless they are part of 
the message payload. This is
         // because AXIS may be providing these headers.
         if (srcPartEl == null && payloadMessageHeader)
-            throw new 
AxisFault(__msgs.msgOdeMessageMissingRequiredPart(headerdef.getPart()));
-        
+            throw new 
OdeFault(__msgs.msgOdeMessageMissingRequiredPart(headerdef.getPart()));
+
         if (srcPartEl == null)
             return;
-        
+
         org.apache.axiom.soap.SOAPHeader soaphdr = soapEnv.getHeader();
         if (soaphdr == null) {
             soaphdr = _soapFactory.createSOAPHeader(soapEnv);
         }
-        
+
         OMElement omPart = OMUtils.toOM(srcPartEl, _soapFactory);
         for (Iterator<OMNode> i = omPart.getChildren(); i.hasNext();)
             soaphdr.addChild(i.next());
@@ -223,22 +224,22 @@
 
     public OMElement createSoapFault(Element message, QName faultName, 
Operation op) throws AxisFault {
         if (faultName.getNamespaceURI() == null || 
!faultName.getNamespaceURI().equals(_def.getTargetNamespace()))
-            throw new AxisFault(__msgs.msgUndefinedFault(_serviceName, 
_portName, op.getName(), faultName));
+            throw new OdeFault(__msgs.msgUndefinedFault(_serviceName, 
_portName, op.getName(), faultName));
         Fault f = op.getFault(faultName.getLocalPart());
         if (f == null)
-            throw new AxisFault(__msgs.msgUndefinedFault(_serviceName, 
_portName, op.getName(), faultName));
-        
-        // For faults, there will be exactly one part. 
+            throw new OdeFault(__msgs.msgUndefinedFault(_serviceName, 
_portName, op.getName(), faultName));
+
+        // For faults, there will be exactly one part.
         Part p = (Part)f.getMessage().getParts().values().iterator().next();
         Element partEl= 
DOMUtils.getFirstChildElement(DOMUtils.findChildByName(message,new 
QName(null,p.getName())));
         if (partEl == null)
-            throw new 
AxisFault(__msgs.msgOdeMessageMissingRequiredPart(p.getName()));
+            throw new 
OdeFault(__msgs.msgOdeMessageMissingRequiredPart(p.getName()));
         if (p == null)
-            throw new AxisFault(new IllegalStateException("fault part is 
non-element" + p.getName()));
+            throw new OdeFault(new IllegalStateException("fault part is 
non-element" + p.getName()));
         Element detail = DOMUtils.findChildByName(partEl, p.getElementName());
         if (detail == null)
-            throw new 
AxisFault(__msgs.msgOdeMessagePartMissingRequiredElement(_serviceName, 
_portName, op.getName(), p.getElementName()));
-        
+            throw new 
OdeFault(__msgs.msgOdeMessagePartMissingRequiredElement(_serviceName, 
_portName, op.getName(), p.getElementName()));
+
         return OMUtils.toOM(detail, _soapFactory);
    }
 
@@ -246,11 +247,11 @@
         BindingOperation bop = _binding.getBindingOperation(op.getName(), 
null, null);
 
         if (bop == null)
-            throw new 
AxisFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, 
op.getName()));
-        
+            throw new 
OdeFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, 
op.getName()));
+
         BindingInput bi = bop.getBindingInput();
         if (bi == null)
-            throw new AxisFault(__msgs.msgBindingInputNotFound(_serviceName, 
_portName, op.getName()));
+            throw new OdeFault(__msgs.msgBindingInputNotFound(_serviceName, 
_portName, op.getName()));
 
         SOAPBody soapBody = getSOAPBody(bi);
         if (soapBody != null)
@@ -266,11 +267,11 @@
         BindingOperation bop = _binding.getBindingOperation(op.getName(), 
null, null);
 
         if (bop == null)
-            throw new 
AxisFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, 
op.getName()));
+            throw new 
OdeFault(__msgs.msgBindingOperationNotFound(_serviceName, _portName, 
op.getName()));
 
         BindingOutput bo = bop.getBindingOutput();
         if (bo == null)
-            throw new AxisFault(__msgs.msgBindingInputNotFound(_serviceName, 
_portName, op.getName()));
+            throw new OdeFault(__msgs.msgBindingInputNotFound(_serviceName, 
_portName, op.getName()));
 
         SOAPBody soapBody = getSOAPBody(bo);
         if (soapBody != null)
@@ -278,24 +279,24 @@
     }
 
     @SuppressWarnings("unchecked")
-    public void createSoapBody(org.apache.axiom.soap.SOAPBody sb, 
-            SOAPBody soapBody, 
-            Message msgDef, 
+    public void createSoapBody(org.apache.axiom.soap.SOAPBody sb,
+            SOAPBody soapBody,
+            Message msgDef,
             Element message,
             String rpcWrapper) throws AxisFault {
-        
+
         OMElement partHolder;
         if (_isRPC) {
             partHolder = _soapFactory.createOMElement(new 
QName(soapBody.getNamespaceURI(),rpcWrapper), sb);
         } else
-            partHolder = sb; 
+            partHolder = sb;
 
         List<Part> parts = msgDef.getOrderedParts(soapBody.getParts());
 
         for (Part part : parts) {
             Element srcPartEl = DOMUtils.findChildByName(message, new 
QName(null, part.getName()));
             if (srcPartEl == null)
-                throw new 
AxisFault(__msgs.msgOdeMessageMissingRequiredPart(part.getName()));
+                throw new 
OdeFault(__msgs.msgOdeMessageMissingRequiredPart(part.getName()));
 
             OMElement omPart = OMUtils.toOM(srcPartEl, _soapFactory);
             if (_isRPC) {
@@ -320,14 +321,14 @@
             QName rpcWrapQName = new QName(bodyDef.getNamespaceURI(), 
rpcWrapper);
             OMElement partWrapper = 
soapBody.getFirstChildWithName(rpcWrapQName);
             if (partWrapper == null)
-                throw new 
AxisFault(__msgs.msgSoapBodyDoesNotContainExpectedPartWrapper(_serviceName,_portName,rpcWrapQName));
+                throw new 
OdeFault(__msgs.msgSoapBodyDoesNotContainExpectedPartWrapper(_serviceName,_portName,rpcWrapQName));
             // In RPC the body element is the operation name, wrapping parts. 
Order doesn't really matter as far as
             // we're concerned. All we need to do is copy the soap:body 
children, since doc-lit rpc looks the same
             // in ode and soap.
             for (Part pdef : bodyParts) {
                 OMElement srcPart = partWrapper.getFirstChildWithName(new 
QName(null, pdef.getName()));
                 if (srcPart == null)
-                    throw new 
AxisFault(__msgs.msgSOAPBodyDoesNotContainRequiredPart(pdef.getName()));
+                    throw new 
OdeFault(__msgs.msgSOAPBodyDoesNotContainRequiredPart(pdef.getName()));
                 
message.appendChild(message.getOwnerDocument().importNode(OMUtils.toDOM(srcPart),
 true));
             }
 
@@ -337,13 +338,13 @@
             Iterator<OMElement> srcParts = soapBody.getChildElements();
             for (Part partDef : bodyParts) {
                 if (!srcParts.hasNext())
-                    throw new 
AxisFault(__msgs.msgSOAPBodyDoesNotContainRequiredPart(partDef.getName()));
+                    throw new 
OdeFault(__msgs.msgSOAPBodyDoesNotContainRequiredPart(partDef.getName()));
 
                 OMElement srcPart = srcParts.next();
                 if (partDef.getElementName() == null)
-                    throw new 
AxisFault(__msgs.msgBindingDefinesNonElementDocListParts());
+                    throw new 
OdeFault(__msgs.msgBindingDefinesNonElementDocListParts());
                 if (!srcPart.getQName().equals(partDef.getElementName()))
-                    throw new 
AxisFault(__msgs.msgUnexpectedElementInSOAPBody(srcPart.getQName(), 
partDef.getElementName()));
+                    throw new 
OdeFault(__msgs.msgUnexpectedElementInSOAPBody(srcPart.getQName(), 
partDef.getElementName()));
                 Element destPart = 
message.getOwnerDocument().createElementNS(null, partDef.getName());
                 message.appendChild(destPart);
                 
destPart.appendChild(message.getOwnerDocument().importNode(OMUtils.toDOM(srcPart),
 true));
@@ -358,7 +359,7 @@
         boolean requiredHeader = payloadMessageHeader || 
(headerdef.getRequired() != null && headerdef.getRequired() == true);
 
         if (requiredHeader && header == null)
-            throw new 
AxisFault(__msgs.msgSoapHeaderMissingRequiredElement(headerdef.getElementType()));
+            throw new 
OdeFault(__msgs.msgSoapHeaderMissingRequiredElement(headerdef.getElementType()));
 
         if (header == null)
             return;
@@ -369,10 +370,10 @@
         Part p = hdrMsg.getPart(headerdef.getPart());
         if (p == null || p.getElementName() == null)
             return;
-        
+
         OMElement headerEl = header.getFirstChildWithName(p.getElementName());
         if (requiredHeader && headerEl == null)
-            throw new 
AxisFault(__msgs.msgSoapHeaderMissingRequiredElement(headerdef.getElementType()));
+            throw new 
OdeFault(__msgs.msgSoapHeaderMissingRequiredElement(headerdef.getElementType()));
 
         if (headerEl == null)
             return;
@@ -403,7 +404,7 @@
 
     /**
      * Attempts to extract the SOAP Action is defined in the WSDL document.
-     * 
+     *
      * @param def
      * @param service
      * @param port
@@ -427,11 +428,11 @@
         Fault fdef = inferFault(operation, flt);
         if (fdef == null)
             return null;
-        
+
         Part pdef = 
(Part)fdef.getMessage().getParts().values().iterator().next();
         Element partel = 
odeMsgEl.getOwnerDocument().createElementNS(null,pdef.getName());
         odeMsgEl.appendChild(partel);
-        
+
         
partel.appendChild(odeMsgEl.getOwnerDocument().importNode(OMUtils.toDOM(detail),true));
         return new QName(_def.getTargetNamespace(), fdef.getName());
     }
@@ -440,27 +441,25 @@
     private Fault inferFault(Operation operation, SOAPFault flt) {
         if (flt.getDetail() == null)
             return null;
-        
+
         QName elName = flt.getDetail().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;
     }
-
-
 
 }


Reply via email to