您的位置:首页 > 产品设计 > UI/UE

loadrunner Web_类函数之soap_request()

2017-09-26 20:34 369 查看

soap_request()

执行SOAP请求。

intsoap_request(const char* StepName,ExpectedResponse,URL,<XMLEnvelope>,[Attachments,] LAST);

 

参数说明:

StepName:步骤的名称,它出现在测试树中。可以使用任何文本。

ExpectedResponse:要接受的响应的类型。详情如下。

URL:要加载的Web服务的URL(统一资源定位符)。

XMLEnvelope:对于以下所需元素列表,请使用以下字符串格式:

“Element = value”

    SOAPEnvelope:发送到服务器的XML包。

    Snapshot:包含步骤快照的.inf文件的名称。

    ResponseParam:存储服务器响应的输出参数的名称。

Attachments:有关详细信息,请参阅附件规格。

LAST:指示规格列表的结束的标记

 

soap_request函数执行SOAP请求。它将SOAP数据包发送到指定的URL并接收服务器响应。

预期响应为以下之一:

Value  Effect (值 效应)

“ExpectedResponse = SoapResult”接受SOAP输出响应并在SOAP故障上失败。

“ExpectedResponse =

SoapFault“接受SOAP故障,并在SOAP输出响应失败。

“ExpectedResponse =

AnySoap“接受SOAP输出和SOAP故障响应。

当您通过HTTP记录SOAP会话而不提供相应Web服务的WSDL文件时,服务测试会生成此函数。

 

示例:soap_request

在第一个示例中,soap_request函数将SOAP数据包发送到http://api.google.com/search/beta2。

web_add_header(“SOAPAction”

        “\”urn:GoogleSearchAction \“”);

soap_request(“StepName = google”,

“ExpectedResponse = AnySoap”,

“URL = http://api.google.com/search/beta2”,

“SOAPEnvelope =”

    “<?xml version = \”1.0 \“encoding = \”utf-8\“?”“

    “<soap:Envelope”

        “xmlns:soap = \”http://schemas.xmlsoap.org/soap/envelope/ \“”

        “xmlns:soapenc = \”“

        “http://schemas.xmlsoap.org/soap/encoding/\”“

        “xmlns:tns = \”urn:GoogleSearch \“”

        “xmlns:types = \”urn:GoogleSearch / encodedTypes \“”

        “xmlns:xsi = \”“

        “http://www.w3.org/2001/XMLSchema-instance\”“

        “xmlns:xsd = \”“

         “http://www.w3.org/2001/XMLSchema\”>“

    “<soap:Body soap:encodingStyle = \”“

         “http://schemas.xmlsoap.org/soap/encoding/\”>“

    “<tns:doGoogleSearch>”

        “<key xsi:type = \”xsd:string \“>”

         “j1bV / rJGA3o10po6iUtemzqHHbb4eH79 </key>”

        “<q xsi:type = \”xsd:string \“>”

         “LoadRunner </ q>”

        “<start xsi:type = \”xsd:int \“> 0</ start>”

        “<maxResults xsi:type= \”“

         “xsd:int \”> 10 </ maxResults>“

        “<filter xsi:type =\”xsd:boolean \“> false </ filter>”

         “<restrict xsi:type= \”xsd:string \“/>”

        “<safeSearch xsi:type= \”xsd:boolean \“>”

         “false </ safeSearch>”

        “<lr xsi:type = \”xsd:string \“/>”

        “<ie xsi:type = \”xsd:string \“/>”

        “<oe xsi:type = \”xsd:string \“/>”

    “</ tns:doGoogleSearch>”

    “</ soap:Body>”

    “</ soap:Envelope>”,

“Snapshot = t1.inf”,

“ResponseParam = result”,

LAST);

 

在第二个示例中,soap_request函数上传和下载文件。

 

web_add_header(“SOAPAction”,“\”\“”);

//Soap_Request用于上传文件

soap_request(“StepName = MimeUploadFileWithSapapRequest”,

    “URL = http:// myServer:8080 / axis / services / MimeService”,

    “SOAPEnvelope =”

        “<?xml version = \”1.0 \“encoding = \”UTF-8\“standalone = \”no \“?

        <soap:Envelope xmlns:soap =\“http:// sc”

        “hemas.xmlsoap.org/soap/envelope/ \”

        “xmlns:xsi = \”http://www.w3.org/2001/XMLSchema-instance \“xm”

        “lns:xsd = \”http://www.w3.org/2001/XMLSchema \“

        “xmlns:tns = \”http:// DefaultNamespace \“xmlns:types”

        “= \”http:// DefaultNamespace \“

        xmlns:soapenc = \“http://schemas.xmlsoap.org/soap/encoding/ \”>“

        “<soap:Body soap:encodingStyle =”

        “\”http://schemas.xmlsoap.org/soap/encoding/ \“>”

        “<tns:MimeUploadFile><”in0 xsi:type = \“xsd:string \”> d“

        “:\\ temp \\ myUploaded1.txt </ in0></ tns:MimeUploadFile>”

        </soap:Body> </ soap:Envelope>“,

        ATTACHMENTS_FORMAT_MIME,

        ATTACHMENT_ADD,“FileName = d:\\ temp\\ attachment.in”,

 

        “ContentType = text / plain”,“Id = 12345”,

     LAST);

//Soap_Request下载文件

soap_request(“StepName = MimeDownloadFileWithSoapRequest”,

    “URL = http:// myServer:8080 / axis / services / MimeService”,

    “SOAPEnvelope =”

        “<?xml version = \”1.0 \“encoding = \”UTF-8\“

        “standalone = \”no \“?> <soap:Envelope xmlns:soap =”http:// sc“

        “hemas.xmlsoap.org/soap/envelope/ \”

        “xmlns:xsi = \”http://www.w3.org/2001/XMLSchema-instance \“xm”

        “lns:xsd = \”http://www.w3.org/2001/XMLSchema \“

        “xmlns:tns = \”http:// DefaultNamespace \“xmlns:types”

        “= \”http:// DefaultNamespace \“

        xmlns:soapenc = \“http://schemas.xmlsoap.org/soap/encoding/ \”>

        <soap:Body soap:encodingStyle=“

        “\”http://schemas.xmlsoap.org/soap/encoding/ \“>

        <tns:MimeDownloadFile>“

        “<in0 xsi:type = \”xsd:string \“>”

        “d:\\ temp \\myUploaded.txt </ in0> </ tns:MimeDownloadFile>”

        “</ soap:Body></ soap:Envelope>”,

     ATTACHMENT_SAVE_BY_INDEX,

     “Index = 1”,“ParamName= pAttachmentContent”,

     LAST);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息