本文整理汇总了C++中Message::Attributes方法的典型用法代码示例。如果您正苦于以下问题:C++ Message::Attributes方法的具体用法?C++ Message::Attributes怎么用?C++ Message::Attributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::Attributes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: submit
//.........这里部分代码省略.........
if (deleg_cert.empty() || deleg_key.empty()) {
logger.msg(ERROR, "Failed to find delegation credentials in "
"client configuration");
return false;
}
}
// Send job request + delegation
if (client) {
if (delegate) {
DelegationProviderSOAP deleg(deleg_cert, deleg_key);
logger.msg(INFO, "Initiating delegation procedure");
if (!deleg.DelegateCredentialsInit(*(client->GetEntry()),
&(client->GetContext()))) {
logger.msg(ERROR, "Failed to initiate delegation");
return false;
}
deleg.DelegatedToken(op);
}
MCC_Status status =
client->process("http://schemas.ggf.org/bes/2006/08/bes-factory/"
"BESFactoryPortType/CreateActivity", &req, &resp);
if (!status) {
logger.msg(ERROR, "Submission request failed");
return false;
}
if (resp == NULL) {
logger.msg(VERBOSE, "There was no SOAP response");
return false;
}
}
else if (client_entry) {
Message reqmsg;
Message repmsg;
MessageAttributes attributes_req;
attributes_req.set("SOAP:ACTION", "http://schemas.ggf.org/bes/2006/08/"
"bes-factory/BESFactoryPortType/CreateActivity");
MessageAttributes attributes_rep;
MessageContext context;
if (delegate) {
DelegationProviderSOAP deleg(deleg_cert, deleg_key);
logger.msg(INFO, "Initiating delegation procedure");
if (!deleg.DelegateCredentialsInit(*client_entry, &context)) {
logger.msg(ERROR, "Failed to initiate delegation");
return false;
}
deleg.DelegatedToken(op);
}
reqmsg.Payload(&req);
reqmsg.Attributes(&attributes_req);
reqmsg.Context(&context);
repmsg.Attributes(&attributes_rep);
repmsg.Context(&context);
MCC_Status status = client_entry->process(reqmsg, repmsg);
if (!status) {
logger.msg(ERROR, "Submission request failed");
return false;
}
logger.msg(INFO, "Submission request succeed");
if (repmsg.Payload() == NULL) {
logger.msg(VERBOSE, "There was no response to a submission request");
return false;
}
try {
resp = dynamic_cast<PayloadSOAP*>(repmsg.Payload());
} catch (std::exception&) {}
示例2: kill
bool UNICOREClient::kill(const std::string& jobid) {
std::string result, faultstring;
logger.msg(INFO, "Creating and sending request to terminate a job");
PayloadSOAP req(unicore_ns);
XMLNode jobref =
req.NewChild("bes-factory:TerminateActivities").
NewChild(XMLNode(jobid));
set_bes_factory_action(req, "TerminateActivities");
WSAHeader(req).To(rurl.str());
// Send kill request
PayloadSOAP *resp = NULL;
if (client) {
MCC_Status status =
client->process("http://schemas.ggf.org/bes/2006/08/bes-factory/"
"BESFactoryPortType/TerminateActivities", &req, &resp);
if (resp == NULL) {
logger.msg(VERBOSE, "There was no SOAP response");
return false;
}
}
else if (client_entry) {
Message reqmsg;
Message repmsg;
MessageAttributes attributes_req;
attributes_req.set("SOAP:ACTION", "http://schemas.ggf.org/bes/2006/08/"
"bes-factory/BESFactoryPortType/TerminateActivities");
MessageAttributes attributes_rep;
MessageContext context;
reqmsg.Payload(&req);
reqmsg.Attributes(&attributes_req);
reqmsg.Context(&context);
repmsg.Attributes(&attributes_rep);
repmsg.Context(&context);
MCC_Status status = client_entry->process(reqmsg, repmsg);
if (!status) {
logger.msg(ERROR, "A job termination request failed");
return false;
}
logger.msg(INFO, "A job termination request succeed");
if (repmsg.Payload() == NULL) {
logger.msg(VERBOSE, "There was no response to a job termination request");
return false;
}
try {
resp = dynamic_cast<PayloadSOAP*>(repmsg.Payload());
} catch (std::exception&) {}
if (resp == NULL) {
logger.msg(ERROR, "The response of a job termination request was "
"not a SOAP message");
delete repmsg.Payload();
return false;
}
}
else {
logger.msg(ERROR, "There is no connection chain configured");
return false;
}
XMLNode cancelled, fs;
(*resp)["TerminateActivitiesResponse"]
["Response"]["Cancelled"].New(cancelled);
result = (std::string)cancelled;
(*resp)["Fault"]["faultstring"].New(fs);
faultstring = (std::string)fs;
delete resp;
if (faultstring != "") {
logger.msg(ERROR, faultstring);
return false;
}
if (result != "true") {
logger.msg(ERROR, "Job termination failed");
return false;
}
return true;
}
示例3: clean
bool UNICOREClient::clean(const std::string& jobid) {
std::string result, faultstring;
logger.msg(INFO, "Creating and sending request to terminate a job");
PayloadSOAP req(unicore_ns);
XMLNode op = req.NewChild("a-rex:ChangeActivityStatus");
XMLNode jobref = op.NewChild(XMLNode(jobid));
XMLNode jobstate = op.NewChild("a-rex:NewStatus");
jobstate.NewAttribute("bes-factory:state") = "Finished";
jobstate.NewChild("a-rex:state") = "Deleted";
// Send clean request
PayloadSOAP *resp = NULL;
if (client) {
MCC_Status status = client->process("", &req, &resp);
if (resp == NULL) {
logger.msg(VERBOSE, "There was no SOAP response");
return false;
}
}
else if (client_entry) {
Message reqmsg;
Message repmsg;
MessageAttributes attributes_req;
MessageAttributes attributes_rep;
MessageContext context;
reqmsg.Payload(&req);
reqmsg.Attributes(&attributes_req);
reqmsg.Context(&context);
repmsg.Attributes(&attributes_rep);
repmsg.Context(&context);
MCC_Status status = client_entry->process(reqmsg, repmsg);
if (!status) {
logger.msg(ERROR, "A job cleaning request failed");
return false;
}
logger.msg(INFO, "A job cleaning request succeed");
if (repmsg.Payload() == NULL) {
logger.msg(VERBOSE, "There was no response to a job cleaning request");
return false;
}
try {
resp = dynamic_cast<PayloadSOAP*>(repmsg.Payload());
} catch (std::exception&) {}
if (resp == NULL) {
logger.msg(ERROR, "The response of a job cleaning request was not "
"a SOAP message");
delete repmsg.Payload();
return false;
}
}
else {
logger.msg(ERROR, "There is no connection chain configured");
return false;
}
if (!((*resp)["ChangeActivityStatusResponse"])) {
delete resp;
XMLNode fs;
(*resp)["Fault"]["faultstring"].New(fs);
faultstring = (std::string)fs;
if (faultstring != "") {
logger.msg(ERROR, faultstring);
return false;
}
if (result != "true") {
logger.msg(ERROR, "Job termination failed");
return false;
}
}
delete resp;
return true;
}
示例4: sstat
bool UNICOREClient::sstat(std::string& status) {
std::string state, faultstring;
logger.msg(INFO, "Creating and sending a service status request");
PayloadSOAP req(unicore_ns);
XMLNode jobref =
req.NewChild("bes-factory:GetFactoryAttributesDocument");
set_bes_factory_action(req, "GetFactoryAttributesDocument");
WSAHeader(req).To(rurl.str());
// Send status request
PayloadSOAP *resp = NULL;
if (client) {
MCC_Status status =
client->process("http://schemas.ggf.org/bes/2006/08/bes-factory/"
"BESFactoryPortType/GetFactoryAttributesDocument",
&req, &resp);
if (resp == NULL) {
logger.msg(VERBOSE, "There was no SOAP response");
return false;
}
}
else if (client_entry) {
Message reqmsg;
Message repmsg;
MessageAttributes attributes_req;
attributes_req.set("SOAP:ACTION", "http://schemas.ggf.org/bes/2006/08/"
"bes-factory/BESFactoryPortType/"
"GetFactoryAttributesDocument");
MessageAttributes attributes_rep;
MessageContext context;
reqmsg.Payload(&req);
reqmsg.Attributes(&attributes_req);
reqmsg.Context(&context);
repmsg.Attributes(&attributes_rep);
repmsg.Context(&context);
MCC_Status status = client_entry->process(reqmsg, repmsg);
if (!status) {
logger.msg(ERROR, "A service status request failed");
return false;
}
logger.msg(INFO, "A service status request succeeded");
if (repmsg.Payload() == NULL) {
logger.msg(VERBOSE, "There was no response to a service status request");
return false;
}
try {
resp = dynamic_cast<PayloadSOAP*>(repmsg.Payload());
} catch (std::exception&) {}
if (resp == NULL) {
logger.msg(ERROR, "The response of a service status request was "
"not a SOAP message");
delete repmsg.Payload();
return false;
}
}
else {
logger.msg(ERROR, "There is no connection chain configured");
return false;
}
XMLNode st;
logger.msg(DEBUG, "Response:\n%s", (std::string)(*resp));
(*resp)["GetFactoryAttributesDocumentResponse"]
["FactoryResourceAttributesDocument"].New(st);
st.GetDoc(state, true);
delete resp;
if (state == "") {
logger.msg(ERROR, "The service status could not be retrieved");
return false;
}
else {
status = state;
return true;
}
}
示例5: stat
bool UNICOREClient::stat(const std::string& jobid, std::string& status) {
std::string state, substate, faultstring;
logger.msg(INFO, "Creating and sending a status request");
PayloadSOAP req(unicore_ns);
XMLNode jobref =
req.NewChild("bes-factory:GetActivityStatuses").
NewChild(XMLNode(jobid));
set_bes_factory_action(req, "GetActivityStatuses");
WSAHeader(req).To(rurl.str());
// Send status request
PayloadSOAP *resp = NULL;
if (client) {
MCC_Status status =
client->process("http://schemas.ggf.org/bes/2006/08/bes-factory/"
"BESFactoryPortType/GetActivityStatuses", &req, &resp);
if (resp == NULL) {
logger.msg(VERBOSE, "There was no SOAP response");
return false;
}
}
else if (client_entry) {
Message reqmsg;
Message repmsg;
MessageAttributes attributes_req;
attributes_req.set("SOAP:ACTION", "http://schemas.ggf.org/bes/2006/08/"
"bes-factory/BESFactoryPortType/GetActivityStatuses");
MessageAttributes attributes_rep;
MessageContext context;
reqmsg.Payload(&req);
reqmsg.Attributes(&attributes_req);
reqmsg.Context(&context);
repmsg.Attributes(&attributes_rep);
repmsg.Context(&context);
MCC_Status status = client_entry->process(reqmsg, repmsg);
if (!status) {
logger.msg(ERROR, "A status request failed");
return false;
}
logger.msg(INFO, "A status request succeed");
if (repmsg.Payload() == NULL) {
logger.msg(VERBOSE, "There was no response to a status request");
return false;
}
try {
resp = dynamic_cast<PayloadSOAP*>(repmsg.Payload());
} catch (std::exception&) {}
if (resp == NULL) {
logger.msg(ERROR,
"The response of a status request was not a SOAP message");
delete repmsg.Payload();
return false;
}
}
else {
logger.msg(ERROR, "There is no connection chain configured");
return false;
}
XMLNode st, fs;
(*resp)["GetActivityStatusesResponse"]["Response"]
["ActivityStatus"].New(st);
state = (std::string)st.Attribute("state");
XMLNode sst;
(*resp)["GetActivityStatusesResponse"]["Response"]
["ActivityStatus"]["state"].New(sst);
substate = (std::string)sst;
(*resp)["Fault"]["faultstring"].New(fs);
faultstring = (std::string)fs;
delete resp;
if (faultstring != "") {
logger.msg(ERROR, faultstring);
return false;
}
else if (state == "") {
logger.msg(ERROR, "The job status could not be retrieved");
return false;
}
else {
status = state + "/" + substate;
return true;
}
}
示例6: uasStartJob
bool UNICOREClient::uasStartJob(){
std::string state, faultstring;
logger.msg(INFO, "Creating and sending a start job request");
PayloadSOAP req(unicore_ns);
XMLNode SOAPMethod =
req.NewChild("jms:Start");
WSAHeader(req).To(rurl.str());
WSAHeader(req).Action("http://schemas.ggf.org/bes/2006/08/bes-activity/BESActivityPortType/StartRequest");
// Send status request
PayloadSOAP *resp = NULL;
if (client) {
MCC_Status status =
client->process("http://schemas.ggf.org/bes/2006/08/bes-activity/BESActivityPortType/StartRequest",
&req, &resp);
if (resp == NULL) {
logger.msg(VERBOSE, "There was no SOAP response");
return false;
}
}
else if (client_entry) {
Message reqmsg;
Message repmsg;
MessageAttributes attributes_req;
attributes_req.set("SOAP:ACTION", "http://schemas.ggf.org/bes/2006/08/bes-activity/BESActivityPortType/StartRequest");
MessageAttributes attributes_rep;
MessageContext context;
reqmsg.Payload(&req);
reqmsg.Attributes(&attributes_req);
reqmsg.Context(&context);
repmsg.Attributes(&attributes_rep);
repmsg.Context(&context);
MCC_Status status = client_entry->process(reqmsg, repmsg);
if (!status) {
logger.msg(ERROR, "A start job request failed");
return false;
}
logger.msg(INFO, "A start job request succeeded");
if (repmsg.Payload() == NULL) {
logger.msg(VERBOSE, "There was no response to a start job request");
return false;
}
try {
resp = dynamic_cast<PayloadSOAP*>(repmsg.Payload());
} catch (std::exception&) {}
if (resp == NULL) {
logger.msg(ERROR, "The response of a start job request was "
"not a SOAP message");
delete repmsg.Payload();
return false;
}
}
else {
logger.msg(ERROR, "There is no connection chain configured");
return false;
}
SOAPFault fs(*resp);
if (!fs) {
return true;
}
else {
faultstring = fs.Reason();
std::string s;
resp->GetXML(s);
delete resp;
logger.msg(DEBUG, "Submission returned failure: %s", s);
logger.msg(ERROR, "Submission failed, service returned: %s", faultstring);
return false;
}
}
示例7: process
MCC_Status MCC_SOAP_Client::process(Message& inmsg,Message& outmsg) {
// Extracting payload
if(!inmsg.Payload()) return make_soap_fault(outmsg,true,"No message to send");
PayloadSOAP* inpayload = NULL;
try {
inpayload = dynamic_cast<PayloadSOAP*>(inmsg.Payload());
} catch(std::exception& e) { };
if(!inpayload) return make_soap_fault(outmsg,true,"No SOAP message to send");
//Checking authentication and authorization;
if(!ProcessSecHandlers(inmsg,"outgoing")) {
logger.msg(ERROR, "Security check failed in SOAP MCC for outgoing message");
return make_soap_fault(outmsg,true,"Security check failed for outgoing SOAP message");
};
// Converting payload to Raw
PayloadRaw nextpayload;
std::string xml; inpayload->GetXML(xml);
nextpayload.Insert(xml.c_str());
// Creating message to pass to next MCC and setting new payload..
Message nextinmsg = inmsg;
nextinmsg.Payload(&nextpayload);
// Specifying attributes for binding to underlying protocols - HTTP so far
std::string soap_action;
bool soap_action_defined = inmsg.Attributes()->count("SOAP:ACTION") > 0;
if(soap_action_defined) {
soap_action=inmsg.Attributes()->get("SOAP:ACTION");
} else {
soap_action_defined=true; //WSAHeader(*inpayload).hasAction(); - SOAPAction must be always present
soap_action=WSAHeader(*inpayload).Action();
};
if(inpayload->Version() == SOAPEnvelope::Version_1_2) {
std::string mime_type("application/soap+xml");
if(soap_action_defined) mime_type+=" ;action=\""+soap_action+"\"";
nextinmsg.Attributes()->set("HTTP:Content-Type",mime_type);
} else {
nextinmsg.Attributes()->set("HTTP:Content-Type","text/xml");
if(soap_action_defined) nextinmsg.Attributes()->set("HTTP:SOAPAction","\""+soap_action+"\"");
};
// Call next MCC
MCCInterface* next = Next();
if(!next) return make_soap_fault(outmsg,true,"Internal chain failure: no next component");
Message nextoutmsg = outmsg; nextoutmsg.Payload(NULL);
MCC_Status ret = next->process(nextinmsg,nextoutmsg);
// Do checks and create SOAP response
// TODO: pass SOAP action from HTTP header to SOAP:ACTION attribute
if(!ret) {
std::string errstr = "Failed to send SOAP message: "+(std::string)ret;
return make_soap_fault(outmsg,nextoutmsg,false,errstr.c_str());
};
if(!nextoutmsg.Payload()) {
return make_soap_fault(outmsg,nextoutmsg,false,"No response for SOAP message recieved");
};
MessagePayload* retpayload = nextoutmsg.Payload();
if(!retpayload) return make_soap_fault(outmsg,nextoutmsg,false,"No valid response for SOAP message recieved");
PayloadSOAP* outpayload = new PayloadSOAP(*retpayload);
if(!outpayload) {
return make_soap_fault(outmsg,nextoutmsg,false,"Response is not SOAP");
};
if(!(*outpayload)) {
delete outpayload; return make_soap_fault(outmsg,nextoutmsg,false,"Response is not valid SOAP");
};
outmsg = nextoutmsg;
outmsg.Payload(outpayload);
delete nextoutmsg.Payload(); nextoutmsg.Payload(NULL);
//Checking authentication and authorization;
if(!ProcessSecHandlers(outmsg,"incoming")) {
logger.msg(ERROR, "Security check failed in SOAP MCC for incoming message");
delete outpayload; return make_soap_fault(outmsg,false,"Security check failed for incoming SOAP message");
};
return MCC_Status(STATUS_OK);
}