From f1d7f8e861ef15563d94574d02978795c6bd4475 Mon Sep 17 00:00:00 2001 From: damitha Date: Wed, 1 Jun 2011 09:49:11 +0000 Subject: Updating the sample git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@1130073 13f79535-47bb-0310-9956-ffa450edef68 --- samples/client/ntlm/ntlm_post.c | 106 ++++------------------------------------ 1 file changed, 9 insertions(+), 97 deletions(-) (limited to 'samples/client/ntlm/ntlm_post.c') diff --git a/samples/client/ntlm/ntlm_post.c b/samples/client/ntlm/ntlm_post.c index 679f765..f42c18f 100755 --- a/samples/client/ntlm/ntlm_post.c +++ b/samples/client/ntlm/ntlm_post.c @@ -21,9 +21,7 @@ #include #include #include - -axiom_node_t *build_om_payload_for_echo_svc( - const axutil_env_t * env); +#include "ntlm_util.h" int main( @@ -44,14 +42,12 @@ main( const int fg = 0; const axis2_char_t *domain = NULL; const axis2_char_t *workstation = NULL; - axis2_bool_t http_auth_required = AXIS2_FALSE; - axis2_bool_t proxy_auth_required = AXIS2_FALSE; axutil_string_t *soap_action = NULL; /* Set up the environment */ env = axutil_env_create_all("ntlm_auth_client.log", AXIS2_LOG_LEVEL_TRACE); - /* Set end point reference of echo service */ + /* Set end point reference of ntlm service */ address = "http://172.16.176.132:80/myservice/Service1.asmx"; if (argc > 1) { @@ -128,30 +124,6 @@ main( return -1; } - /* Enabling REST for HTTP HEAD Request */ - axis2_options_set_enable_rest(options, env, AXIS2_TRUE); - - /* Setting Request as HTTP HEAD Request */ - axis2_options_set_http_method(options, env, AXIS2_HTTP_HEAD); - - /* Sending dummy authentication info */ - if (un && pw) - { - axis2_options_set_ntlm_proxy_auth_info(options, env, "", "", NULL, NULL, NULL, NULL); - } - if(flags) - { - fg = atoi(flags); - } - else - { - fg = 0; - } - - /* Force authentication tests */ - axis2_options_set_test_http_auth(options, env, AXIS2_TRUE); - axis2_options_set_test_proxy_auth(options, env, AXIS2_TRUE); - /* Set service client options */ axis2_svc_client_set_options(svc_client, env, options); @@ -159,50 +131,14 @@ main( /*axis2_svc_client_set_proxy_with_auth(svc_client, env, "127.0.0.1", "3128", NULL, NULL);*/ /* Sending robust authentication test message */ - axis2_svc_client_send_robust(svc_client, env, NULL); - - /* Checking whether authentication is required */ - if (axis2_svc_client_get_proxy_auth_required(svc_client, env)) - { - proxy_auth_required = AXIS2_TRUE; - - /* Set proxy-auth information */ - if (un && pw) - { - axis2_options_set_ntlm_proxy_auth_info(options, env, un, pw, &fg, domain, workstation, - axis2_svc_client_get_auth_type(svc_client, env)); - } - - /* Sending robust authentication test message */ - axis2_svc_client_send_robust(svc_client, env, NULL); - } - if (axis2_svc_client_get_http_auth_required(svc_client, env)) - { - http_auth_required = AXIS2_TRUE; - /* Set http-auth information */ - if (un && pw) - { - axis2_options_set_ntlm_http_auth_info(options, env, un, pw, &fg, domain, workstation, - axis2_svc_client_get_auth_type(svc_client, env)); - } - } - - /* Cancel authentication tests */ - axis2_options_set_test_http_auth(options, env, AXIS2_FALSE); - axis2_options_set_test_proxy_auth(options, env, AXIS2_FALSE); - /* Print whether authentication was required */ - if (http_auth_required) - { - printf("\nHTTP Authentication info required.\n"); - } - if (proxy_auth_required) + /* Set http-auth information */ + if (un && pw) { - printf("\nProxy Authentication info required.\n"); + axis2_options_set_ntlm_http_auth_info(options, env, un, pw, &fg, domain, workstation, + AXIS2_HTTP_AUTH_TYPE_NTLM); } - /* Disabling REST for SOAP Request */ - axis2_options_set_enable_rest(options, env, AXIS2_FALSE); /* Setting Request as HTTP POST Request */ axis2_options_set_http_method(options, env, AXIS2_HTTP_POST); @@ -211,7 +147,7 @@ main( for(i = 0; i < 1; i++) { /* Build the SOAP request message payload using OM API. */ - payload = build_om_payload_for_echo_svc(env); + payload = build_om_payload_for_ntlm_auth_service(env); /*axis2_svc_client_send_robust(svc_client, env, payload);*/ /* Send request */ @@ -223,7 +159,7 @@ main( om_str = axiom_node_to_string(ret_node, env); if (om_str) printf("\nReceived OM : %s\n", om_str); - printf("\necho client invoke SUCCESSFUL!\n"); + printf("\nntlm client invoke SUCCESSFUL!\n"); AXIS2_FREE(env->allocator, om_str); ret_node = NULL; @@ -234,7 +170,7 @@ main( "Stub invoke FAILED: Error code:" " %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); - printf("echo client invoke FAILED!\n"); + printf("ntlm client invoke FAILED!\n"); } } if (svc_client) @@ -252,28 +188,4 @@ main( return 0; } -/* build SOAP request message content using OM */ -axiom_node_t * -build_om_payload_for_echo_svc( - const axutil_env_t * env) -{ - axiom_node_t *echo_om_node = NULL; - axiom_element_t *echo_om_ele = NULL; - axiom_namespace_t *ns1 = NULL; - axis2_char_t *om_str = NULL; - - ns1 = axiom_namespace_create(env, "http://tempuri.org", "ns1"); - echo_om_ele = axiom_element_create(env, NULL, "HelloWorld", ns1, &echo_om_node); - axiom_element_set_text(echo_om_ele, env, "Hello World!", echo_om_node); - axiom_namespace_free(ns1, env); - - om_str = axiom_node_to_string(echo_om_node, env); - if (om_str) - { - printf("\nSending OM : %s\n", om_str); - AXIS2_FREE(env->allocator, om_str); - } - - return echo_om_node; -} -- cgit v1.1-32-gdbae