Forum Discussion

CarlsBerg999's avatar
CarlsBerg999
Helper V
4 years ago

SOAP Query - Passing parameters from another query to second query's M-Code

Hi, 

 

I have a SOAP service (Quinyx) to which I connect to via Power Query. The M-code that works in simple situations is presented below. The issue is, that the employeeId field is mandatory in the SOAP service to which I connect to. Basically the service demands and returns only 1 employee at a time. We have hundreds of employees. I can get a full list of employeeId's with another query to Power Query, but what i need to do is to pass all employeeId's to this request automatically. 

 

Is this possible in any way in M-code, Python or R? What is the method that should be applied to solve this issue? 

 

let

SourceURL = "https://rc.quinyx.com/FlexForceWebServices.php?wsdl",

options = [ #"Content-Type"="text/xml;charset=UTF-8",
            #"Connection"="Keep-Alive"
          ],

WebContent = Web.Contents(SourceURL, 
    [Content=Text.ToBinary("

<soapenv:Envelope xmlns:xsi=#(0022)http://www.w3.org/2001/XMLSchema-instance#(0022) xmlns:xsd=#(0022)http://www.w3.org/2001/XMLSchema#(0022) xmlns:soapenv=#(0022)http://schemas.xmlsoap.org/soap/envelope/#(0022) xmlns:uri=#(0022)uri:FlexForce#(0022)>
   <soapenv:Header/>
   <soapenv:Body>
      <uri:wsdlGetTimePunches soapenv:encodingStyle=#(0022)http://schemas.xmlsoap.org/soap/encoding/#(0022)>
         <apiKey xsi:type=#(0022)xsd:string#(0022)>BLA-BLA-BLA-BLA</apiKey>
         <getTimePunchesRequest xsi:type=#(0022)flex:getTimePunchesRequest#(0022) xmlns:flex=#(0022)https://apiftp.quinyx.com/soap/FlexForce#(0022)>
            <!--You may enter the following 14 items in any order-->
            <!--Mandatory:-->
            <employeeId xsi:type=#(0022)xsd:int#(0022)>EACH EMPLOYEE ID (82387238) IS SET HERE </employeeId>
            <!--Optional:
            <badgeNo xsi:type=#(0022)xsd:string#(0022)>?</badgeNo>-->
         </getTimePunchesRequest>
      </uri:wsdlGetTimePunches>
   </soapenv:Body>
</soapenv:Envelope>

"),

Headers=options]) ,
XmlContent = Xml.Tables(WebContent),
    Table = XmlContent{0}[Table]
in
    Table

 

Thank you!

2 Replies

  • Have a table with your employee IDs.  Add a column that constructs the payload for each of them. Add another column that calls Web.Contents  on that payload.  Process each response individually or union them together.

    • CarlsBerg999's avatar
      CarlsBerg999
      Helper V

      Hi lbendlin, apologies i didn't notice this thread had an answer. The idea itself seems ok, but I honestly have no idea how to accomplish this. I don't quite know how to reference "current row" in M. Do you have any references to some sort of guidance / tutorials / materials i could start studying to accomplish this? I'm pretty much lost on where to even begin.