向xml_rpc c++服务器发出curl请求

vlurs2pr  于 2023-02-23  发布在  其他
关注(0)|答案(1)|浏览(145)

我正在尝试对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_title函数,如何在xml_request中填写Data信息
设置标题

14ifxucb

14ifxucb1#

我创建了一个文件名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

以下是来自http://xmlrpc.com/specs

相关问题