PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → soap call to a external webservice including header
soap call to a external webservice including header
Débuté par Gustavo Gonzalez, 16 mar. 2018 20:26 - 2 réponses
Posté le 16 mars 2018 - 20:26
Hello I wanted to see if someone can help me with the necessary syntax in WINDEV to call a webservice including data that is passed as part of the header ...

The first thing I did was to try it in the most standard way possible and for that I used the SOAPUI program
https://www.soapui.org/
In that program I address the direction of Webserice to: https://hdi.com.uy/hdi/ExternalQuotation/ExternalQuotationMethods.svc

then the request and it works perfectly

<soapenv:Envelope xmlns:ext="http://schemas.datacontract.org/2004/07/ExternalQuotation.Model.Data" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"><soapenv:Header>
<wsse:Security 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" soapenv:mustUnderstand="1">
<wsse:UsernameToken wsu:Id="">
<wsse:Username>XXX</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXX</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"></wsse:Nonce>
<wsu:Created>2017-12-21T14:48:01.646Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header><soapenv:Body>
<tem:GetAgentDataDTOList>
<tem:filter><ext:PageNumber>1</ext:PageNumber><ext:PageSize>50</ext:PageSize>
</tem:filter>
</tem:GetAgentDataDTOList>
</soapenv:Body></soapenv:Envelope>



but if I try to do it from WINDEV it does not work for me, it returns false ...



sMensajeXML is string = [
<soapenv:Envelope xmlns:ext="http://schemas.datacontract.org/2004/07/ExternalQuotation.Model.Data" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"><soapenv:Header>
<wsse:Security 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" soapenv:mustUnderstand="1">
<wsse:UsernameToken wsu:Id="">
<wsse:Username>XUSUARIOX</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XCLAVEX</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"></wsse:Nonce>
<wsu:Created>2017-12-21T14:48:01.646Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header><soapenv:Body>
<tem:GetAgentDataDTOList>
<tem:filter><ext:PageNumber>1</ext:PageNumber><ext:PageSize>50</ext:PageSize>
</tem:filter>
</tem:GetAgentDataDTOList>
</soapenv:Body></soapenv:Envelope>

]


bResultado is boolean = SOAPRunXML("https://hdi.com.uy/hdi/ExternalQuotation/ExternalQuotationMethods.svc", sMensajeXML)
Info(bResultado)
//Return: false
Info(ErrorInfo)
////Return: Security Alert: name on security is incorrect or does not match the selected site.



Did something similar happen to someone?
Any idea what would be the correct way to write this in WLANGUAJE?
Membre enregistré
16 messages
Posté le 19 mars 2018 - 15:17
Try using the created structures of the imported webservice

i once had to call a webservice with header and it ended up like this:

Header is string=''''
Header+="<soapenv:Header>"
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"">"
Header+="<wsse:UsernameToken wsu:Id=""UsernameToken-730C01D84F852BD37A15093785037226"">"
Header+="<wsse:Username>%1</wsse:Username>"
Header+="<wsse:Password Type=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0…"">%2</wsse:Password>"
Header+="</wsse:UsernameToken>"
Header+="</wsse:Security>"
Header+="</soapenv:Header>"

EndPointWS is string="https://qualsiliamb.apambiente.pt/egar/services/GuiaAcompanhamentoWs/v2"

sToken is string="XXXXXXXXXXXXXXXXXXX"

sPassword is string
sPassword=EDT_Password

ConsultaTransp is consultaDadosTransportadorInput
ConsultaTransp.nif=EDT_Contribuinte
ConsultaTransp.tokenCertificacao=sToken

XmlString is string
XmlString=SOAPPrepare(consultaDadosTransportador,ConsultaTransp)
XmlString=Replace(XmlString,"<SOAP-ENV:Header/>",StringBuild(Header,EDT_Contribuinte,sPassword),IgnoreCase)
XmlString=Replace(XmlString,"SOAP-ENV","soapenv",IgnoreCase)

bResposta is boolean
bResposta=SOAPRunXML(EndPointWS,XmlString,"")
IF bResposta=False THEN
Error(SOAPError(SOAPErrMessage))
RETURN
END

sResposta is string
sResposta=''<?xml version=''''1.0'''' encoding=''''ISO-8859-1''''?>''+SOAPGetResult(SOAPXMLResult)

Resultado is xmlDocument
Resultado=XMLOpen(sResposta,fromString)


consultaDadosTransportadorInput is what windev imported from the webservice and consultaDadosTransportador is the function

Note: i replaced " with '' in sResposta
Posté le 15 décembre 2021 - 20:25
Hallo Gustavo, you had found a solution to this problem. I have a similar problem too. Thx