svn commit: r1088047 - in /ofbiz/trunk/framework: service/config/service.properties webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1088047 - in /ofbiz/trunk/framework: service/config/service.properties webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java

jleroux@apache.org
Author: jleroux
Date: Sat Apr  2 15:23:40 2011
New Revision: 1088047

URL: http://svn.apache.org/viewvc?rev=1088047&view=rev
Log:
Completes https://issues.apache.org/jira/browse/OFBIZ-4218

Keeps the secure idea but enhance when working in a secure environment (VPN, local network, etc.) to return a comprehensive response. Depends on the secureSoapAnswer property in service.properties, true by default

Modified:
    ofbiz/trunk/framework/service/config/service.properties
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java

Modified: ofbiz/trunk/framework/service/config/service.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/config/service.properties?rev=1088047&r1=1088046&r2=1088047&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/config/service.properties (original)
+++ ofbiz/trunk/framework/service/config/service.properties Sat Apr  2 15:23:40 2011
@@ -21,3 +21,5 @@
 servicedispatcher.servicedebugmode=true
 # flag to automatically export all services: same of setting export="true" for all service definitions
 remotedispatcher.exportall=false
+# complete answer from SOAP WSDL or only brief message "Problem processing the service" for security reason
+secureSoapAnswer=true

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java?rev=1088047&r1=1088046&r2=1088047&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java Sat Apr  2 15:23:40 2011
@@ -23,6 +23,7 @@ import java.io.OutputStream;
 import java.io.StringReader;
 import java.io.Writer;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import javax.servlet.ServletContext;
@@ -46,12 +47,14 @@ import org.apache.axiom.soap.SOAPFactory
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilGenerics;
+import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ModelService;
+import org.ofbiz.service.ServiceUtil;
 import org.ofbiz.service.engine.SoapSerializer;
 import org.ofbiz.webapp.control.ConfigXMLReader.Event;
 import org.ofbiz.webapp.control.ConfigXMLReader.RequestMap;
@@ -195,9 +198,17 @@ public class SOAPEventHandler implements
                 createAndSendSOAPResponse(serviceResults, serviceName, response);
 
             } catch (GenericServiceException e) {
-                sendError(response, "Problem processing the service");
-                Debug.logError(e, module);
-                return null;
+                if (UtilProperties.getPropertyAsBoolean("service", "secureSoapAnswer", true)) {
+                    sendError(response, "Problem processing the service, check your parameters.");
+                } else {
+                    if(e.getMessageList() == null) {
+                        sendError(response, e.getMessage());
+                    } else {
+                        sendError(response, e.getMessageList());
+                    }
+                    Debug.logError(e, module);
+                    return null;
+                }
             }
         } catch (Exception e) {
             sendError(response, e.getMessage());
@@ -245,7 +256,7 @@ public class SOAPEventHandler implements
             // instead, create the xmlns attribute directly:
             OMAttribute defaultNS = factory.createOMAttribute("xmlns", null, ModelService.TNS);
             resService.addAttribute(defaultNS);
-            
+
             // log the response message
             if (Debug.verboseOn()) {
                 try {
@@ -263,12 +274,18 @@ public class SOAPEventHandler implements
     }
 
     private void sendError(HttpServletResponse res, String errorMessage) throws EventHandlerException {
+        // setup the response
+        sendError(res, ServiceUtil.returnError(errorMessage));
+    }
+
+    private void sendError(HttpServletResponse res, List<String> errorMessages) throws EventHandlerException {
+        sendError(res, ServiceUtil.returnError(errorMessages));
+    }
+    private void sendError(HttpServletResponse res, Object object) throws EventHandlerException {
         try {
             // setup the response
             res.setContentType("text/xml");
-            Map<String, Object> results = FastMap.newInstance();
-            results.put("errorMessage", errorMessage);
-            String xmlResults= SoapSerializer.serialize(results);
+            String xmlResults= SoapSerializer.serialize(object);
             XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlResults));
             StAXOMBuilder resultsBuilder = new StAXOMBuilder(xmlReader);
             OMElement resultSer = resultsBuilder.getDocumentElement();