Attachment 'test_client_ipv6.cpp'

Download

   1 #ifdef HAVE_CONFIG_H
   2 #include <config.h>
   3 #endif
   4 
   5 #include <iostream>
   6 #include <signal.h>
   7 
   8 #include <arc/ArcConfig.h>
   9 #include <arc/Logger.h>
  10 #include <arc/loader/Loader.h>
  11 #include <arc/message/SOAPEnvelope.h>
  12 #include <arc/message/PayloadSOAP.h>
  13 
  14 int main(void) {
  15 #ifndef WIN32
  16   signal(SIGTTOU,SIG_IGN);
  17   signal(SIGTTIN,SIG_IGN);
  18 #endif
  19   Arc::Logger logger(Arc::Logger::rootLogger, "Test");
  20   Arc::LogStream logcerr(std::cerr);
  21   Arc::Logger::rootLogger.addDestination(logcerr);
  22   logger.msg(Arc::INFO, "Creating client side chain");
  23   // Create client chain
  24   Arc::XMLNode client_doc("\
  25     <ArcConfig\
  26       xmlns=\"http://www.nordugrid.org/schemas/ArcConfig/2007\"\
  27       xmlns:tcp=\"http://www.nordugrid.org/schemas/ArcMCCTCP/2007\">\
  28      <ModuleManager>\
  29         <Path>.libs/</Path>\
  30         <Path>../../hed/mcc/http/.libs/</Path>\
  31         <Path>../../hed/mcc/soap/.libs/</Path>\
  32         <Path>../../hed/mcc/tls/.libs/</Path>\
  33         <Path>../../hed/mcc/tcp/.libs/</Path>\
  34      </ModuleManager>\
  35      <Plugins><Name>mcctcp</Name></Plugins>\
  36      <Plugins><Name>mcctls</Name></Plugins>\
  37      <Plugins><Name>mcchttp</Name></Plugins>\
  38      <Plugins><Name>mccsoap</Name></Plugins>\
  39      <Chain>\
  40       <Component name='tcp.client' id='tcp'><tcp:Connect><tcp:Host>::1</tcp:Host><tcp:Port>60000</tcp:Port></tcp:Connect></Component>\
  41       <Component name='http.client' id='http'><next id='tcp'/><Method>POST</Method><Endpoint>/Echo</Endpoint></Component>\
  42       <Component name='soap.client' id='soap' entry='soap'><next id='http'/></Component>\
  43      </Chain>\
  44     </ArcConfig>");
  45   Arc::Config client_config(client_doc);
  46   if(!client_config) {
  47     logger.msg(Arc::ERROR, "Failed to load client configuration");
  48     return -1;
  49   };
  50   Arc::Loader client_loader(&client_config);
  51   logger.msg(Arc::INFO, "Client side MCCs are loaded");
  52   Arc::MCC* client_entry = client_loader["soap"];
  53   if(!client_entry) {
  54     logger.msg(Arc::ERROR, "Client chain does not have entry point");
  55     return -1;
  56   };
  57 
  58   // for (int i = 0; i < 10; i++) {
  59   // Create and send echo request
  60   logger.msg(Arc::INFO, "Creating and sending request");
  61   Arc::NS echo_ns; echo_ns["echo"]="urn:echo";
  62   Arc::PayloadSOAP req(echo_ns);
  63   req.NewChild("echo").NewChild("say")="HELLO";
  64   Arc::Message reqmsg;
  65   Arc::Message repmsg;
  66   reqmsg.Payload(&req);
  67   // It is a responsibility of code initiating first Message to
  68   // provide Context and Attributes as well.
  69   Arc::MessageAttributes attributes_req;
  70   Arc::MessageAttributes attributes_rep;
  71   Arc::MessageContext context;
  72   reqmsg.Attributes(&attributes_req);
  73   reqmsg.Context(&context);
  74   repmsg.Attributes(&attributes_rep);
  75   repmsg.Context(&context);
  76   Arc::MCC_Status status = client_entry->process(reqmsg,repmsg);
  77   if(!status) {
  78     logger.msg(Arc::ERROR, "Request failed");
  79     std::cerr << "Status: " << std::string(status) << std::endl;
  80     return -1;
  81   };
  82   Arc::PayloadSOAP* resp = NULL;
  83   if(repmsg.Payload() == NULL) {
  84     logger.msg(Arc::ERROR, "There is no response");
  85     return -1;
  86   };
  87   try {
  88     resp = dynamic_cast<Arc::PayloadSOAP*>(repmsg.Payload());
  89   } catch(std::exception&) { };
  90   if(resp == NULL) {
  91     logger.msg(Arc::ERROR, "Response is not SOAP");
  92     return -1;
  93   };
  94   std::string xml;
  95   resp->GetXML(xml);
  96   std::cout << "XML: "<< xml << std::endl;
  97   std::cout << "Response: " << (std::string)((*resp)["echoResponse"]["hear"]) << std::endl;
  98   //}    
  99   return 0;
 100 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2008-02-13 18:46:41, 3.2 KB) [[attachment:patch-MCCTCP.cpp.diff]]
  • [get | view] (2008-02-13 18:47:03, 3.0 KB) [[attachment:patch-PayloadTCPSocket.cpp.diff]]
  • [get | view] (2008-02-13 18:47:38, 1.4 KB) [[attachment:service.xml]]
  • [get | view] (2008-02-13 18:59:44, 9.1 KB) [[attachment:service_script.txt]]
  • [get | view] (2008-02-13 19:08:19, 3.3 KB) [[attachment:test_client_ipv4.cpp]]
  • [get | view] (2008-02-13 18:54:28, 3.3 KB) [[attachment:test_client_ipv6.cpp]]
  • [get | view] (2008-02-13 18:53:03, 25.6 KB) [[attachment:test_service_netstat.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.