Use column value in M Query / Power Query - soap

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:

Related

SOAP request object containing null values

I am trying to implement a SOAP web service in ASP.NET Core. I generated the proxy code with dotnet svcutil and a sample request with SoapUI.
The problem is that whenever I try to post the request to my service, the request object I get is not null, but all its values are. Specifically, I am testing it with an object of this class:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="riceviPrenotazione", WrapperNamespace="http://farpresa.esterni.ised.it/", IsWrapped=true)]
public partial class riceviPrenotazioneRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://farpresa.esterni.ised.it/", Order=0)]
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public prenotazione arg0;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://farpresa.esterni.ised.it/", Order=1)]
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public infoUtente arg1;
public riceviPrenotazioneRequest()
{
}
public riceviPrenotazioneRequest(prenotazione arg0, infoUtente arg1)
{
this.arg0 = arg0;
this.arg1 = arg1;
}
}
This is the proxy implementation:
public class FederFarma : FarPreSaEsterniWs
{
public Task<riceviPrenotazioneResponse> riceviPrenotazione(riceviPrenotazioneRequest request)
{
// code...
}
public Task<eliminaPrenotazioneResponse> eliminaPrenotazione(eliminaPrenotazioneRequest request)
{
// code...
}
public Task<verificaDisponibilitaResponse> verificaDisponibilita(verificaDisponibilitaRequest request)
{
// code...
}
}
The function being called is the first one (riceviPrenotazione). Its parameter (request) is not null, but arg0 and arg1 are.
This is my interface:
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://farpresa.esterni.ised.it/", ConfigurationName="FarPreSaEsterniWs")]
public interface FarPreSaEsterniWs
{
[System.ServiceModel.OperationContractAttribute(Action="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/riceviPrenotazioneRequest", ReplyAction="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/riceviPrenotazioneResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
System.Threading.Tasks.Task<riceviPrenotazioneResponse> riceviPrenotazione(riceviPrenotazioneRequest request);
[System.ServiceModel.OperationContractAttribute(Action="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/eliminaPrenotazioneRequest", ReplyAction="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/eliminaPrenotazioneResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
System.Threading.Tasks.Task<eliminaPrenotazioneResponse> eliminaPrenotazione(eliminaPrenotazioneRequest request);
[System.ServiceModel.OperationContractAttribute(Action="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/verificaDisponibilitaRequest", ReplyAction="http://farpresa.esterni.ised.it/FarPreSaEsterniWs/verificaDisponibilitaResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
System.Threading.Tasks.Task<verificaDisponibilitaResponse> verificaDisponibilita(verificaDisponibilitaRequest request);
}
And this is the XML I'm sending via SoapUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:far="http://farpresa.esterni.ised.it/">
<soapenv:Header/>
<soapenv:Body>
<far:riceviPrenotazione>
<!--Optional:-->
<arg0>
<!--Optional:-->
<anagrafica>
<!--Optional:-->
<cellulare>3333333333</cellulare>
<codice>123</codice>
<!--Optional:-->
<codiceFiscale>RSSMRA01A00L885A</codiceFiscale>
<!--Optional:-->
<cognome>Rossi</cognome>
<!--Optional:-->
<comuneDiNascita>
<!--Optional:-->
<codice>L885</codice>
<!--Optional:-->
<descrizione>Vignola</descrizione>
<!--Optional:-->
<fiscale>L885</fiscale>
<!--Optional:-->
<nazione>
<!--Optional:-->
<codice>ITA</codice>
<!--Optional:-->
<descrizione>Italia</descrizione>
<!--Optional:-->
<fiscale>ITA</fiscale>
</nazione>
<!--Optional:-->
<provincia>MO</provincia>
<!--Optional:-->
<regione>
<!--Optional:-->
<codice>ER</codice>
<!--Optional:-->
<descrizione>Emilia-Romagna</descrizione>
</regione>
</comuneDiNascita>
<!--Optional:-->
<domicilioCap>41057</domicilioCap>
<!--Optional:-->
<domicilioComune>
<!--Optional:-->
<codice>F257</codice>
<!--Optional:-->
<descrizione>Modena</descrizione>
<!--Optional:-->
<fiscale>F257</fiscale>
<!--Optional:-->
<nazione>
<!--Optional:-->
<codice>ITA</codice>
<!--Optional:-->
<descrizione>Italia</descrizione>
<!--Optional:-->
<fiscale>ITA</fiscale>
</nazione>
<!--Optional:-->
<provincia>MO</provincia>
<!--Optional:-->
<regione>
<!--Optional:-->
<codice>ER</codice>
<!--Optional:-->
<descrizione>Emilia-Romagna</descrizione>
</regione>
</domicilioComune>
<!--Optional:-->
<domicilioIndirizzo>Via Finta, 12</domicilioIndirizzo>
<!--Optional:-->
<nome>Mario</nome>
<!--Optional:-->
<sesso>M</sesso>
</anagrafica>
<!--Optional:-->
<codice>111</codice>
<!--Optional:-->
<!--Zero or more repetitions:-->
<listaPrenotato>
<!--Optional:-->
<prestazione>
<!--Optional:-->
<codice>222</codice>
<!--Optional:-->
<codiceRegionale>222</codiceRegionale>
<!--Optional:-->
<descrizione>Niente di che</descrizione>
<!--Optional:-->
<specialita>Nullafacentismo</specialita>
</prestazione>
<prezzoUnitario>10</prezzoUnitario>
<quantita>1</quantita>
</listaPrenotato>
<!--Optional:-->
<NRE>080A01234567890</NRE>
<!--Optional:-->
<note>Boh</note>
<prezzoTotale>10</prezzoTotale>
</arg0>
<!--Optional:-->
<arg1>
<!--Optional:-->
<nomeUtente>username</nomeUtente>
<!--Optional:-->
<password>password</password>
</arg1>
</far:riceviPrenotazione>
</soapenv:Body>
</soapenv:Envelope>
According to what I found online, this seems a namespace problem, but all namespaces seem okay to me - SoapUI is consistent with the auto-generated classes, and most importantly they were generated from the same WSDL and not modified. What could be the cause?
Looks like the same issue as mentioned on github: https://github.com/DigDes/SoapCore/issues/79 I assume from the comments you are using SoapCore
Answer was:
Just needed to change DataContractSerializer to XmlSerializer in startup:
app.UseSoapEndpoint<MyService>("/MyService.svc", new BasicHttpBinding(), SoapSerializer.DataContractSerializer);
for this:
app.UseSoapEndpoint<MyService>("/MyService.svc", new BasicHttpBinding(), SoapSerializer.XmlSerializer);
That solution worked for me.

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>

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>