为 xml_rpc c++ 服务器发出 curl 请求
Make a curl request for xml_rpc c++ server
我正在尝试为 c++ xml-rpc 服务器发出 curl 请求。经过一番阅读,我开始知道使用 curl 的 xml-rpc 请求将如下所示
curl --connect-timeout 10 -d'
<xml request>
' -H 'Content-type:text/xml' https://<Billing Core server>:<Port>/RPC2
我的情况是
curl --connect-timeout 10 -d'
<xml request>
' -H 'Content-type:text/xml' https://127.0.0.1:40405/RPC2
我不确定如何填写 <xml request>
和 xml_rpc c++ 代码如下所示
class Data {
public:
Data();
~Data();
std::string getTitle() const;
void setTitle(std::string title);
std::string getMessage(std::string name) const;
private:
std::string title;
};
class SetTitle: public xmlrpc_c::method {
public:
SetTitle(Data* data);
void execute(xmlrpc_c::paramList const& paramList, xmlrpc_c::value * const retvalP);
private:
SetTitle(); // Hereby disabled
Data* data;
};
void SetTitle::execute(xmlrpc_c::paramList const& paramList, xmlrpc_c::value * const retvalP) {
string const title(paramList.getString(0));
paramList.verifyEnd(1);
data->setTitle(title);
*retvalP = xmlrpc_c::value_string(title); // XML-RPC void return values are an extension to the protocol and not always available or compatible between languages.
}
serviceRegistry.addMethod("set_title", new SetTitle(data));
如何创建xml_request?我想调用 set_tittle 函数。如何在xml_request
中填写Data
信息
set_title
我创建了一个文件名set_title.xml
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>set_title</methodName>
<params>
<param>
<value>
<string>BhanuKiran</string>
</value>
</param>
</params>
</methodCall>
并做了一个curl request
curl -H "Content-Type: text/xml" -d @set_title.xml -X POST http://127.0.0.1:40405/RPC2 -v
我正在尝试为 c++ xml-rpc 服务器发出 curl 请求。经过一番阅读,我开始知道使用 curl 的 xml-rpc 请求将如下所示
curl --connect-timeout 10 -d'
<xml request>
' -H 'Content-type:text/xml' https://<Billing Core server>:<Port>/RPC2
我的情况是
curl --connect-timeout 10 -d'
<xml request>
' -H 'Content-type:text/xml' https://127.0.0.1:40405/RPC2
我不确定如何填写 <xml request>
和 xml_rpc c++ 代码如下所示
class Data {
public:
Data();
~Data();
std::string getTitle() const;
void setTitle(std::string title);
std::string getMessage(std::string name) const;
private:
std::string title;
};
class SetTitle: public xmlrpc_c::method {
public:
SetTitle(Data* data);
void execute(xmlrpc_c::paramList const& paramList, xmlrpc_c::value * const retvalP);
private:
SetTitle(); // Hereby disabled
Data* data;
};
void SetTitle::execute(xmlrpc_c::paramList const& paramList, xmlrpc_c::value * const retvalP) {
string const title(paramList.getString(0));
paramList.verifyEnd(1);
data->setTitle(title);
*retvalP = xmlrpc_c::value_string(title); // XML-RPC void return values are an extension to the protocol and not always available or compatible between languages.
}
serviceRegistry.addMethod("set_title", new SetTitle(data));
如何创建xml_request?我想调用 set_tittle 函数。如何在xml_request
中填写Data
信息
set_title
我创建了一个文件名set_title.xml
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>set_title</methodName>
<params>
<param>
<value>
<string>BhanuKiran</string>
</value>
</param>
</params>
</methodCall>
并做了一个curl request
curl -H "Content-Type: text/xml" -d @set_title.xml -X POST http://127.0.0.1:40405/RPC2 -v