[Solved:Change to Synapse][Ask] Indy 10 XMLRPC client lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Mujie · 2010-10-18 12:46 Hi, I'm trying to make a XML-RPC server with a simple XML-RPC client using IXR (The Incutio XML-RPC Library for PHP). A simple XML server is successfully to run, as well as a XML client. Server with IXR : Code: PHP  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 'addTwoNumbers'));?>  Client with IXR : Code: PHP  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i query('demo.addTwoNumbers', '100', '26')) {  die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());} echo '
';print_r($client->getResponse());echo '
';?>  Client without IXR : Code: PHP  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i array('method' => "POST",'header' => "Content-Type: text/xml\r\nUser-Agent: PHPRPC/1.0\r\n",'content' => $request))); $server = 'hxxp://localhost/xmlrpc/xmlrpc-server.php';$file = file_get_contents($server, false, $context);$response = xmlrpc_decode($file);echo '
'.$response.'
';?>  The result from client side is "126"; My question is, how use Indy 10 to build desktop client side as code describe above, parse it and show the result? I try with code below, but no luck Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i use .... IdHTTP, ........procedure TForm1.Button1Click(Sender: TObject);var  lHTTP: TIdHTTP;  lParamList: TStringList;  Result: String; begin  lHTTP := TIdHTTP.Create(nil);  lHTTP.Request.ContentType := 'text/xml';  lHTTP.Request.Accept := '*/*';  lHTTP.Request.Connection := 'Keep-Alive';  lHTTP.Request.Method := 'POST';  lParamList := TStringList.Create;  lParamList.Add('demo.addTwoNumbers');  lParamList.Add('100');  lParamList.Add('26');   try    Result := lHTTP.Post('hxxp://localhost/xmlrpc/xmlrpc-server.php', lParamList);  finally    FreeAndNil(lHTTP);    FreeAndNil(lParamList);  end;   Memo1.Text := Result; end; ---------------------------------------------------------------------- Laksen · 2010-10-18 15:18 Take a look at the specification, it's very simple: http://www.xmlrpc.com/spec So essentially what you should send, should be something like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   lParamList.Add('');  lParamList.Add('');  lParamList.Add('   demo.addTwoNumbers');  lParamList.Add('   ');  lParamList.Add('      ');  lParamList.Add('       100');  lParamList.Add('         26');  lParamList.Add('      ');  lParamList.Add('   ');  lParamList.Add('');  And the response(without headers) should look something like: Code: [Select]                    126           You can use TXMLDocument to parse that ---------------------------------------------------------------------- Mujie · 2010-10-18 22:24 Quote from: Laksen on October 18, 2010, 05:18:52 pmTake a look at the specification, it's very simple: http://www.xmlrpc.com/spec So essentially what you should send, should be something like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   lParamList.Add('');  lParamList.Add('');  lParamList.Add('   demo.addTwoNumbers');  lParamList.Add('   ');  lParamList.Add('      ');  lParamList.Add('       100');  lParamList.Add('         26');  lParamList.Add('      ');  lParamList.Add('   ');  lParamList.Add('');  Still no luck, I always got this : Code: [Select]                                 faultCode           -32700                                               parse error. not well formed                         Even I change 100 with 100. Anymore clue ? ---------------------------------------------------------------------- Laksen · 2010-10-19 06:06 My mistake Code: [Select]  lParamList.Add('');   lParamList.Add('');   lParamList.Add('   demo.addTwoNumbers');   lParamList.Add('   ');   lParamList.Add('      ');   lParamList.Add('         100');   lParamList.Add('      ');   lParamList.Add('      ');   lParamList.Add('         26');   lParamList.Add('      ');   lParamList.Add('   ');   lParamList.Add(''); ---------------------------------------------------------------------- Mujie · 2010-10-19 06:50 @Laksen : no, still not working, same error messages. Please take a look at http://stackoverflow.com/questions/301991, I follow their comment. Maybe Indy can't do this? Just guessing. ---------------------------------------------------------------------- ik · 2010-10-19 10:02 I've wrote a client using lNet and Lazarus in 2007, and still use it. First I can open source it (it's not at the moment), but I tested it on on Linux 64 bit ---------------------------------------------------------------------- Mujie · 2010-10-19 10:10 @ik : Nevermind if you don't share your source, I don't bother it . But, if you don't mind, please break my problem at my thread above and give me a clue. Should I change Indy with another network component such a Synapse or LNet ? Many thanks for any hint and help. ---------------------------------------------------------------------- ik · 2010-10-19 10:37 A. I'm willing to GPL it, that's why I offered it B. You might need the names of the parameters as well. Try in the PHP also to print the parameters, you might be missing something there. I use the IXR inside my own class so on the Init level I can also print_r the content (to log file). ---------------------------------------------------------------------- Mujie · 2010-10-19 22:28 @ik : sound great This day after struggle a few minutes, I found some weird char when I print out my XML client post with my past code. Code: [Select]Memo1.Lines.Text := lParamList.Text; Code: [Select]lParamList.Add(''); The result is : Code: [Select]'); The result is : Code: [Select]'+                                   'demo.addTwoNumbers'+                                   ''+                                   '100'+                                   '26'+                                   ''+                                     '');    aHTTP.MimeType := 'application/xml';    if aHTTP.HTTPMethod('POST', 'hxxp://localhost/xmlrpc/xmlrpc-server.php') then    begin      aHTTP.Document.Position := 0;      Memo1.Lines.LoadFromStream(aHTTP.Document);    end else ShowMessage('Can not POST');  finally    aHTTP.Free;  end;end; ---------------------------------------------------------------------- rychu · 2010-12-08 23:20 hi Mujie, please try: Code: [Select]lHTTP.HTTPOptions:=[]; ---------------------------------------------------------------------- vfclists · 2011-01-21 12:15 Isn't this the simple matter of URL encoding on by Indy? Isn't the server supposed to decode them, or is Indy not supposed to encode them before sending, or encoding it wrongly? Quote from: Mujie on October 20, 2010, 12:28:52 am@ik : sound great This day after struggle a few minutes, I found some weird char when I print out my XML client post with my past code. Code: [Select]Memo1.Lines.Text := lParamList.Text; Code: [Select]lParamList.Add(''); The result is : Code: [Select]'); The result is : Code: [Select]