我试图将一个正常的肥皂请求映射到Gatling似乎很基本,但是我在Gatling中不断收到400个错误,而在SOAP UI中却得到200 OK
以下是SOAP UI详细信息:-
Raw-->
POST http://r21sVCS.onlinegaming.local:4059/Business/EventReporterV2
HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://www.ds.com/Service/2013-
03/IEventReporterEndpoint/GetAccountVersion"
Content-Length: 385
Host: r20services.onlinegaming.local:4059
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
XML-->
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://www.ds.com/Service/2013-03">
<soapenv:Header/>
<soapenv:Body>
<ns:GetAccountVersion>
<!--Optional:-->
<ns:request>
<ns:UserName>?</ns:UserName>
</ns:request>
</ns:GetAccountVersion>
</soapenv:Body>
</soapenv:Envelope>
现在等效的加特林代码是:- 包装模拟
import baseConfig.BaseSimulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.language.postfixOps
class ERBSGetServiceVersion extends BaseSimulation {
val httpProtocol = http
.baseURL("http://r21sVCS.onlinegaming.local:4059/Business/
EventReporterV2")
val header = Map(
"POST" -> "http://r21sVCS.onlinegaming.local:4059/Business/EventReporterV2
HTTP/1.1",
"Accept-Encoding" -> "gzip,deflate",
"Content-Type" -> "text/xml;charset=UTF-8",
"SOAPAction" -> "http://www.ds.com/Service/2013-
03/IEventReporterEndpoint/GetAccountVersion",
"Content-Length" -> "385",
"Host" -> "r21sVCS.onlinegaming.local:4059",
"Connection" -> "Keep-Alive",
"User-Agent" -> "Apache-HttpClient/4.1.1 (java 1.5)"
)
val scn = scenario("SOAPRecordedSimulation")
.exec(http("Get Service Soap Request")
.post(" HTTP/1.1")
.headers(header)
.body(StringBody("""<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://www.ds.com/Service/2013-03">
| <soapenv:Header/>
| <soapenv:Body>
| <ns:GetAccountVersion>
| <!--Optional:-->
| <ns:request>
| <ns:UserName>?</ns:UserName>
| </ns:request>
| </ns:GetAccountVersion>
| </soapenv:Body>
|</soapenv:Envelope>""")))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
请注意,此服务不需要身份验证,但仍需要加特林 抛出400
17:11:56.245 [WARN ] i.g.h.a.ResponseProcessor - Request 'Get Service Soap
Request' failed:
status.find.in(200,304,201,202,203,204,205,206,207,208,209), but actually
found 400
---- Errors --------------------------------------------------------------
------
> status.find.in(200,304,201,202,203,204,205,206,207,208,209), b 1
(100.0%)
but actually found 400
答案 0 :(得分:0)
仅使用ELFFileBody解决了我的问题,我就将SOAP信封的内容放在.txt文件中,并保存在加特林项目的resources >> data文件夹中,从而解决了问题
package simulations
import baseConfig.BaseSimulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.language.postfixOps
class ERBSGetServiceVersion extends BaseSimulation {
val httpProtocol = http
.baseURL("http://r21sVCS.onlinegaming.local:4059/Business/")
val header = Map(
"POST" -> "http://r21sVCS.onlinegaming.local:4059/Business/EventReporterV2 HTTP/1.1",
"Accept-Encoding" -> "gzip,deflate",
"Content-Type" -> "text/xml;charset=UTF-8",
"SOAPAction" -> "http://www.ds.com/Service/2013-03/IEventReporterEndpoint/GetAccountVersion",
"Content-Length" -> "385",
"Host" -> "r21sVCS.onlinegaming.local:4059",
"Connection" -> "Keep-Alive",
"User-Agent" -> "Apache-HttpClient/4.1.1 (java 1.5)"
)
val scn = scenario("SOAPRecordedSimulation")
.exec(http("Get Service Soap Request")
.post("EventReporterV2")
.headers(header)
.body(ElFileBody("Soap_request_0000.txt")))
setUp(scn.inject(atOnceUsers(20))).protocols(httpProtocol)
}