Postman test fails while parsing the xml soap response - soap

I am using POSTMAN to send a SOAP request and below is my soapenv response received. I would like to test for the below value received in my postman test, but the post man test fails, could someone advise on what to do here ?
LicStatus
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:schemas.general.com.au:api:other">
<soapenv:Header xmlns:urn="urn:schemas.general.com.au:api:other" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<header xmlns:urn="urn:schemas.general.com.au:api:other" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.cordys.com/General/1.0/">
<msg-id>005056B9-3921-A1E9-A327-64509F7362DC</msg-id>
<messageoptions noreply="true"/>
</header>
</soapenv:Header>
<soapenv:Body>
<getSupplierDataResponse xmlns:urn="urn:schemas.general.com.au:api:other" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:schemas.general.com.au:api:other" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns6="http://schemas.cordys.com/default_005056B9-5D92-A1E9-904D-128C719CE2DD" xmlns:ns5="http://schemas.cordys.com/casemanagement/1.0" xmlns:ns4="http://schemas.XXTGGHG.org/2004/07/STRD.Models" xmlns:ns3="urn:schemas.general.com.au:canonical:technical:v1" xmlns:ns2="urn:schemas.general.com.au:api:other" xmlns:bpm="http://schemas.cordys.com/default" xmlns:sm="http://www.w3.org/2005/07/scxml" xmlns:instance="http://schemas.cordys.com/bpm/instance/1.0">
<CustomerData>
<DateLicenceExpires>28/01/2020</DateLicenceExpires>
<Demonstration_Method>Certification</Demonstration_Method>
<AuditLastAuditDate>05/03/2018</AuditLastAuditDate>
<AuditOutcome>Non Compliance</AuditOutcome>
<HeadOfficeRegion/>
<ScopeOfLicencing>YES</ScopeOfLicencing>
<LicStatus>Licensed</LicStatus>
</CustomerData>
<OperationResult xmlns="urn:schemas.general.com.au:canonical:technical:v1">
<Status>00</Status>
<StatusMessage>Success</StatusMessage>
</OperationResult>
</getSupplierDataResponse>
</soapenv:Body>
</soapenv:Envelope>
Below is the post man test:
pm.test('Verify the LicStatus', function() {
var responseJson = xml2Json(responseBody);
pm.expect(responseJson.results[0].LicStatus).to.eql("Licensed");
})

Try something like this:
pm.test('Verify the LicStatus', function() {
var xmlTree = xml2Json(responseBody);
var licenseStatus = xmlTree['soapenv:Envelope']['soapenv:Body'].getSupplierDataResponse.CustomerData.LicStatus;
pm.expect(licenseStatus).to.eql("Licensed");
})

Related

Use column value in M Query / Power Query

I've a short code to make a SOAP request to fetch data into Power BI. The problem is that I need to give a Session_id for the requests:
let
SourceURL = "HTTPS://SOAP.E-BOEKHOUDEN.NL/SOAP.ASMX?WSDL", //host provides this address. Url ends often with "wsdl"
options = [ #"Authorization" ="Basic USER:PASS=", //User:pass decoded with SOAP UI
#"Accept-Encoding"= "gzip,deflate",
// SOAPAction="",
#"Content-Type"="text/xml;charset=UTF-8",
#"Connection"="Keep-Alive"
],
WebContent = Web.Contents(SourceURL,
// Content options in Web.Contents() requires you to authenticate anonymously !
[Content=Text.ToBinary("
<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" xmlns:soap1=""http://www.e-boekhouden.nl/soap"">
<soap:Header/>
<soap:Body>
<soap1:OpenSession>
<!--Optional:-->
<soap1:Username>***</soap1:Username>
<!--Optional:-->
<soap1:SecurityCode1>***</soap1:SecurityCode1>
<!--Optional:-->
<soap1:SecurityCode2>***</soap1:SecurityCode2>
<!--Optional:-->
<soap1:Source></soap1:Source>
</soap1:OpenSession>
</soap:Body>
</soap:Envelope>
"),
Headers=options]) ,
XmlContent = Xml.Tables(WebContent)
in
XmlContent
Now this code is to get the Session_id. To get the other data I need to give the session_id instead of SecurityCode2 in a similar request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://www.e-boekhouden.nl/soap">
<soapenv:Header/>
<soapenv:Body>
<soap:GetMutaties>
<!--Optional:-->
<soap:SessionID>***</soap:SessionID>
<!--Optional:-->
<soap:SecurityCode1>***</soap:SecurityCode1>
<!--Optional:-->
<soap:cFilter>
</soap:cFilter>
</soap:GetMutaties>
</soapenv:Body>
</soapenv:Envelope>
Can I use a column value as parameter/variable that I can use in the body?
You don't even need a column for that. Create a query that just returns a string:
and then you can reference that query anywhere else:

Basic auth credentials using headers in soap on groovy

I'm trying to connect to WSDL server, which requires basic auth along with the body. I tried hitting with SOAPUI, and was able to do so. While working for the same in groovy and using wslite package for SOAP call, I'm getting error as "Password required".
I tried the tutorial on https://github.com/jwagenleitner/groovy-wslite, but the method described (in Usage block) didn't help.
I'm using groovy for this.
Below is the raw code from SOAP UI, with response 200OK
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:w="http://xmlns.oracle.com/Enterprise/Tools/schemas/W_CHKLST_CREATE_REQ.1">
<soapenv:Header><wsse:Security soapenv:mustUnderstand="1" 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-83C962CC24EAB67F1D15586306447678"><wsse:Username>userName</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">JLTdeK6Yg3D64+2qz5xnbA==</wsse:Nonce><wsu:Created>2019-05-23T16:57:24.767Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>
<soapenv:Body>
<w:helloWorld/>
</soapenv:Body>
</soapenv:Envelope>
which results in a 200OK from SOAPUI
HTTP/1.1 200 OK
Date: Wed, 22 May 2019 21:54:12 GMT
Content-Type: text/xml; charset=UTF-8
Content-Length: 3570
My Groovy Code,
def client = new SOAPClient("URL of WSDL")
def response = client.send(SOAPAction: "someAction",
connectTimeout:10000,
readTimeout:20000,
useCaches:false,
followRedirects:false) {
version SOAPVersion.V1_2 // SOAPVersion.V1_1 is default
soapNamespacePrefix "soapenv" // "soap-env" is default
envelopeAttributes "xmlns:ns":"http://example.weather.org"
header {
security("xmlns:ns20":"http://SecurityOpenXSD"){
"ns20:Username"("username")
"ns20:Password"("password")
}
}
body {
"ns:helloWorld" {
}
}
}
which gives soap xml as
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand='1'
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-83C962CC24EAB67F1D15586299636605'>
<wsse:Username>userName</wsse:Username>
<wsse:Password
Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>
password
</wsse:Password>
<wsse:Nonce
EncodingType='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'>
JLTdeK6Yg3D64+2qz5xnbA==
</wsse:Nonce>
<wsu:Created>2019-05-23T10:07:52.913Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
But i get error as password required,
<?xml version="1.0" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<Code><Value>SOAP-ENV:Receiver</Value></Code>
<Reason><Text>null</Text></Reason>
<Detail><IBResponse type="error" xmlns=""><DefaultTitle> Error Response</DefaultTitle>
<StatusCode>20</StatusCode>
<DefaultMessage><![CDATA[User Password required]]></DefaultMessage>
</IBResponse></Detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

Bad envelope tag: SOAP service

When I try to test a SOAP request, I get the following error in the console
Bad envelope tag: EbMtvnSvcReq
<?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>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXException: Bad envelope tag: EbMtvnSvcReq</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">d05jbapp12</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I am testing this SOAP request in Postman tool.
Here is my request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://epayments.metavante.com/types/request" xmlns:com="http://metavante.com/types/common" xmlns:req1="http://epayments.metavante.com/types/consumer/request" xmlns:com1="http://epayments.metavante.com/types/common" xmlns:req2="http://epayments.metavante.com/types/event/request" xmlns:req3="http://epayments.metavante.com/types/statistics/request" xmlns:req4="http://epayments.metavante.com/types/notification/request" xmlns:req5="http://epayments.metavante.com/types/security/request" xmlns:req6="http://epayments.metavante.com/types/paymentRule/request" xmlns:req7="http://epayments.metavante.com/types/fi/request" xmlns:req8="http://epayments.metavante.com/types/fundingProfile/request" xmlns:req9="http://epayments.metavante.com/types/transferAccount/request" xmlns:req10="http://epayments.metavante.com/types/merchant/request" xmlns:req11="http://epayments.metavante.com/types/consumerPayee/request" xmlns:req12="http://epayments.metavante.com/types/payment/request" xmlns:req13="http://epayments.metavante.com/types/user/request" xmlns:req14="http://epayments.metavante.com/types/bill/request" xmlns:req15="http://epayments.metavante.com/types/category/request" xmlns:req16="http://epayments.metavante.com/types/report/request" xmlns:req17="http://epayments.metavante.com/types/alert/request" xmlns:req18="http://epayments.metavante.com/types/banking/request" xmlns:req19="http://epayments.metavante.com/types/messaging/request" xmlns:req20="http://epayments.metavante.com/types/recipient/request" xmlns:req21="http://epayments.metavante.com/types/transfer/request" xmlns:req22="http://epayments.metavante.com/types/transferRule/request" xmlns:req23="http://epayments.metavante.com/types/giftcard/request">
<soapenv:Header>
<ActivityId xmlns="http://epayments.metavante.com/types/request" CorrelationId="10018d27-2573-4d6b-8bcb-b49f6c686f1a">5d827c1d-bd7b-437f-904f-5f82c9844022</ActivityId>
</soapenv:Header>
<soapenv:Body>
<req:EbMtvnSvcReq>
<req:MtvnSvcVer>v1.1.0</req:MtvnSvcVer>
<req:MsgUUID>eE64A6fA-c7Dc-1e3f-D95E-94092c95B5A7</req:MsgUUID>
<req:PrcsParms>
<req:SrcID>MVEPAY</req:SrcID>
</req:PrcsParms>
<req:Svc>
<req:SvcParms>
<req:ApplID>ZELLE_UAT</req:ApplID>
<req:SvcID>GetConsumerDetails</req:SvcID>
<req:SvcVer>v1.6.0</req:SvcVer>
<req:RqstUUID>892e6e60-294d-451a-9c65-5f09c8f0e999</req:RqstUUID>
<req:RoutingID>sandbox</req:RoutingID>
</req:SvcParms>
<req:MsgData>
<req:GetConsumerDetails>
<com:channelName>WEB</com:channelName>
<com:locale>en-US</com:locale>
<com:userId>JimZelle1</com:userId>
</req:GetConsumerDetails>
</req:MsgData>
</req:Svc>
</req:EbMtvnSvcReq>
</soapenv:Body>
</soapenv:Envelope>
You SOAPMessage i.e. SOAPEnvelope is in correct, your missing,
</soap:Header> and </soap:Envelope> enclosing Tags.
Correct XML should be something like below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://epayments.metavante.com/types/request" xmlns:com="http://metavante.com/types/common" xmlns:req1="http://epayments.metavante.com/types/consumer/request" xmlns:com1="http://epayments.metavante.com/types/common" xmlns:req2="http://epayments.metavante.com/types/event/request" xmlns:req3="http://epayments.metavante.com/types/statistics/request" xmlns:req4="http://epayments.metavante.com/types/notification/request" xmlns:req5="http://epayments.metavante.com/types/security/request" xmlns:req6="http://epayments.metavante.com/types/paymentRule/request" xmlns:req7="http://epayments.metavante.com/types/fi/request" xmlns:req8="http://epayments.metavante.com/types/fundingProfile/request" xmlns:req9="http://epayments.metavante.com/types/transferAccount/request" xmlns:req10="http://epayments.metavante.com/types/merchant/request" xmlns:req11="http://epayments.metavante.com/types/consumerPayee/request" xmlns:req12="http://epayments.metavante.com/types/payment/request" xmlns:req13="http://epayments.metavante.com/types/user/request" xmlns:req14="http://epayments.metavante.com/types/bill/request" xmlns:req15="http://epayments.metavante.com/types/category/request" xmlns:req16="http://epayments.metavante.com/types/report/request" xmlns:req17="http://epayments.metavante.com/types/alert/request" xmlns:req18="http://epayments.metavante.com/types/banking/request" xmlns:req19="http://epayments.metavante.com/types/messaging/request" xmlns:req20="http://epayments.metavante.com/types/recipient/request" xmlns:req21="http://epayments.metavante.com/types/transfer/request" xmlns:req22="http://epayments.metavante.com/types/transferRule/request" xmlns:req23="http://epayments.metavante.com/types/giftcard/request">
<soapenv:Header>
<ActivityId xmlns="http://epayments.metavante.com/types/request" CorrelationId="10018d27-2573-4d6b-8bcb-b49f6c686f1a">5d827c1d-bd7b-437f-904f-5f82c9844022</ActivityId>
</soapenv:Header>
<soapenv:Body>
<req:EbMtvnSvcReq>
<req:MtvnSvcVer>v1.1.0</req:MtvnSvcVer>
<req:MsgUUID>eE64A6fA-c7Dc-1e3f-D95E-94092c95B5A7</req:MsgUUID>
<req:PrcsParms>
<req:SrcID>MVEPAY</req:SrcID>
</req:PrcsParms>
<req:Svc>
<req:SvcParms>
<req:ApplID>ZELLE_UAT</req:ApplID>
<req:SvcID>GetConsumerDetails</req:SvcID>
<req:SvcVer>v1.6.0</req:SvcVer>
<req:RqstUUID>892e6e60-294d-451a-9c65-5f09c8f0e999</req:RqstUUID>
<req:RoutingID>sandbox</req:RoutingID>
</req:SvcParms>
<req:MsgData>
<req:GetConsumerDetails>
<com:channelName>WEB</com:channelName>
<com:locale>en-US</com:locale>
<com:userId>JimZelle1</com:userId>
</req:GetConsumerDetails>
</req:MsgData>
</req:Svc>
</req:EbMtvnSvcReq>
</soapenv:Body>
</soapenv:Envelope>

Cannot invoke method last() on null object in soap ui

I am new to soap ui. I am trying to fetch list of files using groovy and trigger the soap UI for the same files. groovy script us running fine.but in request I am getting response stating that "Cannot invoke method last() on null object".Am I missing something:
Here is my groovy script:
def fileList = []
File theInfoName = new File("D:\\SOAP")
theInfoName.eachFile { file ->
if (file.isFile() && file.name.endsWith('.txt')) {
fileList.add(file)
}
}
log.info fileList
//context.put('fileList', fileList)
Here is my request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
<soapenv:Header/>
<soapenv:Body>
${=new File("D:\\SOAP\\" + (context.get('fileList')).last()).text}
</soapenv:Body>
</soapenv:Envelope>
but when I see in request messageExchangeResults it is showing:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
<soapenv:Header/>
<soapenv:Body>
Cannot invoke method last() on null object
</soapenv:Body>
</soapenv:Envelope>

Cannot send Soap Request as String using Retrofit 2.0

I tried sending Soap Request as String using Retrofit 2.0 but it always add myrequestString .
Do you know how to send an String SoapUI format via Retrofit 2.0?
Here is my code:
MyService.java:
#Headers({
"Content-Type: text/xml"
})
#POST
Call<ResponseBody> loadRepo(#Url String url,#Body String body);
String to send request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="">
<soapenv:Header/>
<soapenv:Body>
<web:ValidateLink>
<Request>
...
Request actual:
<string><?xml version=&apos;1.0&apos; encoding=&apos;UTF-8&apos; standalone=&apos;yes&apos; ?><soapenv:Envelope xmlns:au
...
;/soapenv:Body></soapenv:Envelope></string>
Request Expected:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="">
<soapenv:Header/>
<soapenv:Body>
<web:ValidateLink>
<Request>