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>
Related
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");
})
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>
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>
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='1.0' encoding='UTF-8' standalone='yes' ?><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>
I have this error
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Message part {http://soap.ws.server.wst.fit.cvut.cz/}createOrders was not recognized. (Does it exist in service WSDL?)</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
which is completely fine. But the problem is that CXF is returning Internal Server Error (HTTP 500). I would expect it to return 400 Bad Request because a wrong request is causing this. How can I change that?
DETAILS
The wrong request which produces the error above - there should be <soap:createOrder/> instead of <soap:createOrders/>.
POST http://localhost:8080/wst-server-1.0.0/services/soap/order
POST data:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.ws.server.wst.fit.cvut.cz/">
<soapenv:Header/>
<soapenv:Body>
<soap:createOrders/>
</soapenv:Body>
</soapenv:Envelope>
[no cookies]
Request Headers:
Content-Length: 238
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
I know maybe this is too late for the answer but another way to handle HTTP status code is using CXF interceptors.
you can add an interceptor in your server CXF configure
public class ServiceConfigurer implements CxfConfigurer {
#Override
public void configureServer(Server server) {
server.getEndpoint().getOutFaultInterceptors().add(new ChangingStatusCodeInterceptor();
}
}
and in your interceptor, you can change this
public class SaveInfluxDataInterceptor extends WSS4JOutInterceptor {
#Override
public void handleMessage(SoapMessage soapMessage) {
((Fault)exchange.get(Exception.class)).setStatusCode(202); // this is because of soap12OutFaultInterceptor look to this fault
// or you can use this
// exchange.getOutFaultMessage().put(Message.RESPONSE_CODE, 202);
}
}
I used Camel with CXF. maybe this solution should change in yours.