4.3 问题
按照上面的步骤执行脚本,发现有错,提示信息如下:
该问题暂时无法解决,需要再进一步的研究,现用soap_request函数实现webservice的测试。
本文出自黄进青的51Testing软件测试博客:http://www.51testing.com/?65519
版权声明:原创作品,转载请保留链接,标明本文原始出处、作者信息和本声明,否则将追究法律责任。
4.4 实现webservice测试
使用web_add_header(用户添加webservice头)、soap_request(用户向服务器发送webservice请求)、lr_convert_string_encoding(用于将webservice请求的XML转换为UTF-8格式,必须要转换为UTF-8格式,否则在请求的XML中如果含有中文字符的话将会请求失败)、和lr_eval_string(用于向soap_request函数传递转换后的UTF-8格式参数值)函数实现webservice测试,代码如下:
Action() { int rc = 0; unsigned long converted_buffer_size_unicode = 0; char *converted_buffer_unicode = NULL; char *strnew = NULL;
web_add_header("SOAPAction", "\"\""); web_add_header("User-Agent", "Jakarta Commons-HttpClient/3.1"); web_add_header("Content-Type", "text/xml;charset=UTF-8");
strnew= "SOAPEnvelope= <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://webservice.qr.ufmobile.cn/\"> <soapenv:Header/> <soapenv:Body> <web:uploadException><arg0>{NewParam_1}</arg0><arg1>number</arg1><arg2>有实物无帐</arg2><arg3>该产品没有入账</arg3><arg4>77804179</arg4><arg5>huangjq</arg5><arg6>96</arg6></web:uploadException></soapenv:Body></soapenv:Envelope>";
rc = lr_convert_string_encoding(strnew, LR_ENC_SYSTEM_LOCALE, LR_ENC_UTF8, "new");
//上传异常盘点信息 soap_request("StepName=login", "URL=http://10.192.17.40/PanasonicQR/MobileService/UploadInventoryService", lr_eval_string("{new}"), "Snapshot=t1.inf", "ResponseParam=result", LAST); return 0; } |