PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 25 → Webservice Soap com Autenticação no cabeçalho/Header
Webservice Soap com Autenticação no cabeçalho/Header
Iniciado por Boller, jun., 28 2020 1:44 PM - Sem resposta
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em junho, 28 2020 - 1:44 PM
Bom dia

Segue abaixo o exemplo

Les requêtes aux WebServices sont envoyées au serveur Web enveloppées DANS un Document xml. Pour certains WebServices lauthentification est faite grâce un entête à ajouter au Document xml.

Prenons par exemple un WebService qui nécessite ce type dauthentification :

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:net="http://www.WS.TEST/TestST">

<soapenv:Header>

<WebServiceLogin xsi:type="net:WebServiceLogin">

<RefClient xsi:type="xsd:int">?</refClient>

<NomUser xsi:type="xsd:string">?</NomUser>

<MotPasse xsi:type="xsd:string">?</MotPasse>

</WebServiceUser>

</soapenv:Header>

<soapenv:Body>

<net:getListeCommandes soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<dateDeb xsi:type="xsd:string">?</dateDeb>

<dateFin xsi:type="xsd:string">?</dateFin>

</net: getListeCommandes >

</soapenv:Body>

</soapenv:Envelope>

On voit DANS une requête type, la partie concernant lenveloppe, une partie « Header » AVEC lauthentification ET une partie « Body » AVEC lappel du WebService.

une fois importé DANS WINDEV, le WebService va exposer la Procedure getListeCommandes qui attend deux paramètres (une date de début ET une date de FIN) ET une structure WebServiceLogin.

DANS ce WebService, il faut donc ajouter lors de lauthentification la référence client, le nom de lutilisateur ET le mot de passe DANS lentête du Document xml. On Utilise pour cela la FONCTION SOAPAjouteEntête() en déclarant une Variable de ce type :



LoginWs est un WebServiceLogin

LoginWs.RefClient = "9811X1255"

LoginWs.NomUser = "adresse.complement@domaine.fr"

LoginWs.MotPasse = "MotPasse"

SOAPAjouteEntête(TestST,LoginWs)



Vous pouvez ensuite appeler directement la FONCTION du WebService souhaitée :

wsResponse = TestST.GetListeCommandes("20190114","20200414")


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/