How to Pass Complex Type Argument from Zeep Where all Argument Are Not Mandatory - soap

I have the following soap envelope.
<soapenv:Header/>
<soapenv:Body>
<uri:wsdlGetSchedulesV3 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<apiKey xsi:type="xsd:string">111111111111111</apiKey>
<GetSchedulesV3 xsi:type="flex:GetSchedulesV3" xmlns:flex="http://app.quinyx.com/soap/FlexForce">
<!--You may enter the following 16 items in any order-->
<!--Optional:-->
<section xsi:type="xsd:string">0</section>
<!--Optional:-->
<badgeNo xsi:type="xsd:string">111111</badgeNo>
<!--Optional:-->
<employeeId xsi:type="xsd:int">0</employeeId>
<fromDate xsi:type="xsd:string">2014-03-01</fromDate>
<!--Optional:-->
<fromTime xsi:type="xsd:string">00:00:00</fromTime>
<toDate xsi:type="xsd:string">2014-03-04</toDate>
<!--Optional:-->
<toTime xsi:type="xsd:string">23:59:59</toTime>
</GetSchedulesV3>
</uri:wsdlGetSchedulesV3>
</soapenv:Body>
</soapenv:Envelope>
As you can see from soap body, not all parameter passing is mandatory. Only apiKey, fromDate, toDate are the mandatory argument. I want to initialize only the mandatory argument. So I tried the following way to pass the argument. But I think I am missing something here.
My Attempt:
from zeep import Client
from zeep import xsd
from requests import Session
from requests.auth import HTTPBasicAuth
from zeep.transports import Transport
wsdl = "https://api.quinyx.com/FlexForceWebServices.php?wsdl"
username = "username"
password = "password "
session = Session()
session.auth = HTTPBasicAuth(username, password)
client = Client(wsdl, transport=Transport(session=session))
data ={ "apiKey" : "111111111111111",
"GetSchedulesV3" :
{ "employeeId" :xsd.SkipValue,
"badgeNo":xsd.SkipValue,
"section":xsd.SkipValue,
"fromDate":'2022-05-01',
"fromTime":xsd.SkipValue,
"toDate":'2022-06-01',
"toTime":xsd.SkipValue,
}
}
result = client.service['wsdlGetSchedulesV3'](**data)
I am getting the following error:
TypeError: {https://api.quinyx.com/soap/FlexForce}
GetSchedulesV3() got an unexpected keyword argument 'allUnits'.
Signature: `section: xsd:string, badgeNo: xsd:string, employeeId:
xsd:int, fromDate: xsd:string, fromTime: xsd:string, toDate:
xsd:string, toTime: xsd:string,

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:

Postman test fails while parsing the xml soap response

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");
})

JBOSS fuse Optional tag on Interface method argument

I have two arguments to interface method
I have the following code
package com.pk.testAtrifact.incident;
public interface ServiceCountry {
/**
* Operation to country
*/
OutCountry getCountry(Header header,InputCountry input);
}
when it comes in WSDL it comes like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
<soapenv:Header/>
<soapenv:Body>
<mpos:getCountry>
<!--Optional:-->
<v1:RequestHeader>
<!--Optional:-->
There is Optional tag on RequestHeader. I dont want to keep header optional. How can i do this

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>

JAXB Binding for SOAP request parameter in JAXWS

My task is to write a webservice for an update operation where a list of objects are passed to the method.
#WebMethod(operationName = "updateObjects", action = "urn:preferences")
public boolean updateObjects(List<MyObject> objects){
}
The class MyObject is simple enough.
#XmlRootElement(name="Object")
public class MyObject{
private String item1;
private String item2;
}
Now the problem statement. When I look at the SOAP request for this method (that SOAP UI generated for me), the request looks like below :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pref="preferences">
<soapenv:Header/>
<soapenv:Body>
<pref:updateObjects>
<!--Zero or more repetitions:-->
<arg0>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</arg0>
</pref:updateObjects>
</soapenv:Body>
</soapenv:Envelope>
but I want it to look like below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pref="preferences">
<soapenv:Header/>
<soapenv:Body>
<pref:updateObjects>
<!--Zero or more repetitions:-->
<Objects>
<Object>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</Object>
<Object>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</Object>
</Objects>
</pref:updateObjects>
</soapenv:Body>
</soapenv:Envelope>
Can somebody please advice. Thanks in advance.
You only need to add a 'wrapper' to your List of objects like this:
#XmlRootElement(name="objects")
public class MyObjects{
#XmlElement(name="object")
List<MyObject> myObjects;
}
public class MyObject{
private String item1;
private String item2;
}
NOTE: changing root element from arg0 to objects with the tag #XmlRootElement(name="objects") will not work because your <objects> is not a root element in the web service definition. Actually it is part of your <wsdl:message> (so JAXB will discart it).
What you need to change is the web service message adding a #WebParam(name = "objects") to your #WebMethod like:
#WebMethod(operationName = "updateObjects", action = "urn:preferences")
public boolean updateObjects(#WebParam(name = "objects") MyObjects objects){
}
If you do not want use a 'wrapper', you can keep your WebMethod but like this:
#WebMethod(operationName = "updateObjects", action = "urn:preferences")
public boolean updateObjects(#WebParam(name = "object") List<MyObject> objects){
}
but you will loose the <objects> wrapper. The request should be something like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pref="preferences">
<soapenv:Header/>
<soapenv:Body>
<pref:updateObjects>
<!--Zero or more repetitions:-->
<object>
<!--Optional:-->
<item1>?</item1>
<!--Optional:-->
<item2>?</item2>
</object>
</pref:updateObjects>
</soapenv:Body>
</soapenv:Envelope>