我正在使用Karate API自动化3个API(Rest_1、Rest_2和Soap_3服务(。Rest_1的输出将被输入到Rest_2,Rest_2的输出将输入到Soap_3。为每个API创建了3个要素文件,并创建了一个调用这3个要素的主要素文件。Rest_1-->Rest_2流按预期工作,Rest_2-->Soap_3请求XML按预期生成,但同一请求未命中Soap_3服务并获得响应500。
-
当我单独执行Soap_3功能文件时,它会给我预期的响应。但在批量中,它抛出了500个错误。
-
如果我采用Rest_2-->Soap_3生成的XML并在SoapUI中手动运行它,它就可以正常工作。
请求您对此问题的帮助。提前感谢!
以下是我的Soap_3服务功能文件:
Feature: Get PolicyDetails
Background:
* configure headers = {Content-Type: 'application/soap+xml; charset=utf-8'}
* configure logPrettyResponse = true
* configure ssl = true
* configure ssl = 'TLSv1.2'
* header Authorization = call read('classpath:resources/common/basic_auth.js') {username:'test',password:'test'}
* url 'https://soap_3apiurl'
Scenario: get the PolicyInfo
* configure charset = null
# getting submission id from preious feature file output
* call read('classpath:resources/dynamic/previous.feature'){'submissionID':'#(submissionID)'}
* xml req = read ('classpath:resources/common/RetrivePolicyDetails.xml')
* karate.set ('req/soapenv:Envelope/soapenv:Body/ns2:retrieveSubmission/ns2:aRequest/SubmissionID',submissionID)
Given request req
When soap action 'https://soap3apiurl'
Then status 200
And print response
**Console log:**
16:43:30.562 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - response time in milliseconds: 58.18
1 < 500
1 < Accept-Encoding:
1 < Authorization: Basic
1 < Cneonction: close
1 < Content-Type: application/soap+xml; charset=UTF-8
1 < Cookie: NSC
1 < Date:
1 < Host: soap3APIurl.com
1 < Set-Cookie:
1 < Transfer-Encoding: chunked
1 < X-Forwarded-For: 10.00.00.1, 10.00.00.20
1 < X-Forwarded-Host:
1 < X-Forwarded-Server:
1 < X-dynaTrace: FW1;10000008;-1100030439;601946;6;-11000009;60194;1
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/">soap11Env:Server</faultcode>
<faultstring>Error while building message</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
16:43:30.565 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - status code was: 500, expected: 200
不要在read
函数引用后留下空格:
* xml req = read('classpath:resources/common/RetrivePolicyDetails.xml')
对此进行了解释:https://github.com/intuit/karate/tree/develop/karate-core#locator-查找
如果不是问题所在,请遵循以下流程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
* configure headers = {Cookie : null}
添加以上行解决了我的问题。谢谢