Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-4207

Multiple responses send by SOAPEventHandler when ServiceValidationException occurs

    XMLWordPrintableJSON

Details

    Description

      When calling a service that was defined as "export=true" and a non-optional parameter is missing, then the SOAP-Response will look like this:

      <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><Response><map-Map>
              <map-Entry>
                  <map-Key>
                      <std-String value="errorMessage"></std-String>
                  </map-Key>
                  <map-Value>
                      <std-String value="Problem processing the service"></std-String>
                  </map-Value>
              </map-Entry>
          </map-Map></Response></soapenv:Body></soapenv:Envelope><?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><Response><map-Map>
              <map-Entry>
                  <map-Key>
                      <std-String value="errorMessage"></std-String>
                  </map-Key>
                  <map-Value>
                      <std-String value="The following required parameter is missing: ..."></std-String>
                  </map-Value>
              </map-Entry>
          </map-Map></Response></soapenv:Body></soapenv:Envelope>
      

      Problem
      =======

      The problem is, that this response is not a valid XML.

      Cause
      =====

      The cause is, that in SOAPEventHandler.invoke() the dispatcher.runSync() throws a ServiceValidationException ("The following required parameter is missing..."). This will be catched by the GenericServiceException-block, a error response will be written to the output stream (via sendError()) and an EventHandlerException will be thrown. This exception will again be catched (this time by the Exception-block and another error response will be written to the output stream.

      Solution
      ========

      I think the best solution is simply not to call sendError in the GenericServiceException-block. Then the response will look like this:

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
         <soapenv:Body>
            <Response>
               <map-Map>
                  <map-Entry>
                     <map-Key>
                        <std-String value="errorMessage"/>
                     </map-Key>
                     <map-Value>
                        <std-String value="The following required parameter is missing: ..."/>
                     </map-Value>
                  </map-Entry>
               </map-Map>
            </Response>
         </soapenv:Body>
      </soapenv:Envelope>
      

      Attachments

        1. SOAPEventHandler.diff
          0.5 kB
          Michael Reichenbach

        Activity

          People

            jleroux Jacques Le Roux
            reichemi Michael Reichenbach
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 0.25h
                0.25h
                Remaining:
                Remaining Estimate - 0.25h
                0.25h
                Logged:
                Time Spent - Not Specified
                Not Specified