[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

SOAP library written in C

  • To: xml-dev@l...
  • Subject: SOAP library written in C
  • From: Ferhat Ayaz <ayaz@j...>
  • Date: Thu, 5 Feb 2004 22:35:59 +0100
  • In-reply-to: <20040205213313.GG1853@debian> (from ayaz@j... on Thu, Feb 05, 2004 at 22:33:13 +0100)
  • References: <20040205213313.GG1853@debian>

soap library
Hi folks,
 try the SOAP library written in C. You can also implement a SOAP
 server in C. This library depends on libxml2.

 Homepage: http://csoap.sourceforge.net


 Example client using CSOAP
 ----------------------------------------------

 static const char *url =
  "http://csoap.sourceforge.net/cgi-bin/csoapserver";
 static const char *urn = "urn:examples";
 static const char *method = "sayHello";

 int main(int argc, char *argv[])
 {
  SoapEnv *env, *res;
  env = soap_env_new_with_method(urn, method);

   soap_env_add_item(env, "xsd:string",
 	"name", "Jonny B. Good");
   res = soap_client_invoke(env, url , "");

   soap_xml_doc_print(res->root->doc);

   soap_env_free(res);
   soap_env_free(env);

 return 0;
 }


 Example server using CSOAP
 ----------------------------------------------

 /**
 	FUNCTION: say_hello()
 	DESCRIPTION: The SOAP Server service function.
 	URN: urn:examples
 	METHOD: sayHello
 */
 SoapEnv* say_hello(SoapEnv *request)
 {

  SoapEnv *env;
  xmlNodePtr method, node;
  char *name;

  env = soap_env_new_with_response(request);

  method = soap_env_get_method(request);
  node = soap_xml_get_children(method);

  while (node) {

    name = (char*)xmlNodeListGetString(node->doc,
 		node->xmlChildrenNode, 1);
    if (!name) continue;

    soap_env_add_itemf(env,"xsd:string", "echo", "Hello '%s'", name);

    xmlFree((xmlChar*)name);

    node = soap_xml_get_next(node);
  }

  return env;
 }

 /**
 	FUNCTION: main()
 	DESCRIPTION: Register and run soap server
 */
 int main(int argc, char *argv[])
 {

  SoapRouter *router;

   if (!soap_server_init_args(argc, argv)) {
    return 0;
  }

   router = soap_router_new();

   soap_router_register_service(router, say_hello, "sayHello",
     "urn: examples");
   soap_server_register_router(router, "/csoapserver");

   soap_server_run();

   soap_router_free(router);
   soap_server_destroy();

  return 0;
 }

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.