xmlrpc_srv.cpp

Go to the documentation of this file.
00001 
00002  //
00003  // XMLStorage XML-RPC server extension
00004  //
00005  // Copyright (c) 2009 Martin Fuchs <martin-fuchs@gmx.net>
00006  //
00007 
00008 
00009 /*
00010 
00011   All rights reserved.
00012 
00013   Redistribution and use in source and binary forms, with or without
00014   modification, are permitted provided that the following conditions are met:
00015 
00016   * Redistributions of source code must retain the above copyright
00017     notice, this list of conditions and the following disclaimer.
00018   * Redistributions in binary form must reproduce the above copyright
00019     notice, this list of conditions and the following disclaimer in
00020     the documentation and/or other materials provided with the
00021     distribution.
00022 
00023   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00027   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00029   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00030   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00031   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00032   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033   POSSIBILITY OF SUCH DAMAGE.
00034 
00035 */
00036 
00037 #include "httpsrv.h"
00038 
00039 
00040 XMLRPCRequest::XMLRPCRequest(const string& xml_str)
00041  :  XMLRPCParser(xml_str, "methodCall")
00042 {
00043     if (_pos.go_down("methodName")) {
00044         _method_name = _pos->get_content();
00045         _pos.back();
00046     }
00047 
00048     if (_pos.go_down("params")) {
00049         // We are now prepared to call the get_int/double/string/...() functions
00050     }
00051 }
00052 
00053 
00054 void XMLRPCResponse::init()
00055 {
00056     _writer.create("methodResponse");
00057 
00058     // The <methodResponse> tag is closed in XMLRPCWriter::flush().
00059 }
00060 
00061 void XMLRPCResponse::set_failure(int code, const string& message)
00062 {
00063     XMLRPCStruct members;
00064 
00065     members["faultCode"] = (XS_String)XMLInt(code);
00066     members["faultString"] = message;
00067 
00068     write_struct(members, "fault");
00069 }