karatelabs / karate

Test Automation Made Simple
https://karatelabs.github.io/karate
MIT License
8.29k stars 1.95k forks source link

Karate changes the xml request body #1417

Closed sudhag85 closed 3 years ago

sudhag85 commented 3 years ago

Hi, I was automating a SOAP API using Karate Framework and noticed the request body gets modified by karate.

Actual Behaviour- Request body is modified by karate Expected Behaviour- Request body should be passed as it is

Note- Attached sample maven project to reproduce the steps. Also attached an image highlighting the difference Java Version- jdk1.8.0_271 JUnit- 5

Listed below is my feature file-

Feature: SearchCustomer Scenario: Test Scenario Given url 'https://postman-echo.com/post' And request """

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://abc.com/enterpriseapplicationintegration/common-types/v1" xmlns="http://abc.com/customerinformationmanagement/customerprofilesearch/v1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <soapenv:Header>
      <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
         <wsse:UsernameToken wsu:Id="UsernameToken-123456">
            <wsse:Username>abc</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">123</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soapenv:Header>
   <soap:Body>
      <searchCustSum xmlns="http://abc.com/customerinformationmanagement/customerprofilesearch/v1" xmlns:ns2="http://abc.com/customerprofile-common/types/v1" xmlns:ns3="http://abc.com/commonbusinessentities-common/types/v1" xmlns:ns4="http://abc.com/enterpriseapplicationintegration/common-types/v1" xmlns:ns5="http://abc.com/customerprofile/types/v1" xmlns:ns6="http://abc.com/core/types/v1" xmlns:ns7="http://abc.com/locationmanagement/types/v1" xmlns:ns8="http://abc.com/customerprofile/types-extended/v1" xmlns:ns9="http://abc.com/customerprofile/types-unqualified/v1" xmlns:ns10="http://abc.com/customerbilling/types-unqualified/v1" xmlns:ns11="http://abc.com/commonbusinessentities/types-unqualified/v1" xmlns:ns12="http://abc.com/core/types-unqualified/v1" xmlns:ns13="http://abc.com/enterprise/types-unqualified/v1" xmlns:ns14="http://abc.com/supplierpartner/types-unqualified/v1" xmlns:ns15="http://abc.com/customerproduct/types-unqualified/v1" xmlns:ns16="http://abc.com/customerbusinessinteraction/types-unqualified/v1" xmlns:ns17="http://abc.com/resource/types-unqualified/v1" xmlns:ns18="http://abc.com/productcatalog/types-unqualified/v1" xmlns:ns19="http://abc.com/marketsales/types-unqualified/v1" xmlns:ns20="http://abc.com/productcatalog-common/types/v1" xmlns:ns21="http://abc.com/customerproduct/types/v1" xmlns:ns22="http://abc.com/customerbilling-common/types/v1" xmlns:ns23="http://abc.com/customerbusinessinteraction-common/types/v1" xmlns:ns24="http://abc.com/servicecatalog/types-unqualified/v1" xmlns:ns25="http://abc.com/service/types-unqualified/v1" xmlns:ns26="http://abc.com/servicebusinessinteraction/types-unqualified/v1" xmlns:ns27="http://abc.com/supplierpartner-common/types/v1" xmlns:ns28="http://abc.com/customerproduct-common/types/v1" xmlns:ns29="http://abc.com/customerordermanagement-common/types/v1">
         <query xsi:type="CustomerQueryByAccount" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <custAcctID>
            <ns2:id xmlns:v12="http://abc.com/customerprofile-common/types/v1">12345</ns2:id>
            </custAcctID>
         </query>
      </searchCustSum>
   </soap:Body>
</soapenv:Envelope>
""" 

When soap action 'https://postman-echo.com/post'

17:47:48.782 request: 1 > POST https://postman-echo.com/post 1 > Accept-Encoding: gzip,deflate 1 > Connection: Keep-Alive 1 > Content-Length: 3080 1 > Content-Type: text/xml; charset=UTF-8 1 > Host: postman-echo.com 1 > SOAPAction: https://postman-echo.com/post 1 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_271)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://abc.com/customerinformationmanagement/customerprofilesearch/v1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://abc.com/enterpriseapplicationintegration/common-types/v1" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header>
      <wsse:Security>
         <wsse:UsernameToken wsu:Id="UsernameToken-123456">
            <wsse:Username>abc</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">123</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soapenv:Header>
   <soap:Body>
      <searchCustSum xmlns:ns10="http://abc.com/customerbilling/types-unqualified/v1" xmlns:ns11="http://abc.com/commonbusinessentities/types-unqualified/v1" xmlns:ns12="http://abc.com/core/types-unqualified/v1" xmlns:ns13="http://abc.com/enterprise/types-unqualified/v1" xmlns:ns14="http://abc.com/supplierpartner/types-unqualified/v1" xmlns:ns15="http://abc.com/customerproduct/types-unqualified/v1" xmlns:ns16="http://abc.com/customerbusinessinteraction/types-unqualified/v1" xmlns:ns17="http://abc.com/resource/types-unqualified/v1" xmlns:ns18="http://abc.com/productcatalog/types-unqualified/v1" xmlns:ns19="http://abc.com/marketsales/types-unqualified/v1" xmlns:ns2="http://abc.com/customerprofile-common/types/v1" xmlns:ns20="http://abc.com/productcatalog-common/types/v1" xmlns:ns21="http://abc.com/customerproduct/types/v1" xmlns:ns22="http://abc.com/customerbilling-common/types/v1" xmlns:ns23="http://abc.com/customerbusinessinteraction-common/types/v1" xmlns:ns24="http://abc.com/servicecatalog/types-unqualified/v1" xmlns:ns25="http://abc.com/service/types-unqualified/v1" xmlns:ns26="http://abc.com/servicebusinessinteraction/types-unqualified/v1" xmlns:ns27="http://abc.com/supplierpartner-common/types/v1" xmlns:ns28="http://abc.com/customerproduct-common/types/v1" xmlns:ns29="http://abc.com/customerordermanagement-common/types/v1" xmlns:ns3="http://abc.com/commonbusinessentities-common/types/v1" xmlns:ns4="http://abc.com/enterpriseapplicationintegration/common-types/v1" xmlns:ns5="http://abc.com/customerprofile/types/v1" xmlns:ns6="http://abc.com/core/types/v1" xmlns:ns7="http://abc.com/locationmanagement/types/v1" xmlns:ns8="http://abc.com/customerprofile/types-extended/v1" xmlns:ns9="http://abc.com/customerprofile/types-unqualified/v1">
         <query xsi:type="CustomerQueryByAccount">
            <custAcctID>
            <ns2:id xmlns:v12="http://abc.com/customerprofile-common/types/v1">12345</ns2:id>
            </custAcctID>
         </query>
      </searchCustSum>
   </soap:Body>
</soapenv:Envelope>

17:47:50.046 response time in milliseconds: 1256.81 1 < 200 1 < Connection: keep-alive 1 < Content-Type: application/json; charset=utf-8 1 < Date: Fri, 01 Jan 2021 09:47:42 GMT 1 < ETag: W/"e3a-kLk/9LZkZlgFEJipePgkYEM12Uk" 1 < Transfer-Encoding: chunked 1 < Vary: Accept-Encoding 1 < set-cookie: sails.sid=s%3AjJa04mLZHqYY4JKJlF6USGczk8Lyxv8B.YufjiMTx6mYrlx1eAY8twTT8IF96kGsVycLUT%2BgmaDg; Path=/; HttpOnly {"args":{},"data":"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns=\"http://abc.com/customerinformationmanagement/customerprofilesearch/v1\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v1=\"http://abc.com/enterpriseapplicationintegration/common-types/v1\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <soapenv:Header>\r\n <wsse:Security>\r\n <wsse:UsernameToken wsu:Id=\"UsernameToken-123456\">\r\n <wsse:Username>abc</wsse:Username>\r\n <wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">123</wsse:Password>\r\n </wsse:UsernameToken>\r\n </wsse:Security>\r\n </soapenv:Header>\r\n <soap:Body>\r\n <searchCustSum xmlns:ns10=\"http://abc.com/customerbilling/types-unqualified/v1\" xmlns:ns11=\"http://abc.com/commonbusinessentities/types-unqualified/v1\" xmlns:ns12=\"http://abc.com/core/types-unqualified/v1\" xmlns:ns13=\"http://abc.com/enterprise/types-unqualified/v1\" xmlns:ns14=\"http://abc.com/supplierpartner/types-unqualified/v1\" xmlns:ns15=\"http://abc.com/customerproduct/types-unqualified/v1\" xmlns:ns16=\"http://abc.com/customerbusinessinteraction/types-unqualified/v1\" xmlns:ns17=\"http://abc.com/resource/types-unqualified/v1\" xmlns:ns18=\"http://abc.com/productcatalog/types-unqualified/v1\" xmlns:ns19=\"http://abc.com/marketsales/types-unqualified/v1\" xmlns:ns2=\"http://abc.com/customerprofile-common/types/v1\" xmlns:ns20=\"http://abc.com/productcatalog-common/types/v1\" xmlns:ns21=\"http://abc.com/customerproduct/types/v1\" xmlns:ns22=\"http://abc.com/customerbilling-common/types/v1\" xmlns:ns23=\"http://abc.com/customerbusinessinteraction-common/types/v1\" xmlns:ns24=\"http://abc.com/servicecatalog/types-unqualified/v1\" xmlns:ns25=\"http://abc.com/service/types-unqualified/v1\" xmlns:ns26=\"http://abc.com/servicebusinessinteraction/types-unqualified/v1\" xmlns:ns27=\"http://abc.com/supplierpartner-common/types/v1\" xmlns:ns28=\"http://abc.com/customerproduct-common/types/v1\" xmlns:ns29=\"http://abc.com/customerordermanagement-common/types/v1\" xmlns:ns3=\"http://abc.com/commonbusinessentities-common/types/v1\" xmlns:ns4=\"http://abc.com/enterpriseapplicationintegration/common-types/v1\" xmlns:ns5=\"http://abc.com/customerprofile/types/v1\" xmlns:ns6=\"http://abc.com/core/types/v1\" xmlns:ns7=\"http://abc.com/locationmanagement/types/v1\" xmlns:ns8=\"http://abc.com/customerprofile/types-extended/v1\" xmlns:ns9=\"http://abc.com/customerprofile/types-unqualified/v1\">\r\n <query xsi:type=\"CustomerQueryByAccount\">\r\n <custAcctID>\r\n <ns2:id xmlns:v12=\"http://abc.com/customerprofile-common/types/v1\">12345</ns2:id>\r\n </custAcctID>\r\n </query>\r\n </searchCustSum>\r\n </soap:Body>\r\n</soapenv:Envelope>","files":{},"form":{},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-5feeefbe-39ca2d7862b6082030511cfa","content-length":"3080","soapaction":"https://postman-echo.com/post","content-type":"text/xml; charset=UTF-8","user-agent":"Apache-HttpClient/4.5.13 (Java/1.8.0_271)","accept-encoding":"gzip,deflate"},"json":null,"url":"https://postman-echo.com/post"}

Test.zip

RequestBody_Comparison_Screenshot
ptrthomas commented 3 years ago

@sudhag85 why don't you re-read those instructions and try again: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

to help you I'm quoting it below:

"Minimal" also means that your pom.xml (or build.gradle) should ideally be in the form generated by the quickstart or copied from the examples, many people get this wrong - so please ensure that you do this ! Please don't just cut and paste your existing pom.xml - your issue will be promptly rejected