In order to write a secure client following steps should be followed.
1.Create a service client
svc_client = axis2_svc_client_create(env, client_home);
2.Set options, such as endpoint address and SOAP action
options = axis2_options_create(env);
axis2_options_set_to(options, env, endpoint_ref);
axis2_options_set_action(options, env,"http://example.com/ws/2004/09/policy/Test/EchoRequest");
axis2_svc_client_set_options(svc_client, env, options);
3.Create policy object and set it to the service client
policy = neethi_util_create_policy_from_file(env, policy_file_name);
axis2_svc_client_set_policy(svc_client, env, policy)
4.Engage the security module
axis2_svc_client_engage_module(svc_client, env, "rampart");
5.Write your code to build the payload. i.e. the body of your SOAP message that carries your business logic to the service
payload = build_om_payload_for_echo_svc(env);
6.Send the message
ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
Note that from above list, only 3 and 4 are the additional steps that you have to take, to secure a client request. Also note that in the step 3 we are giving a policy file name as a string argument to the function neethi_util_create_policy_from_file(). Here the policy_file_name is the file name for your policy configurations in the client side. You may find such client's policy files for each and every security requirement in the scenarios available under WSFC_HOME/rampartc/samples/secpolicy.
No comments:
Post a Comment