gpt4 book ai didi

soap - 如何使用 Gatling 2.2.0 调用 SOAP Web 服务

转载 作者:行者123 更新时间:2023-12-02 01:26:52 25 4
gpt4 key购买 nike

我是 Gatling 和 Scala 的新手。如何使用 Gatling 2.2.0 调用/测试 Java SOAP Web 服务?我搜索过谷歌和加特林文档,但找不到任何链接

代码:

    val httpProtocol = http
.baseURL("http://PUNITP83267L:8081/WebServiceProject/services/MyService")
val headers_0 = Map(
"accept-encoding" -> "gzip, deflate",
"Content-Type" -> "text/xml;charset=UTF-8",
"SOAPAction" -> "",
"Content-Length" -> "275",
"Host" -> "PUNITP83267L:8081",
"Connection" -> "alive",
"accept-language" -> "en-US,en;q=0.8",
"user-agent" -> "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"
)

val scn = scenario("SOAPRecordedSimulation")
.exec(http("simple Soap Request")
.post("<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
<soapenv:Body><greetMeResponse xmlns=\"http://ws.star.fs.infosys.com\">
<greetMeReturn>Hello uMESH</greetMeReturn></greetMeResponse>
</soapenv:Body></soapenv:Envelope>\"\r\n")
.headers(headers_0))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

最佳答案

不知道有没有录音机。但是,您可以对脚本进行如下更改:

class testSOAP extends Simulation {

val httpProtocol = http
.baseURL("http://PUNITP83267L:8081/WebServiceProject/services/")

val header = Map(
"accept-encoding" -> "gzip, deflate",
"Content-Type" -> "text/xml;charset=UTF-8",
"SOAPAction" -> "", "Content-Length" -> "275",
"Host" -> "PUNITP83267L:8081",
"Connection" -> "alive",
"accept-language" -> "en-US,en;q=0.8",
"user-agent" -> "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36")

val scn = scenario("SOAPRecordedSimulation")
.exec(http("simple Soap Request")
.post("MyService")
.headers(header)
.body(StringBody("""<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><greetMeResponse xmlns=\"http://ws.star.fs.infosys.com\"><greetMeReturn>Hello uMESH</greetMeReturn></greetMeResponse></soapenv:Body></soapenv:Envelope>\"\r\n""")))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

关于soap - 如何使用 Gatling 2.2.0 调用 SOAP Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36620768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com