Re: Implementating Multithreading or Forking with XMLRPC C server

"amit_basnak25" <[email protected]>
Newsgroups gmane.text.xml.rpc.specification
Message-ID <[email protected]>
Bryan thanks 
I have my client.c written as below where im passing an array of 
string 

#include <stdlib.h>
#include <stdio.h>

#include <xmlrpc-c/base.h>
#include <xmlrpc-c/client.h>

#include "config.h"  /* information about this build environment */

#define NAME "Xmlrpc-c Test Client"
#define VERSION "1.0"

static void 
die_if_fault_occurred (xmlrpc_env *env) {
    if (env->fault_occurred) {
        fprintf(stderr, "XML-RPC Fault: %s (%d)\n",
                env->fault_string, env->fault_code);
        exit(1);
    }
}



int 
main(int           const argc, 
     const char ** const argv ATTR_UNUSED) {

    xmlrpc_env env;
    xmlrpc_value *result;
   // xmlrpc_int32 sum;
    char * const serverUrl = "http://localhost:12000/RPC2";
    char * const methodName = "count.entities";
    xmlrpc_value * array;
    size_t len=12, i;


    /* added by Amit */
	const char * employeeName[5] = {"Amit"};
    if (argc-1 > 0) {
        fprintf(stderr, "This program has no arguments\n");
        exit(1);
    }

    /* Initialize our error-handling environment. */
    xmlrpc_env_init(&env);

    /* Start up our XML-RPC client library. */
    xmlrpc_client_init2(&env, XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION, 
NULL, 0);
    die_if_fault_occurred(&env);

    printf("Making XMLRPC call to server url '%s' method '%s' "
           "to request the array "
           "of strings...\n", serverUrl, methodName);

    /* Make the remote procedure call */
    result = xmlrpc_client_call(&env, serverUrl, methodName,"(A)", 
&array );
    die_if_fault_occurred(&env);
    
    /* Get our array and print it out. */
    xmlrpc_read_int(&env, result, &array);
    die_if_fault_occurred(&env);

    printf("The array  is %s\n, %s\n , %s\n ", result);
    
    /* Dispose of our result value. */
    xmlrpc_DECREF(result);

    /* Clean up our error-handling environment. */
    xmlrpc_env_clean(&env);
    
    /* Shutdown our XML-RPC client library. */
    xmlrpc_client_cleanup();

    return 0;
}
--------------------------------------------------------------------
also in the server side Im not sure how to modify the code for the 
server side , What I got so far is 
static xmlrpc_value *
easy_struct(xmlrpc_env *   const env,
            xmlrpc_value * const param_array,
            void *         const user_data ATTR_UNUSED) {

    xmlrpc_int32 larry, moe, curly;
fprintf(stderr,"I-flex - easy struct suresh\n");

    /* Parse our argument array and get the stooges. */
    xmlrpc_decompose_value(env, param_array, "({s:i,s:i,s:i,*})",
                           "larry", &larry,
                           "moe", &moe,
                           "curly", &curly);
    //RETURN_IF_FAULT(env);

    /* Return our result. */
    return xmlrpc_build_value(env, "i", larry + moe + curly);
}

------------------------------------------------------------------

Bryan can you please guide me in the right direction
Thanks for time and help
Amit



--- In [email protected], bryanh@... wrote:
>
> >How do I pass a C structure request from client to server in xmlrpc-
c ? 
> 
> You can do it the same way that the example programs pass a C 
integer,
> except using "{...}" in the format string instead of "i".  See
> <http://xmlrpc-c.sourceforge.net/doc/libxmlrpc.html#formatstring>.
> 
> -- 
> Bryan Henderson                                    Phone 408-621-2000
> San Jose, California
>







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/xml-rpc/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.