Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6042449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:47:30+00:00 2026-05-23T06:47:30+00:00

i inteded to show xml format on the console from following basic code :

  • 0

i inteded to show xml format on the console from following basic code :

#include <stdio.h>
#include <stdlib.h>
#include <xmlrpc.h>
#include <xmlrpc_client.h>
#include <xmlrpc-c/base.h>
#include <xmlrpc-c/util.h>

#define XMLRPC_NAME       "XML-RPC tesaja"
#define XMLRPC_VERSION    "0.1"

int main()
{
//declare
    xmlrpc_env env;
    xmlrpc_value *result = NULL;

    xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, XMLRPC_NAME, XMLRPC_VERSION);
    xmlrpc_env_init(&env);


     result = xmlrpc_client_call(&env, "http://xmlrpc-c.sourceforge.net/api/sample.php" ,
                                 "sample.sumAndDifference", "(ii)", //method
                                (xmlrpc_int32) 5,                  //var
                                (xmlrpc_int32) 3);                 //var

    /* ma code */
     char output[1024] = {0};
     int l_output = 0;
    /* ------------------ keluarin xml ------------------*/
        xmlrpc_value *params;
        xmlrpc_mem_block *xmlmemblockP = NULL;

    params = xmlrpc_build_value(&env, "(ii)", (xmlrpc_int32) 5, (xmlrpc_int32) 7);    
    xmlmemblockP = XMLRPC_MEMBLOCK_NEW(char, &env, 0);
    xmlrpc_serialize_call(&env, xmlmemblockP, "sample.sumAndDifference", params);


    l_output = snprintf(output,XMLRPC_MEMBLOCK_SIZE(char, xmlmemblockP),"%s",XMLRPC_MEMBLOCK_CONTENTS(char, xmlmemblockP));
    output[l_output] = '\0';

    printf("submit data -> \n %s\n",output);

    XMLRPC_MEMBLOCK_FREE(char, xmlmemblockP);

    /* Dispose of our parameter array. */
    xmlrpc_DECREF(params);

     /* ------------------ keluarin xml ------------------*/


    if(env.fault_occurred)
    {
    printf("%s\n",env.fault_string);
        return 0;
    }


    // Parse our result value 
    xmlrpc_int32 sum, difference;
    xmlrpc_decompose_value(&env, result, "{s:i,s:i,*}",
                       "sum", &sum,
                       "difference", &difference);

    /* keluarin xml respon */
    params = result;
    xmlmemblockP = XMLRPC_MEMBLOCK_NEW(char, &env, 0);
    xmlrpc_serialize_call(&env, xmlmemblockP, "sample.sumAndDifference", params);

    l_output = snprintf(output,XMLRPC_MEMBLOCK_SIZE(char, xmlmemblockP),"%s",XMLRPC_MEMBLOCK_CONTENTS(char, xmlmemblockP));
    output[l_output] = '\0';    
    printf("respon data-> \n %s \n",output);
    XMLRPC_MEMBLOCK_FREE(char, xmlmemblockP);

    /* Dispose of our parameter array. */
    //xmlrpc_DECREF(params); //udah diwakilin dibawah
    /* keluarin xml respon*/


    if(env.fault_occurred)
    {
        printf("%s\n",env.fault_string);
        return 0;
    }


    // Print out our sum and difference.  
    printf("Sum: %d, Difference: %d\n", (int) sum, (int) difference);


    // Dispose of our result value.  
    xmlrpc_DECREF(result);

    //Shutdown our XML-RPC client library. 
    xmlrpc_env_clean(&env);
    xmlrpc_client_cleanup();



return 0;
}

and somehow it doesnt work properly :

compile

$ gcc -o xxx xxx.c `xmlrpc-c-config libwww-client --libs --cflags`

output

submit data -> 
 <?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>sample.sumAndDifference</methodName>
<params>
<param><value><i4>5</i4></value></param>
<param><value><i4>7</i4></value></param>
</params>
</methodCall>
respon data-> 
 <?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>sample.sumAndDifference</methodName>
 params>
Expected XMLRPC_TYPE_ARRAY

question

  1. why these code could not work properly ?
  2. what is <i4> mean ?, if xmlrpc server (any xmlrpc based, like xmlrpc-c, xmlrpc java, etc..) asking for integer, will <i4> representing it ?

thx for everything

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:47:30+00:00Added an answer on May 23, 2026 at 6:47 am

    aah, after i sought the functions provided by xmlrpc-c library, i found xmlrpc_serialize_response(); , which i thought will do such thing

    #include <stdio.h>
    #include <stdlib.h>
    #include <xmlrpc.h>
    #include <xmlrpc_client.h>
    #include <xmlrpc-c/base.h>
    #include <xmlrpc-c/util.h>
    
    #define XMLRPC_NAME       "XML-RPC tesaja"
    #define XMLRPC_VERSION    "0.1"
    
    int main()
    {
    //declare
        xmlrpc_env env;
        xmlrpc_value *result = NULL;
    
        xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, XMLRPC_NAME, XMLRPC_VERSION);
        xmlrpc_env_init(&env);
    
    
         result = xmlrpc_client_call(&env, "http://xmlrpc-c.sourceforge.net/api/sample.php" ,
                                     "sample.sumAndDifference", "(ii)", //method
                                    (xmlrpc_int32) 5,                  //var
                                    (xmlrpc_int32) 3);                 //var
    
        /* ma code */
         char output[1024] = {0};
         int l_output = 0;
        /* ------------------ keluarin xml ------------------*/
            xmlrpc_value *params;
            xmlrpc_mem_block *xmlmemblockP = NULL;
    
        params = xmlrpc_build_value(&env, "(ii)", (xmlrpc_int32) 5, (xmlrpc_int32) 7);    
        xmlmemblockP = XMLRPC_MEMBLOCK_NEW(char, &env, 0);
        xmlrpc_serialize_call(&env, xmlmemblockP, "sample.sumAndDifference", params);
    
    
        l_output = snprintf(output,XMLRPC_MEMBLOCK_SIZE(char, xmlmemblockP),"%s",XMLRPC_MEMBLOCK_CONTENTS(char, xmlmemblockP));
        output[l_output] = '\0';
    
        printf("submit data -> \n %s\n",output);
    
        XMLRPC_MEMBLOCK_FREE(char, xmlmemblockP);
    
        /* Dispose of our parameter array. */
        xmlrpc_DECREF(params);
    
         /* ------------------ keluarin xml ------------------*/
    
    
        if(env.fault_occurred)
        {
        printf("err : %s\n",env.fault_string);
            return 0;
        }
    
    
        // Parse our result value 
        xmlrpc_int32 sum, difference;
    
        xmlrpc_decompose_value(&env, result, "{s:i,s:i,*}",
                           "sum", &sum,
                           "difference", &difference);
    
        /* keluarin xml respon */
    
        xmlmemblockP = XMLRPC_MEMBLOCK_NEW(char, &env, 0);
    
        xmlrpc_serialize_response(&env,xmlmemblockP,result);    
        l_output = snprintf(output,XMLRPC_MEMBLOCK_SIZE(char, xmlmemblockP),"%s",XMLRPC_MEMBLOCK_CONTENTS(char, xmlmemblockP));
        output[l_output] = '\0';    
        printf("respon data-> \n %s \n",output);
        XMLRPC_MEMBLOCK_FREE(char, xmlmemblockP);
    
        /* keluarin xml respon*/
    
    
        if(env.fault_occurred)
        {
            printf("err : %s\n",env.fault_string);
            return 0;
        }
    
    
        // Print out our sum and difference.  
        printf("Sum: %d, Difference: %d\n", (int) sum, (int) difference);
    
    
        // Dispose of our result value.  
        xmlrpc_DECREF(result);
    
        //Shutdown our XML-RPC client library. 
        xmlrpc_env_clean(&env);
        xmlrpc_client_cleanup();
    
    
    
    return 0;
    }
    

    output

    submit data -> 
     <?xml version="1.0" encoding="UTF-8"?>
    <methodCall>
    <methodName>sample.sumAndDifference</methodName>
    <params>
    <param><value><i4>5</i4></value></param>
    <param><value><i4>7</i4></value></param>
    </params>
    </methodCall>
    respon data-> 
     <?xml version="1.0" encoding="UTF-8"?>
    <methodResponse>
    <params>
    <param><value><struct>
    <member><name>sum</name>
    <value><i4>8</i4></value></member>
    <member><name>difference</name>
    <value><i4>2</i4></value></member>
    </struct></value></param>
    </params>
     /methodResponse>
    Sum: 8, Difference: 2
    

    and fortunately it did.
    now thats first question done with.
    but second question left unanswered, anyone mind to answer the left?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following code does destroy records as intended, but the callback is inherited from one
I've taken inspiration from the example show in the following URL csharp-online and intended
I am using some excellent code for a photo slide show from http://www.queness.com/post/1450/jquery-photo-slide-show-with-slick-caption-tutorial-revisited .
This confused me a lot var show = function(){ console.log('wow'); }; var show2 =
I am using VFW unit from JEDI wrapper on WinAPI. The code I am
The following code will: Test to see if the characters in a div are
I have code that is intended to show the user the number of remaining
the following code is a handler that takes in a Percent (percent of the
I found this piece of code from anther post here. It worked as intended
The following code is intended to do a purely ajax POST request, instead it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.