I'm developing a SOAP web service using apache axis2c in c++. I use services.xml
to set some service-specific parameters & I need to get value of these parameters inside axis2_svc_skeleton
interface (e.g. in axis2_get_instance
function). But I dont know how can I do this?
Here is some part os my services.xml & I want to access value of myreadonlyparam
in my code:
<service name="myservice">
<parameter name="myreadonlyparam" locked="xsd:true">myparamvalue</parameter>
...
</service>
and this is part of my code
AXIS2_EXPORT int axis2_get_instance( axis2_svc_skeleton_t ** inst, const axutil_env_t * env )
{
*inst = axis2_myservice_create(env);
if (!(*inst))
{
return AXIS2_FAILURE;
}
//HERE I NEED SERVICE PARAMETER VALUE
...
}
Any idea?
I'm afraid it is not possible to get the service config without having axis2_conf
object. The axis2_conf
object is only accessible in init_with_conf
function.
Example on how to get service parameter:
int AXIS2_CALL my_service_init_with_conf(
axis2_svc_skeleton_t* skel, const axutil_env_t* env, axis2_conf* conf)
{
const axis2_char_t* service_name = "myservice";
/* get service by name */
struct axis2_svc* service = axis2_conf_get_svc(conf, env, service_name);
/* get service param */
axutil_param_t* param = axis2_svc_get_param(service, env, "myreadonlyparam");
/* get param value */
const char* value = (const char*) axutil_param_get_value(param, env);
printf("PARAM VALUE: %s\n", value);
return AXIS2_SUCCESS;
}
/* Skeleton options */
static axis2_svc_skeleton_ops_t skel_ops =
{
my_service_init,
my_service_invoke,
my_service_on_fault,
my_service_free,
my_service_init_with_conf
};
AXIS2_EXPORT int axis2_get_instance(
axis2_svc_skeleton** skel, axutil_env_t* env)
{
*skel = (axis2_svc_skeleton_t*) AXIS2_MALLOC(
env->allocator, sizeof(axis2_svc_skeleton_t));
if (!*skel)
return AXIS2_FAILURE;
(*skel)->ops = &skel_ops;
(*skel)->func_array = NULL;
return AXIS2_SUCCESS;
}
Output:
$ ./axis2_http_server PARAM VALUE: myparamvalue Started Simple Axis2 HTTP Server ...