Forum Discussion
How to get data from a SOAP WS with Power BI
Hello dataloreous,
Yes we got it to work. Yes soapy SOAP is old and we are also stuck in the past... the joys of working for the governement...
This being said :
- Our SOAP web service return an XML file and need a user and a PW and some other info to get the data we want.
- You need to start somewhere and get data : either with an XML file or with the web service's URL. (its doesnt has any importance because we just want to get to the query editor (Power Query)
- So we started to get data from an XML file because we already tested our web service with an other app and we got the XML it returns, so we loaded it. And drilled down till we get something to load/modify :
- As I said, you can simply load the web service URL and use "WEB" to get data. The goal is to load something then access the query editor and advanced editor.
- In the query editor, you accesse the advanced editor (sorry for my french):
- in the advanced editor you change your source to :
let
Source = Xml.Tables(Web.Contents("URLofTheWebService",[Content=File.Contents("D:\download\post.xml"),Headers=[#"Accept-Encoding"="gzip,deflate", SOAPAction="", #"Content-Type"="text/xml;charset=UTF-8"]])), - We use Xml.Tables because as I said our web service return an Xml and web.contents because we connect to a web service
- "D:\download\post.xml" is the path to the XML file where we have the credentials to connect to the web service, you have to call it in your query, here's an example of the file (made with SOAP UI open source) :
- The rest of the query code depends on the structur of your XML, here's what we have :
- Table = Source{0}[Table],
Table1 = Table{0}[Table],
Table2 = Table1{0}[Table],
Table3 = Table2{0}[Table],
Table4 = Table3{0}[Table],
#"Changed Type" = Table.TransformColumnTypes(Table4,{{"chaineXml", type text}, {"codeRetour", Int64.Type}, {"codeSysteme", type text}, {"messageRetour", type text}, {"nbrErreurs", Int64.Type}, {"noFormulaire", Int64.Type}, {"nomSysteme", type text}, {"version", Int64.Type}}),
chaineXml1 = #"Changed Type"{0}[chaineXml],
#"Parsed XML" = Xml.Tables(chaineXml1),
Table5 = #"Parsed XML"{0}[Table],
Table6 = Table5{0}[Table],
#"Expanded Namespace:" = Table.ExpandTableColumn(Table6, "Namespace:", {"column1", "column2", "columnXX"}, {"Namespace:.column1", "Namespace:.column2", "Namespace:.columnXX"}),
#"Expanded Namespace:.column1" = Table.ExpandTableColumn(#"Expanded Namespace:", "Namespace:.column1", {"column2", "column3", "columnXX""}, {"Namespace:.column1.column2", "Namespace:.column1.column3", "Namespace:.column1.columnXX"})
in
#"Expanded Namespace:.column1" - Our code is structured like that because the XML file we get has all the data as XML text in one feild so we have to parse de data and transform the XML string in a table
Hope this help!
Jason
I Try.
https://advertising.criteo.com/API/v201305/AdvertiserService.asmx?WSDL
XML saved in c:\a
<soapenv:Envelope xmlns:v20="https://advertising.criteo.com/API/v201305" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<v20:clientLogin>
<!--Optional:-->
<v20:username>XXXXXX</v20:username>
<!--Optional:-->
<v20:password>XXXXX</v20:password>
<!--Optional:-->
</v20:clientLogin>
</soapenv:Body>
</soapenv:Envelope>
Advanced Editor
let
Source = Xml.Tables(Web.Contents("https://advertising.criteo.com/API/v201305/AdvertiserService.asmx?WSDL"
,[Content=File.Contents("C:\a\a.xml"),Headers=[#"Accept-Encoding"="gzip,deflate", SOAPAction="", #"Content-Type"="text/xml;charset=UTF-8"]]))
in
Source
Return this error..
DataSource.Error: Web.Contents failed to get contents from 'https://advertising.criteo.com/API/v201305/AdvertiserService.asmx?WSDL' (500): Internal Server Error
Details:
DataSourceKind=Web
DataSourcePath=https://advertising.criteo.com/API/v201305/AdvertiserService.asmx
Url=https://advertising.criteo.com/API/v201305/AdvertiserService.asmx?WSDL
Can you help me?
Tanks
- JasonL9 years ago
Advocate II
Have you tried to connecte to your web service with something else than Power Bi to see if it works?
I can test it from my office, proxy block advertisement website
Also are you sure your webservice returns XML?- juliovidigal9 years ago
Advocate I
Yes, it is working, I have tested using SoapUI, and I have had the correct return in XML.
This is the return in SoapUI...!
<soap:Envelope 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">
<soap:Body>
<clientLoginResponse xmlns="https://advertising.criteo.com/API/v201305">
<clientLoginResult>XXXXXXXXXXXXX</clientLoginResult>
</clientLoginResponse>
</soap:Body>
</soap:Envelope>
- JasonL9 years ago
Advocate II
Your M code seems ok, the only difference I see with me is in your XML
you use <v20:clientLogin>were i use </web:returnData>
- juliovidigal9 years ago
Advocate I
I'm going to do a test using </ web: returnData> ...
Tanks - juliovidigal9 years ago
Advocate I
I've removed the "SOAPAction =" "and now it's working.
Thank you- hugoberry9 years ago
Responsive Resident
It seems that making SOAP more user firendly for PowerBI is because of lack of Xml create functions.
Has anyone tried to build an populate an Xml.Document type as per the MSDN document? https://msdn.microsoft.com/en-us/library/mt260907.aspx
Maybe if you start from there you can resolve a lot of SOAP comunication issues.