认真能把事做对,用心才能把事做好,专心、专注、心注未来。 声明:本博客内容除特别注明转载外全部是个人工作总结,转载时请注明出处!

使用HTTP协议进行SOAP模拟

上一篇 / 下一篇  2012-07-24 10:50:33 / 个人分类:原创

  Action()
{
     int num ;
 int maxlens =27344150;
    //soap消息http请求头中的字段--服务器地址
    web_add_header("SOAPAction", "http://10.40.33.19:38090/nvsauc/services/cmccSOAP");
 web_set_max_html_param_len("27344150");
 //保存响应用于分析返回结果
 web_reg_save_param("rcontext","LB=","RB=","SEARCH=BODY",LAST);
 //模仿soap消息请求
    web_custom_request("CVRequest",
       "Method=POST",
       "Mode=HTML",
        "RecContentType=text/xml",
        "EncType=text/xml",
        "URL=http://10.40.33.19:38090/nvsauc/services/cmccSOAP",
        "Body=<?xml version='1.0'  encoding='UTF-8' standalone='no'?>"
  "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
  " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
  "<SOAP-ENV:Body><tns:CVRequest xmlns:tns='http://www.cmcc.com/cv/'>"
   "<Version>1.0</Version><MsgType>AUTH_ADC</MsgType><MsgSeq>00000001</MsgSeq>"
  "<TimeStamp>20110125184544</TimeStamp><CVBody>&lt;Msg_Body&gt;&lt;"
  "EcCode&gt;8888800001&lt;/EcCode&gt;&lt;"
  "UserName&gt;{NewParam}&lt;/UserName&gt;"
  "&lt;Password&gt;000000&lt;/Password&gt;"
  "&lt;ClientType&gt;1&lt;/ClientType&gt;&lt;/Msg_Body&gt;"
  "</CVBody></tns:CVRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>",
        LAST);
  
   //解析响应
   lr_xml_get_values ("XML={rcontext}",
             "Query=/Envelope/Body/CVResponse/CVBody",
             "ValueParam=OutputParam",
                 LAST);
   lr_xml_find("XML={OutputParam}",
       "Query=/MSG_BODY/AuthResultCode",
       "Value=0",
       LAST);
   lr_xml_get_values ("XML={OutputParam}",
             "Query=/MSG_BODY/Token",
             "ValueParam=Token",
                 LAST);
   lr_output_message(lr_eval_string("{rcontext}"));
  lr_output_message(lr_eval_string("{OutputParam}"));
  lr_output_message(lr_eval_string("{Token}"));
  web_add_header("SOAPAction", "http://10.40.33.19:38090/nvsauc/services/cmccSOAP");
      //模仿soap消息请求
    web_custom_request("CVRequest",
       "Method=POST",
       "Mode=HTML",
        "RecContentType=text/xml",
        "EncType=text/xml",
        "URL=http://10.40.33.19:38090/nvsauc/services/cmccSOAP",
        "Body=<?xml version='1.0'  encoding='UTF-8' standalone='no'?>"
  "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
  " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
  "<SOAP-ENV:Body><tns:CVRequest xmlns:tns='http://www.cmcc.com/cv/'>"
  "<Version>1.0</Version><MsgType>HEARTBEAT</MsgType><MsgSeq>00000001</MsgSeq>"
  "<TimeStamp>20110125184544</TimeStamp><CVBody>&lt;Msg_Body&gt;&lt;"
  "Token&gt;{Token}&lt;/Token&gt;&lt;"
  "Source&gt;0&lt;/Source&gt;"
        "&lt;/Msg_Body&gt;"
  "</CVBody></tns:CVRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>",
        LAST);

 //聚集集合点
    lr_rendezvous("authadc");
 //开启事务
 lr_start_transaction("webplay");

  //保存响应用于分析返回结果
 web_reg_save_param("nvssgwreq","LB=","RB=","SEARCH=BODY",LAST);
 
 //soap消息http请求头中的字段--服务器地址
    web_add_header("SOAPAction", "http://10.40.33.19:48090/nvssgw/services/cmccSOAP");  

      //模仿soap消息请求---web 获取设备列表
 /** */
    web_custom_request("CVRequest",
       "Method=POST",
       "Mode=HTML",
        "RecContentType=text/xml",
        "EncType=text/xml",
        "URL=http://10.40.33.19:48090/nvssgw/services/cmccSOAP",
        "Body=<?xml version='1.0'  encoding='UTF-8' standalone='no'?>"
  "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
  " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
  "<SOAP-ENV:Body><tns:CVRequest xmlns:tns='http://www.cmcc.com/cv/'>"
  "<Version>1.0</Version><MsgType>WEB_PLAY_LIST</MsgType><MsgSeq>00000001</MsgSeq>"
  "<TimeStamp>20110125184544</TimeStamp><CVBody>&lt;Msg_Body&gt;&lt;"
        "EcCode&gt;8888800001&lt;/EcCode&gt;&lt;"
     "Area&gt;01&lt;/Area&gt;&lt;"
  "UserName&gt;{NewParam_1}&lt;/UserName&gt;&lt;"  
  "Token&gt;{Token}&lt;/Token&gt;"
        "&lt;/Msg_Body&gt;"
  "</CVBody></tns:CVRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>",
        LAST);
 
 lr_output_message(lr_eval_string("{nvssgwreq}"));

 lr_xml_get_values ("XML={nvssgwreq}",
             "Query=/Envelope/Body/CVResponse/Result",
             "ValueParam=Result",
                 LAST);
 num = lr_output_message("%d", lr_output_message(lr_eval_string("{Result}")));

  if(1==num)
  {
   lr_output_message("成功!");
   lr_end_transaction("webplay", LR_PASS);
  }
  else
  {
     lr_output_message("失败!");
   lr_end_transaction("webplay", LR_FAIL);
  }
 
 return 0;
}
 

TAG: http HTTP SOAP websevice

 

评分:0

我来说两句

Open Toolbar