Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 22718 invoked from network); 6 Dec 2006 07:55:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Dec 2006 07:55:26 -0000 Received: (qmail 78915 invoked by uid 500); 6 Dec 2006 07:55:34 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 78679 invoked by uid 500); 6 Dec 2006 07:55:34 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 78668 invoked by uid 500); 6 Dec 2006 07:55:34 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 78664 invoked by uid 99); 6 Dec 2006 07:55:34 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Dec 2006 23:55:34 -0800 X-ASF-Spam-Status: No, hits=-6.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME,URIBL_OB_SURBL X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Dec 2006 23:55:24 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 772481A9846; Tue, 5 Dec 2006 23:54:43 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r482954 - in /webservices/axis2/trunk/c/samples/client/yahoo: ./ Makefile.am yahoo_client.c Date: Wed, 06 Dec 2006 07:54:43 -0000 To: axis2-cvs@ws.apache.org From: dinesh@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061206075443.772481A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dinesh Date: Tue Dec 5 23:54:42 2006 New Revision: 482954 URL: http://svn.apache.org/viewvc?view=rev&rev=482954 Log: yahoo search sample added Added: webservices/axis2/trunk/c/samples/client/yahoo/ webservices/axis2/trunk/c/samples/client/yahoo/Makefile.am webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c Added: webservices/axis2/trunk/c/samples/client/yahoo/Makefile.am URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/client/yahoo/Makefile.am?view=auto&rev=482954 ============================================================================== --- webservices/axis2/trunk/c/samples/client/yahoo/Makefile.am (added) +++ webservices/axis2/trunk/c/samples/client/yahoo/Makefile.am Tue Dec 5 23:54:42 2006 @@ -0,0 +1,25 @@ +prgbindir=$(prefix)/bin/samples +samplesdir=$(prefix)/samples/client/google +prgbin_PROGRAMS = yahoosearch +samples_DATA=yahoo_client.c Makefile.am Makefile.in +yahoosearch_SOURCES = yahoo_client.c + +yahoosearch_LDADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxis2_util \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -laxis2_parser \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + -lwoden \ + -laxis2_xml_schema \ + $(GUTHTHILA_LIBS) \ + $(LIBXML2_LIBS) + +INCLUDES = -I$(AXIS2C_HOME)/include \ + @UTILINC@ \ + @AXIOMINC@ + +EXTRA_DIST=README.txt Added: webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c?view=auto&rev=482954 ============================================================================== --- webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c (added) +++ webservices/axis2/trunk/c/samples/client/yahoo/yahoo_client.c Tue Dec 5 23:54:42 2006 @@ -0,0 +1,163 @@ +#include +#include +#include +#include + +axiom_node_t * +build_yahoo_rest_payload (const axis2_env_t *env, axis2_char_t *string); + +void +format_output (const axis2_env_t *env, axiom_node_t *ret_node); + +void +format_output_one (const axis2_env_t *env, axiom_node_t *child_node); + +int +print_help (); + +int main (int argc, char *argv[]) +{ + const axis2_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t* endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t* svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + axis2_property_t *rest_property = NULL; + axis2_property_t *get_property = NULL; + axis2_char_t *search_string = NULL; + + if (argc > 1) + { + + if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) + { + print_help (); + } + else + search_string = argv[1]; + } + + env = axis2_env_create_all("yahoo_rest_search.log", AXIS2_LOG_LEVEL_TRACE); + address = "http://search.yahooapis.com/WebSearchService/V1/webSearch"; + + printf ("using endpoint %s \n", address); + + endpoint_ref = axis2_endpoint_ref_create(env, address); + + options = axis2_options_create(env); + AXIS2_OPTIONS_SET_TO(options, env, endpoint_ref); + + rest_property = axis2_property_create(env); + AXIS2_PROPERTY_SET_VALUE(rest_property, env, axis2_strdup (AXIS2_VALUE_TRUE, env)); + AXIS2_OPTIONS_SET_PROPERTY(options, env, AXIS2_ENABLE_REST, + rest_property); + get_property = axis2_property_create(env); + AXIS2_PROPERTY_SET_VALUE(get_property, env, axis2_strdup(AXIS2_HTTP_HEADER_GET, env)); + AXIS2_OPTIONS_SET_PROPERTY(options, env, AXIS2_HTTP_METHOD, get_property); + + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp (client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:" + " %d :: %s", env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, env, options); + + /* Build the SOAP request message payload using OM API.*/ + payload = build_yahoo_rest_payload (env, search_string); + + /* Send request */ + ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE(svc_client, env, payload); + + if (ret_node) + { + format_output (env, ret_node); + printf("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:" + " %d :: %s", env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + AXIS2_SVC_CLIENT_FREE(svc_client, env); + svc_client = NULL; + } + return 0; +} + +axiom_node_t * +build_yahoo_rest_payload (const axis2_env_t *env, axis2_char_t *string) +{ + axiom_node_t *root_node; + axiom_node_t *appid_node; + axiom_node_t *query_node; + axiom_element_t *appid_element; + axiom_element_t *query_element; + axiom_element_t *root_element; + root_node = axiom_node_create (env); + appid_node = axiom_node_create (env); + query_node = axiom_node_create (env); + root_element = axiom_element_create (env, NULL, "yahoo_rest_search", NULL, &root_node); + appid_element = axiom_element_create (env, root_node, "appid", NULL, &appid_node); + AXIOM_ELEMENT_SET_TEXT (appid_element, env, "YahooDemo", appid_node); + query_element = axiom_element_create (env, root_node, "query", NULL, &query_node); + if (string) + AXIOM_ELEMENT_SET_TEXT (query_element, env, string, query_node); + else + AXIOM_ELEMENT_SET_TEXT (query_element, env, "finance", query_node); + return root_node; +} + +void +format_output (const axis2_env_t *env, axiom_node_t *node) +{ + axiom_node_t *child_node; + child_node = AXIOM_NODE_GET_FIRST_CHILD (node, env); + while (AXIOM_NODE_IS_COMPLETE (node, env) && child_node) + { + printf ("\n\n"); + format_output_one (env, child_node); + child_node = AXIOM_NODE_GET_NEXT_SIBLING (child_node, env); + } + + +} + +void +format_output_one (const axis2_env_t *env, axiom_node_t *node) +{ + axiom_node_t *child_node; + child_node = AXIOM_NODE_GET_FIRST_CHILD (node, env); + while (AXIOM_NODE_IS_COMPLETE (node, env) && child_node) + { + printf ("\t%s\n", AXIOM_NODE_TO_STRING (child_node, env)); + child_node = AXIOM_NODE_GET_NEXT_SIBLING (child_node, env); + } +} + + +int +print_help () +{ + printf ("./yahoosearch string_to_search \n"); + exit (0); + return 0; +} --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org