~loentar/wsf-staff/trunk

« back to all changes in this revision

Viewing changes to staff/axis2/staff_service/src/StaffService.cpp

  • Committer: loentar
  • Date: 2015-02-05 22:41:33 UTC
  • Revision ID: svn-v4:46775792-f812-11dd-b507-8b4ecd5210be:trunk:878
core: added SoapUserFaultException - exception to handle user-defined fault
das: added support for user-defined faults (with attribute user="true")
disabled compiling of unused components

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
#include <staff/utils/CrashHandler.h>
47
47
#include <staff/common/Exception.h>
48
48
#include <staff/common/Operation.h>
 
49
#include <staff/common/DataObject.h>
49
50
#include <staff/common/MessageContext.h>
50
51
#ifndef WITHOUT_SECURITY
51
52
#include <staff/security/tools.h>
137
138
    }
138
139
#endif
139
140
 
 
141
    axutil_param_t* pParam = axis2_svc_get_param(m_pAxis2Svc, pEnv, "Http200OnFault");
 
142
    if (pParam != NULL)
 
143
    {
 
144
      const axis2_char_t* szValue = reinterpret_cast<const axis2_char_t*>(axutil_param_get_value(pParam, pEnv));
 
145
      if (szValue != NULL)
 
146
      {
 
147
        m_bHttp200OnFault = !axutil_strcasecmp(szValue, "true");
 
148
      }
 
149
    }
 
150
 
140
151
    m_pEnv = pEnv;
141
152
    m_pConf = pConf;
142
153
 
297
308
        pServiceWrapper->Invoke(tOperation, sSessionId, sInstanceId);
298
309
      }
299
310
    }
 
311
    catch (const staff::SoapUserFaultException& rEx)
 
312
    {
 
313
      try
 
314
      {
 
315
        staff::DataObject tdoFault;
 
316
        tdoFault.FromString(rEx.GetFault());
 
317
        tOperation.SetUserFault(tdoFault);
 
318
      }
 
319
      catch (...)
 
320
      {
 
321
        tOperation.SetFault("server", "Invalid format of user soap fault",
 
322
                            "Failed to invoke service " + sServiceName
 
323
                            + "." + tOperation.GetName()
 
324
#ifndef WITHOUT_SECURITY
 
325
                            + "#" + sInstanceId + "(" + sSessionId + ")"
 
326
#endif
 
327
                            );
 
328
      }
 
329
    }
 
330
    catch (const staff::SoapFaultException& rEx)
 
331
    {
 
332
      tOperation.SetFault(rEx.GetCode(), rEx.GetString(), rEx.GetDetail());
 
333
    }
300
334
    catch (const std::exception& rEx)
301
335
    {
302
336
      tOperation.SetFault("server", rEx.what(), "Failed to invoke service " + sServiceName
325
359
      AXIS2_ERROR_SET_MESSAGE(pEnv->error, static_cast<axis2_char_t*>(axutil_strdup(pEnv, tOperation.GetFaultString().c_str())));
326
360
      AXIS2_ERROR_SET_ERROR_NUMBER(pEnv->error, static_cast<axutil_error_codes_t>(AXUTIL_ERROR_MAX + 1));
327
361
      AXIS2_ERROR_SET_STATUS_CODE(pEnv->error, AXIS2_FAILURE);
328
 
      return NULL;
 
362
      if (!m_bHttp200OnFault)
 
363
        return NULL;
329
364
    }
330
365
 
331
366
    if(!IsNeedReply(pMsgCtx, pEnv))
388
423
  static const axutil_env_t* m_pEnv; 
389
424
  static axis2_conf* m_pConf;
390
425
  static bool m_bShuttingDown;
 
426
  static bool m_bHttp200OnFault;
391
427
};
392
428
 
393
429
 
406
442
const axutil_env_t* StaffService::m_pEnv = NULL;
407
443
axis2_conf* StaffService::m_pConf = NULL;
408
444
bool StaffService::m_bShuttingDown = false;
 
445
bool StaffService::m_bHttp200OnFault = false;
409
446
 
410
447
/**
411
448
 * Following block distinguish the exposed part of the dll.