如何在空手道中用键传递 SOAP header
How to pass SOAP header with key in karate
我想用空手道调用以下请求:
http://testsample.com/test?request=<REQUESTS>
<REQUEST TYPE="createClientAccount" REF_NUM="A1">
<CRM_ID>ABC_123</CRM_ID>
<CRM_SYSTEM_ID>abc</CRM_SYSTEM_ID>
<AUTO_APPROVE>TRUE</AUTO_APPROVE>
</REQUEST>
</REQUESTS>
我尝试了以下选项,但没有用,有人可以告诉我这里有什么问题吗?
Given url 'http://testsample.com/test'
And request
"""
<REQUESTS>
<REQUEST TYPE="createClientAccount" REF_NUM="A1">
<CRM_ID>ABC_123</CRM_ID>
<CRM_SYSTEM_ID>abc</CRM_SYSTEM_ID>
<AUTO_APPROVE>TRUE</AUTO_APPROVE>
</REQUEST>
</REQUESTS>
"""
And header Content-Type = 'application/soap+xml'
When method post
Then status 200
糟糕,这看起来设计得很糟糕 API。您确定要将 XML 作为 URL 的一部分发送吗?然后这样做:
* string xml = <REQUESTS><REQUEST TYPE="createClientAccount" REF_NUM="A1"><CRM_ID>ABC_123</CRM_ID><CRM_SYSTEM_ID>abc</CRM_SYSTEM_ID><AUTO_APPROVE>TRUE</AUTO_APPROVE></REQUEST></REQUESTS>
Given url 'http://testsample.com/test'
And param request = xml
And request ''
When method post
如果您不熟悉 HTTP 和 REST,请寻求他人的帮助。
我想用空手道调用以下请求:
http://testsample.com/test?request=<REQUESTS>
<REQUEST TYPE="createClientAccount" REF_NUM="A1">
<CRM_ID>ABC_123</CRM_ID>
<CRM_SYSTEM_ID>abc</CRM_SYSTEM_ID>
<AUTO_APPROVE>TRUE</AUTO_APPROVE>
</REQUEST>
</REQUESTS>
我尝试了以下选项,但没有用,有人可以告诉我这里有什么问题吗?
Given url 'http://testsample.com/test'
And request
"""
<REQUESTS>
<REQUEST TYPE="createClientAccount" REF_NUM="A1">
<CRM_ID>ABC_123</CRM_ID>
<CRM_SYSTEM_ID>abc</CRM_SYSTEM_ID>
<AUTO_APPROVE>TRUE</AUTO_APPROVE>
</REQUEST>
</REQUESTS>
"""
And header Content-Type = 'application/soap+xml'
When method post
Then status 200
糟糕,这看起来设计得很糟糕 API。您确定要将 XML 作为 URL 的一部分发送吗?然后这样做:
* string xml = <REQUESTS><REQUEST TYPE="createClientAccount" REF_NUM="A1"><CRM_ID>ABC_123</CRM_ID><CRM_SYSTEM_ID>abc</CRM_SYSTEM_ID><AUTO_APPROVE>TRUE</AUTO_APPROVE></REQUEST></REQUESTS>
Given url 'http://testsample.com/test'
And param request = xml
And request ''
When method post
如果您不熟悉 HTTP 和 REST,请寻求他人的帮助。