Hi All,
I am facing some problems with invoking a https based .Net
webservice using the axis2c client. I am getting Error code 2. It is
giving error "cannot find the password for user
pbsgridworks\\administrator". How can i set the password to this.
I am sending axis.xml ,my .c file and client_policy.xml file. Please
check and give reply.
Thanks
Divakar
<axisconfig name="Axis2/C">
<!-- ================================================= -->
<!-- Parameters -->
<!-- ================================================= -->
<!-- Uncomment following to enable MTOM support -->
<!--parameter name="enableMTOM" locked="false">true</parameter-->
<parameter name="hotdeployment" locked="false">false</parameter>
<parameter name="hotupdate" locked="false">false</parameter>
<!--parameter name="enableMTOM" locked="false">true</parameter-->
<!-- Uncomment this to enable REST support -->
<parameter name="enableREST" locked="false">true</parameter>
<parameter name="userName" locked="false">pbsgridworks\\administrator</parameter>
<parameter name="password" locked="false">[EMAIL PROTECTED]</parameter>
<parameter name="seralizeLocation" locked="false">.</parameter>
<!-- Uncomment following to persist op_ctx, useful with RM -->
<!--parameter name="persistOperationContext" locked="false">true</parameter-->
<!--if you want to extract the service archive file and work with that please uncomment this-->
<!--else , it wont extract archive file or does not take into consideration if someone drop-->
<!--exploded directory into /service directory-->
<!--<parameter name="extractServiceArchive" locked="false">true</parameter>-->
<!-- ================================================= -->
<!-- Message Receivers -->
<!-- ================================================= -->
<!-- This is the Deafult Message Receiver for the Request Response style Operations -->
<!--messageReceiver mep="INOUT" class="axis2_receivers"/-->
<!-- ================================================= -->
<!-- Transport Ins -->
<!-- ================================================= -->
<transportReceiver name="http" class="axis2_http_receiver">
<parameter name="port" locked="false">6060</parameter>
</transportReceiver>
<!--transportReceiver name="tcp" class="axis2_tcp_receiver">
<parameter name="port" locked="false">6060</parameter>
</transportReceiver-->
<!-- ================================================= -->
<!-- Transport Outs -->
<!-- ================================================= -->
<!--transportSender name="http" class="axis2_http_sender">
<parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
<parameter name="Transfer-Encoding">chunked</parameter-->
<!--parameter name="PROXY" proxy_host="127.0.0.1" proxy_port="8080" locked="true"/>
</transportSender-->
<!-- Uncomment this one with the appropriate papameters to enable the XMPP transport Sender-->
<!--transportSender name="xmpp" class="axis2_xmpp_sender">
<parameter name="PROTOCOL" locked="false">XMPP</parameter>
</transportSender-->
<!-- Uncomment this one with the appropriate papameters to enable the TCP transport Sender-->
<!--transportSender name="tcp" class="axis2_tcp_sender">
<parameter name="PROTOCOL" locked="false">TCP</parameter>
</transportSender-->
<transportSender name="https" class="axis2_http_sender">
<parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
</transportSender>
<parameter name="SERVER_CERT">/home/divakar/cert.pem</parameter>
<!--parameter name="KEY_FILE">/path/to/client/certificate/chain/file</parameter-->
<parameter name="SSL_PASSPHRASE">passphrase</parameter>
<!-- ================================================= -->
<!-- Global Modules -->
<!-- ================================================= -->
<!-- Comment this to disable Addressing -->
<module ref="addressing"/>
<module ref ="rampart"/>
<!--Configuring module , providing paramters for modules whether they refer or not-->
<!--<moduleConfig name="addressing">-->
<!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
<!--</moduleConfig>-->
<!-- ================================================= -->
<!-- Phases -->
<!-- ================================================= -->
<phaseOrder type="inflow">
<!-- System pre defined phases -->
<phase name="Transport"/>
<phase name="PreDispatch"/>
<phase name="Dispatch"/>
<phase name="PostDispatch"/>
<!-- End system pre defined phases -->
<!-- After PostDispatch phase, module or service author can add any phase as required -->
<!-- User defined phases could be added here -->
<!--phase name="userphase1"/-->
<!--phase name="RMPhase"/-->
<!--phase name="SavanPhase"/-->
</phaseOrder>
<phaseOrder type="outflow">
<!-- User defined phases could be added here -->
<!--phase name="RMPhase"/-->
<!--phase name="SavanPhase"/-->
<!--phase name="userphase1"/-->
<!--system predefined phase-->
<phase name="MessageOut"/>
<phase name="Security"/>
</phaseOrder>
<phaseOrder type="INfaultflow">
<!-- User defined phases could be added here -->
<!--phase name="userphase1"/-->
<!--phase name="RMPhase"/-->
<!--phase name="SavanPhase"/-->
</phaseOrder>
<phaseOrder type="Outfaultflow">
<!-- User defined phases could be added here -->
<!--phase name="RMPhase"/-->
<!--phase name="SavanPhase"/-->
<!--phase name="userphase1"/-->
<phase name="MessageOut"/>
</phaseOrder>
</axisconfig>
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:InitiatorToken>
<wsp:Policy>
<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssX509V3Token10/>
</wsp:Policy>
</sp:X509Token>
</wsp:Policy>
</sp:InitiatorToken>
<sp:RecipientToken>
<wsp:Policy>
<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
<wsp:Policy>
<sp:WssX509V3Token10/>
</wsp:Policy>
</sp:X509Token>
</wsp:Policy>
</sp:RecipientToken>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:AsymmetricBinding>
<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always"/>
</wsp:Policy>
</sp:SignedSupportingTokens>
<rampc:RampartConfig xmlns:rampc="http://ws.apache.org/rampart/c/policy">
<rampc:User>pbsgridworks\\administrator</rampc:User>
<!--rampc:Password>[EMAIL PROTECTED]</rampc:Password-->
<rampc:PasswordType>Digest</rampc:PasswordType>
<rampc:PasswordCallbackClass>/usr/local/axis2c/bin/samples/rampart/callback/libpwcb.so</rampc:PasswordCallbackClass>
<!--rampc:Password>[EMAIL PROTECTED]</rampc:Password-->
</rampc:RampartConfig>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
#include <axiom.h>
#include <axis2_util.h>
#include <axis2_const.h>
#include <axutil_env.h>
#include <axutil_log_default.h>
#include <axutil_error_default.h>
#include <axiom_output.h>
#include <axiom_xml_writer.h>
#include <stdio.h>
#include <axis2_client.h>
#include <axiom_soap.h>
#include <axiom_soap_envelope.h>
#include <rampart_context.h>
#include <rampart_username_token.h>
#include <axiom_soap_envelope.h>
#include <rampart_constants.h>
#include <neethi_util.h>
#include <neethi_policy.h>
axiom_node_t *getHeaderNode(const axutil_env_t *env)
{
/* Namespace element declarations */
axiom_namespace_t *wsa_ns= NULL;
axiom_namespace_t *wsse_ns=NULL;
axiom_namespace_t *wsu_ns=NULL;
axiom_node_t *header_node=NULL,*to_node=NULL,*action_node=NULL;
axiom_element_t *header_element=NULL,*to_element=NULL,*action_element=NULL;
axiom_text_t *om_text=NULL;
axiom_node_t *text_node=NULL;
axiom_node_t *security_node=NULL,*usernametoken_node=NULL,*username_node=NULL,*password_node=NULL;
axiom_element_t *security_element=NULL,*usernametoken_element=NULL,*username_element=NULL,*password_element=NULL;
axiom_attribute_t *password_attribute=NULL,*body_attribute=NULL,*to_attribute=NULL;
/* Creating all the namespace elements */
wsa_ns= axiom_namespace_create(env,"http://www.w3.org/2005/08/addressing","wsa");
wsse_ns=axiom_namespace_create(env,"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","wsse");
wsu_ns=axiom_namespace_create(env,"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd","wsu");
/* SOAP Header element */
header_element=axiom_element_create(env,NULL,"Header",NULL,&header_node);
security_element=axiom_element_create(env,NULL,"Security",wsse_ns,&security_node);
/* Usernametoken element to pass the username, password to HPCPwebservice */
usernametoken_element=axiom_element_create(env,NULL,"UsernameToken",wsse_ns,&usernametoken_node);
axiom_element_set_namespace(usernametoken_element,env,wsse_ns,usernametoken_node);
username_element=axiom_element_create(env,NULL,"Username",wsse_ns,&username_node);
om_text=axiom_text_create(env,username_node,"PBSGRIDWORKS\\administrator",&text_node);
password_element=axiom_element_create(env,NULL,"Password",wsse_ns,&password_node);
password_attribute=axiom_attribute_create(env,"Type","http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText",NULL);
axiom_element_add_attribute(password_element,env,password_attribute,password_node);
om_text=axiom_text_create(env,password_node,"[EMAIL PROTECTED]",&text_node);
axiom_node_add_child(usernametoken_node,env,username_node);
axiom_node_add_child(usernametoken_node,env,password_node);
axiom_node_add_child(security_node,env,usernametoken_node);
/* End of Usernametoken element */
/*
action_element=axiom_element_create(env,NULL,"Action",wsa_ns,&action_node);
om_text=axiom_text_create(env,action_node,"http://schemas.ggf.org/bes/2006/08/bes-factory/CreateActivity",&text_node);
axiom_node_add_child(header_node,env,action_node);
to_element=axiom_element_create(env,NULL,"To",wsa_ns,&to_node);
to_attribute=axiom_attribute_create(env,"mustUnderstand","1",NULL);
axiom_element_add_attribute(to_element,env,to_attribute,to_node);
om_text=axiom_text_create(env,to_node,"http://OpenSuSe10:8081",&text_node);
axiom_node_add_child(header_node,env,to_node);
*/
axis2_char_t *om_str=NULL;
om_str = axiom_node_to_string(security_node,env);
if(om_str)
{
printf("\n Header Element : %s\n", om_str);
AXIS2_FREE(env->allocator, om_str);
}
return security_node;
}
axiom_node_t *ToElement(const axutil_env_t *env)
{
axiom_namespace_t *wsa_ns=NULL;
axiom_node_t *to_node=NULL;
axiom_element_t *to_element=NULL;
axiom_attribute_t *to_attribute=NULL;
axiom_node_t *text_node=NULL;
wsa_ns= axiom_namespace_create(env,"http://www.w3.org/2005/08/addressing","wsa");
to_element=axiom_element_create(env,NULL,"To",wsa_ns,&to_node);
to_attribute=axiom_attribute_create(env,"mustUnderstand","1",NULL);
axiom_element_add_attribute(to_element,env,to_attribute,to_node);
axiom_text_t *om_text=axiom_text_create(env,to_node,"http://www.murali.com/BESFactory",&text_node);
axis2_char_t *om_str = axiom_node_to_string(to_node,env);
if(om_str)
{
printf("\n To Element : %s\n", om_str);
AXIS2_FREE(env->allocator, om_str);
}
return to_node;
}
axiom_node_t* convertPBSToJSDL(const axutil_env_t *env)
{
/* Namespace element declarations */
axiom_namespace_t *jsdl_ns = NULL;
axiom_namespace_t *bes_factory_ns= NULL;
axiom_namespace_t *hpcp_ns=NULL;
axiom_namespace_t *xml_ns=NULL;
axiom_text_t *om_text=NULL;
axiom_node_t *text_node=NULL;
/* Body elements */
axiom_node_t *createactivity_node=NULL,*activity_node=NULL;
axiom_element_t *createactivity_element=NULL,*activity_element=NULL;
/* JSDL document element declarations */
axiom_node_t *jobdefinition_node=NULL,*jobidentification_node=NULL,*jobdescription_node=NULL,*jobname_node=NULL;
axiom_element_t *jobdefinition_element=NULL,*jobidentification_element=NULL,*jobdescription_element=NULL,*jobname_element=NULL;
/* HPCP - Application profile element declarations */
axiom_node_t *application_node=NULL,*applicationname_node=NULL,*executable_node=NULL,*stdout_node=NULL,*stderr_node=NULL,*working_node=NULL;
axiom_element_t *application_element=NULL,*applicationname_element=NULL,*executable_element=NULL,*stdout_element=NULL,*stderr_element=NULL,*working_element=NULL;
axiom_attribute_t *applicationname_attribute=NULL;
/* Creating all the namespace elements */
jsdl_ns=axiom_namespace_create(env,"http://schemas.ggf.org/jsdl/2005/11/jsdl","jsdl");
bes_factory_ns=axiom_namespace_create(env,"http://schemas.ggf.org/bes/2006/08/bes-factory","bes-factory");
hpcp_ns=axiom_namespace_create(env,"http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcp","jsdl-hpcp");
xml_ns=axiom_namespace_create(env,"http://www.w3.org/2001/XMLSchema-instance","xsi");
/* CreateActivity Element */
createactivity_element=axiom_element_create(env,NULL,"CreateActivity",bes_factory_ns,&createactivity_node);
/* ActivityDocument element */
activity_element=axiom_element_create(env,NULL,"ActivityDocument",bes_factory_ns,&activity_node);
jobdefinition_element=axiom_element_create(env,NULL,"JobDefinition",jsdl_ns,&jobdefinition_node);
jobdescription_element=axiom_element_create(env,NULL,"JobDescription",jsdl_ns,&jobdescription_node);
/* Job Identification element */
jobidentification_element=axiom_element_create(env,NULL,"JobIdentifiction",jsdl_ns,&jobidentification_node);
jobname_element=axiom_element_create(env,NULL,"JObName",jsdl_ns,&jobname_node);
//jobname_element to jobname_node
om_text=axiom_text_create(env,jobname_node,"PBSToCCS",&text_node);
axiom_node_add_child(jobidentification_node,env,jobname_node);
axiom_node_add_child(jobdescription_node,env,jobidentification_node);
application_element=axiom_element_create(env,NULL,"Application",jsdl_ns,&application_node);
applicationname_element=axiom_element_create(env,NULL,"HPCProfileApplication",hpcp_ns,&applicationname_node);
applicationname_attribute=axiom_attribute_create(env,"name","Example",NULL);
axiom_element_add_attribute(applicationname_element,env,applicationname_attribute,applicationname_node);
/* Executable Element */
executable_element=axiom_element_create(env,NULL,"Executable",hpcp_ns,&executable_node);
om_text=axiom_text_create(env,executable_node,"dir",&text_node);
axiom_node_add_child(applicationname_node,env,executable_node);
/* Stdout element */
stdout_element=axiom_element_create(env,NULL,"Output",hpcp_ns,&stdout_node);
om_text=axiom_text_create(env,stdout_node,"example.out",&text_node);
axiom_node_add_child(applicationname_node,env,stdout_node);
/* Stderr element */
stderr_element= axiom_element_create(env,NULL,"Error",hpcp_ns,&stderr_node);
om_text=axiom_text_create(env,stderr_node,"example.err",&text_node);
axiom_node_add_child(applicationname_node,env,stderr_node);
/* Working Directory Element */
working_element=axiom_element_create(env,NULL,"WorkingDirectory",hpcp_ns,&working_node);
om_text=axiom_text_create(env,working_node,"c:\\",&text_node);
axiom_node_add_child(applicationname_node,env,working_node);
axiom_node_add_child(application_node,env,applicationname_node);
axiom_node_add_child(jobdescription_node,env,application_node);
axiom_node_add_child(jobdefinition_node,env,jobdescription_node);
axiom_node_add_child(activity_node,env,jobdefinition_node);
axiom_node_add_child(createactivity_node,env,activity_node);
axis2_char_t *om_str=NULL;
om_str = axiom_node_to_string(createactivity_node,env);
if(om_str)
{
printf("\n Body Element : %s\n", om_str);
AXIS2_FREE(env->allocator, om_str);
}
return createactivity_node;
}
int createActivity()
{ axis2_endpoint_ref_t* endpoint_reference=NULL;
axis2_options_t *options=NULL;
const axis2_char_t *client_home=NULL;
axis2_svc_client_t *svc_client = NULL;
const axutil_env_t *env = NULL;
const axis2_char_t *address = NULL;
axis2_char_t *file_name = NULL;
axis2_char_t *file_name2 = NULL;
axiom_node_t *payload = NULL;
axiom_node_t *ret_node = NULL;
axis2_status_t status = AXIS2_FAILURE;
neethi_policy_t *policy = NULL;
/* Setup the environment */
env = axutil_env_create_all("PBSHPCP.log",AXIS2_LOG_LEVEL_TRACE);
/* Set end point reference of HPCP webservice */
address = "https://altair-winccss0.pbsgridworks/HPCBasicProfile/HPCBasicProfile.svc";
printf("Using Endpoint : %s \n", address);
/* Create EPR with given address */
endpoint_reference = axis2_endpoint_ref_create(env,address);
/* Setup options */
options = axis2_options_create(env);
axis2_options_set_to(options,env,endpoint_reference);
axis2_options_set_action(options,env,"http://schemas.ggf.org/bes/2006/08/bes-factory/BESFactoryPortType/CreateActivity");
axutil_property_t *server_certificate=axutil_property_create(env);
axutil_property_set_value(server_certificate,env,axutil_strdup(env,"/home/divakar/Desktop/examples/murali.pem"));
axis2_options_set_property(options,env,"SERVER_CERT",server_certificate);
/* Reading the Client Home from environment */
client_home = "/usr/local/axis2c";
if (!client_home || !strcmp (client_home, ""))
client_home=AXIS2_GETENV("$AXIS2_HOME");
/* Creating 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);
//modifies by div
printf("\nyour client home %s\n",client_home);
if(client_home)
{
file_name = axutil_stracat(env, client_home, AXIS2_PATH_SEP_STR);
printf("%s",file_name);
file_name2 = axutil_stracat(env, file_name, "./examples/client-policy.xml" );
printf("%s",file_name2);
AXIS2_FREE(env->allocator, file_name);
file_name = NULL;
}else{
printf("Client Home not Specified\n");
printf("echo client invoke FAILED!\n");
return 0;
}
/*Create the policy, from file*/
policy =neethi_util_create_policy_from_file(env,file_name2);
if(file_name2){
AXIS2_FREE(env->allocator, file_name2);
file_name2 = NULL;
}
if(!policy)
{
printf("\nPolicy creation failed from the file. %s\n", file_name2);
/*printf("echo client invoke FAILED!\n");
return 0;*/
}
status = axis2_svc_client_set_policy(svc_client, env, policy);
if(status == AXIS2_FAILURE)
{
printf("Policy setting failed\n");
}
else
printf("policy setting done");
//end
/* axis2_svc_client_disengage_module(svc_client,env,AXIS2_MODULE_ADDRESSING); */
/* axiom_node_t *header_node=getHeaderNode(env);
status = axis2_svc_client_add_header(svc_client,env,header_node);
if(status==AXIS2_FAILURE)
{
printf("Unable to add the header");
return -1;
}
else
{
printf (" \n Sucessfully Added the Header \n");
}*/
/* axiom_node_t *to_node=ToElement(env);
status=axis2_svc_client_add_header(svc_client,env,to_node);
if(status==AXIS2_FAILURE)
{
printf("Unable to add To element to the Header");
return -1;
}
else
{
printf (" \n TO Element added sucessfully to Header \n");
}
status=axis2_svc_client_set_target_endpoint_ref(svc_client,env,endpoint_reference);
if(status==AXIS2_FAILURE)
{
printf("Unable to set the endpoint reference");
return -1;
}*/
status=axis2_svc_client_engage_module(svc_client,env,AXIS2_MODULE_RAMPART);
//axis2_status_t *status=axis2_svc_client_engage_module(svc_client,env,AXIS2_MODULE_ADDRESSING);
if(status==AXIS2_FAILURE)
{
printf("Unable to add RAMPART element \n");
return -1;
}
rampart_context_t *rampart=rampart_context_create(env);
status=rampart_context_set_user(rampart,env,"pbsgridworks\\administrator");
if(status==AXIS2_FAILURE)
{
printf("Unable to set user element ");
return -1;
}
status=rampart_context_set_password(rampart,env,"[EMAIL PROTECTED]");
if(status==AXIS2_FAILURE)
{
printf("Unable to set password element ");
return -1;
}
axiom_node_t *security_node=NULL;
axiom_namespace_t *wsse_ns=NULL;
axiom_element_t *security_element=NULL;
wsse_ns=axiom_namespace_create(env,"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","wsse");
security_element=axiom_element_create(env,NULL,"Security",wsse_ns,&security_node);
status = rampart_username_token_build(env,rampart,security_node,wsse_ns);
if(status==AXIS2_FAILURE)
{
printf("Unable to Add usernametoken element \n");
return -1;
}
payload=convertPBSToJSDL(env);
if(payload==NULL)puts("no pay load");
axiom_node_t *ret=axis2_svc_client_send_receive(svc_client,env,payload);
if(ret)
{
axis2_char_t *om_str=NULL;
om_str = axiom_node_to_string(ret,env);
if(om_str)
{
printf("\nReceived OM : %s\n", om_str);
printf("\necho client invoke SUCCESSFUL!\n");
AXIS2_FREE(env->allocator, om_str);
} ret = NULL;
}
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 FAILED0!\n");
}
if (svc_client)
{
axis2_svc_client_free(svc_client, env);
svc_client = NULL;
}
if (env)
{
axutil_env_free((axutil_env_t *) env);
env = NULL;
}
return 0;
}
int main()
{
createActivity();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]