WSF/C crash when using HTTP Basic authentication (no https)

dc.groups.gmail.com's picture
Hello guys, I'm having hard times with WSF/C v1.3.0 libraries from client side to consume an web service set up to work on apache tomcat with basic authentication. It seems that whatever I am doing, it is not working. Google doesn't 'offer' too many solutions on my issue. So, here's a small description of my project: - I have a client-application written in C (RHEL 3.9) which will be used by various users; - All users will have valid user on the server side; - For some reason, the only way to authenticate on server side is to use HTTP (NB: no HTTPS) with Basic authentication; What I have done so far: - I could try to dig a way to setup axis2.xml file to do the authentication automatically, but this will force me to impersonate only one user at server side; - I have compiled WSF/C using this command line: ./configure --prefix=${WSFC_HOME} --enable-sandesha=no --enable-guththila=no --enable-libxml2=yes --enable-openssl=yes ++ I don't have acccess to libcurl - I have to stick with original OS version; - echo_blocking.c is not working. I have tried to use it against my web-server. It doesn't 'detect' any authentication mechanism and tries to issue a plain request; - I executed WSDL2C and created a stub using my websvc wsdl file. I have compiled the file and put it with services.xml under services directory in ${WSFC_HOME}. From log file, it seems like the code detects the new service and loads it: [Thu May 6 15:29:48 2010] [debug] svc_builder.c(318) DLL path is : /home/user/work/lib/axis/services/ManagementServiceService/libManagementServiceService.so [Thu May 6 15:29:48 2010] [debug] phase_resolver.c(123) Service name is : ManagementServiceService ++ And that's it. However, it appears that for libsubscription service (the default one), the log contains a lot more information than those 2 lines ... - Here's a sample of my code (borrowed and addapted from echo_blocking): request_string = ""; env = axutil_env_create_all("./websvc_client.log", AXIS2_LOG_LEVEL_TRACE); address = "http://jasper:8080/jasperserver-pro/services/repository"; endpoint_ref = axis2_endpoint_ref_create(env, address); options = axis2_options_create(env); axis2_options_set_to(options, env, endpoint_ref); axis2_options_set_action(options, env, ""); client_home = getenv("WSFC_HOME"); jasper_client = axis2_stub_create_ManagementServiceService(env, client_home, address); svc_client = axis2_stub_get_svc_client(jasper_client, env ); axis2_options_set_http_method(options, env, AXIS2_HTTP_POST); axis2_options_set_http_auth_info(options, env, un, pw, "Basic"); // Tried also with Digest, but no luck. axis2_svc_client_set_options(svc_client, env, options); axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); list_item = adb_list_create(env); adb_list_set_requestXmlString(list_item, env, request_string); // the code crashes here. list_response = axis2_stub_op_ManagementServiceService_list(jasper_client, env, list_item); - axis2.xml file is not changed. It's the original file; - Here you can find the request and response made with IE: GET http://jasper:8080/jasperserver-pro/services/repository?wsdl HTTP/1.1 Accept: */* Accept-Language: en-us User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1) Accept-Encoding: gzip, deflate Connection: Keep-Alive Host: jasper:8080 Cookie: JSESSIONID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXX HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Pragma: No-cache Cache-Control: no-cache Expires: Thu, 01 Jan 1970 02:00:00 EET Content-Type: text/xml;charset=utf-8 Date: Fri, 07 May 2010 09:32:57 GMT Content-Length: 8599 <?xml version="1.0" encoding="UTF-8"?> ... I have made a 3-lines test code in C# and with Basic-authentication flags it worked fine. So it has to be something with my WSFC/C code. Can you please point me what am I doing wrong here, or at least, point me to a similar sample (HTTP Basic auth with stubs)?
dc.groups.gmail.com's picture

I think it was solved.

I think the problem was solved. Instead of using newly created options object, I should have taken the options of service client of the stub and alter its http authentication flags: options_svc = axis2_svc_client_get_options(svc_client, env); axis2_options_set_http_method((axis2_options_t *)options_svc, env, AXIS2_HTTP_POST); axis2_options_set_http_auth_info((axis2_options_t *)options_svc, env, un, pw, "Basic"); // Set service client options //axis2_svc_client_set_options(svc_client, env, options); And it worked.
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)