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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Am I correct in thinking that there is currently no way of sending a fault response back?
David
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.
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
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
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
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