Menu

Fault response

Help
2003-02-13
2003-03-31
  • David Monahan

    David Monahan - 2003-02-13

    Am I correct in thinking that there is currently no way of sending a fault response back?

    David

     
    • Chris Morley

      Chris Morley - 2003-02-13

      The method XmlRpcServerConnection::executeRequest() will generate a fault response if the requested method is not found, but there isn't any way to have a given method return one.

      Overriding executeRequest() in a subclass would allow you to do what ever you wanted with it though.
      Note that if you do subclass XmlRpcServerConnection, you will also have to subclass XmlRpcServer and override XmlRpcServer::createConnection(int) in order to use your new connection class.

       
    • Chris Morley

      Chris Morley - 2003-03-05

      In cvs now, if your server method throws an XmlRpcFaultException(string msg, int code), a fault response will be returned with the specified message and error code.
      Look for a release within a week.

      Chris

       
    • Mark Cooper

      Mark Cooper - 2003-03-27

      I think you meant to say, throw an XmlRpcException? There is no XmlRpcFaultException.

      Also, when I throw this exception I call:

      throw new XmlRpcException(string("My String"), 1);

      ...I get an error "MSCRTD! _CxxThrowException@8".
      Any idea what's happening? Maybe you could include an example in your test code.

      Thanks a lot,
      Mark

       
      • Chris Morley

        Chris Morley - 2003-03-27

        Yes, that comment referred to a pre-release cvs snapshot of the code. I changed it before the last release (FaultException sounded redundant).

        The error you get may be caused by not compiling all of the code (yours and XmlRpc++) with C++ exception handling enabled (/GX switch). You should probably also have run time type info (/GR) enabled.

        More likely, though, it is because the exception your code throws is not being caught, so the runtime is exiting with an error. Note that XmlRpcServerConnection::executeRequest() is catching this:
        catch (const XmlRpcException& fault)
        while you are throwing this:
        throw XmlRpcException*

        Those are different types, and the exception blows right past the catch. In general its a bad idea to throw dynamically allocated data unless your catch is written to delete it. Meyers More Effective C++ has a good discussion on what types to throw and catch. Try:

        throw XmlRpcException("...");

        There are examples of throws in XmlRpcValue.cpp, and examples of processing fault responses in test/HelloClient.cpp (search for "no such method").

        Chris

         
    • Mark Cooper

      Mark Cooper - 2003-03-31

      Cool thanks, the problem was I shouldn't be (as you said) calling:

      throw new XmlRpcException(...);

      Instead:

      throw XmlRpcException(...);

      clearly I'm a little weak in my C++... ;)

      Thanks!
      -Mark

       

Log in to post a comment.