loadrunner 测试webservice接口问题求助
在使用loadrunner测试天气预报webservice接口时,发送的请求中带中文,不能识别,要转成utf8格式的,使用lr_convert_string_encoding做转换,比如lr_convert_string_encoding("上海",LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"test1"),“上海”可以转换为“涓婃捣\x00”,去掉“\x00”后,可以得到想要的结果。
soap_request("StepName=SOAP Request",
"URL=http://webservice.webxml.com.cn/webservices/weatherws.asmx",
"SOAPEnvelope="
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://WebXml.com.cn/\">"
"<soapenv:Header></soapenv:Header>"
"<soapenv:Body>"
"<web:getSupportCityString>"
"<web:theRegionCode>涓婃捣</web:theRegionCode>"
"</web:getSupportCityString>"
"</soapenv:Body>"
"</soapenv:Envelope>",
"SOAPAction=http://WebXml.com.cn/getSupportCityString",
"ResponseParam=response",
"Snapshot=t1383210041.inf",
LAST);
但是有部分中文转换后带有字符,比如“黑龙江”转换后是“榛戦緳姹\x9f\x00”
这种转换后带字符的应该怎么处理? 字符后面加\应该可以吧?即:榛戦緳姹\\x9f。你试试一下? :lol已解决
lr_convert_string_encoding("黑龙江",LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"test1");
lr_save_string(lr_eval_string("{test1}"),"haha");
soap_request("StepName=SOAP Request",
"URL=http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx",
"SOAPEnvelope="
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://WebXml.com.cn/\">"
"<soapenv:Header></soapenv:Header>"
"<soapenv:Body>"
"<web:getSupportCityString>"
"<web:theRegionCode>{haha}</web:theRegionCode>"
"</web:getSupportCityString>"
"</soapenv:Body>"
"</soapenv:Envelope>",
"SOAPAction=http://WebXml.com.cn/getSupportCityString",
"ResponseParam=response",
"Snapshot=t1383644195.inf",
LAST);
return 0; 这种一问一答的精神值得鼓励一下
解决了问题就应该共享下心得 :victory:
页:
[1]