本文介绍了如何使用Gatling 2.2.0调用SOAP Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Gatling和Scala的新手.如何使用Gatling 2.2.0调用/测试Java SOAP Web服务?我已经搜索过Google和加特林的文档,但是找不到任何链接
I am new to Gatling and Scala. How to invoke / test a java SOAP web service using Gatling 2.2.0 ? I had searched google and gatling documentation, but could not find any link for that
代码:
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)
}
推荐答案
我不确定是否有可用的记录器.但是,您可以按以下方式更改脚本:
Am not sure if there is a recorder available. But, you could make changes to your script as below:
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)
}
这篇关于如何使用Gatling 2.2.0调用SOAP Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!