PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → WX - Webservice verificando o cabeçalho Header de acesso antes de liberar os métodos.
WX - Webservice verificando o cabeçalho Header de acesso antes de liberar os métodos.
Débuté par BOLLER, 06 avr. 2017 13:19 - 2 réponses
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 06 avril 2017 - 13:19
Prezados,

Webservice verificando o cabeçalho Header de acesso antes de liberar os métodos:

https://help.windev.com/en-US/…

WsRequest (Tipo de variável) - REQUISITANDO UM WS
Em francês: wsRequête
O tipo wsRequest é usado para definir as características avançadas de um Webservice. Esse tipo de variável é usado principalmente para definir os cabeçalhos HTTP usados ​​por um Webservice. O EBay e SharePoint Websevices exigem esse tipo de cabeçalhos HTTP.
Nota : Consulte Declaração de uma variável para obter mais detalhes.

C is wsRequest
C..HTTPHeader["key"] = "Value"
// Call the procedure of the Webservice
// while passing the header and the expected parameters
WebServiceProc(C, param1_WS, param2_WS)


Observações

Propriedades específicas para a descrição das variáveis ​​wsRequest
As seguintes propriedades podem ser usadas para manipular uma variável wsRequest :
Nome da propriedade Tipo utilizado Efeito
Novo na versão 21

TimeOut
Inteiro Máximo tempo limite de resposta (expresso em milissegundos).
Essa propriedade é definida como 20 segundos por padrão.
HTTPHeader Conjunto associativo de strings Unicode Cabeçalhos HTTP.
XMLSource Binário / Buffer Origem XML enviada para o servidor.
Esta propriedade está disponível somente para leitura.


Nota : Essas propriedades podem ser usadas com uma das seguintes sintaxes:
<Nome da variável> .. <Nome da propriedade>
<Nome da variável>. <Nome da propriedade>
Funções que estão usando as variáveis ​​wsRequest
SOAPAddSAMLAssertion Adiciona uma asserção SAML a uma solicitação Webservice.
SOAPAddXMLSignature Adiciona uma assinatura XML a uma solicitação Webservice.

https://help.windev.com/en-US/…

wsResponse (Type of variable) - PEGANDO O RESULTADO DE WS
O tipo wsResponse é usado para obter:
O código-fonte XML da resposta Webservice.
O valor das diferentes partes da resposta Webservice (para os Webservices retornar várias respostas).
As características deste tipo podem ser definidas e modificadas por várias propriedades do WLanguage.
Nota : Consulte Declaração de uma variável para obter mais detalhes.
Exemplo
Para um WebService que retorna 2 respostas (e não uma resposta estruturada)

WsResp é wsResponse = WSProcedure ()
Trace ( wsResp [ "part1" ]. SubElement1 )
Trace ( wsResp [ "part2" ]. SubElement2 )


Para um WebService para o qual queremos recuperar a resposta inteira XML (eo XML enviado)

// WSDL of WebService:
// http://www.webservicex.net/globalweather.asmx?WSDL

// Variable of parameter type of the WebService function
paramGetWeather is GlobalWeather.GetWeather
paramGetWeather.CityName = "Paris-Charles De Gaulle Airport"
paramGetWeather.CountryName = "France"

// Variable of return type of the WebService function
resGetWeatherResponse is GetWeatherResponse
// Instead of:
// resGetWeatherResponse = GetWeather(paramGetWeather)
// Use a "wsResponse" variable to get the entire XML result and
// a "wsRequest" variable to retrieve everything that was sent to the WebService function
wsResp is wsResponse
wsReq is wsRequest
// Ability to force the HTTP time-out of the request: example HTTPTimeOut(10*1000)
wsResp = GlobalWeather.GetWeather(wsReq,paramGetWeather)
IF ErrorOccurred THEN
// Ability to get the entire XML returned with: wsResp.SourceXML
Error(ErrorInfo(), ...
"---------------------------------- Details of the XML request sent: ", wsReq.SourceXML, ...
"---------------------------------- Details of the XML response received: ", wsResp.SourceXML)

ELSE
// Then, assign the return type of the WebService function to the variable
resGetWeatherResponse=wsResp.Value
// If the result is not the expected one,
// you have the ability to get the entire result XML with wsResp.SourceXML
//trace(resGetWeatherResponse.GetWeatherResult..Value)

xmlWeather is xmlDocument=XMLOpen(resGetWeatherResponse.GetWeatherResult..Value, ...
fromString)
IF ErrorOccurred THEN
Error(ErrorInfo())
ELSE
IF xmlWeather.CurrentWeather.Status..Text~="Success" THEN
Info("City: " + xmlWeather.CurrentWeather.Location, ...
"Time: " + xmlWeather.CurrentWeather.Time, ...
"Wind: " + xmlWeather.CurrentWeather.Wind, ...
"Visibility: " + xmlWeather.CurrentWeather.Visibility, ...
"Temperature: " + xmlWeather.CurrentWeather.Temperature, ...
"Dew point: " + xmlWeather.CurrentWeather.DewPoint, ...
"Humidity: " + xmlWeather.CurrentWeather.RelativeHumidity, ...
"Pressure: " + xmlWeather.CurrentWeather.Pressure)
ELSE
Error(resGetWeatherResponse.GetWeatherResult, ...
"---------------------------------- Details of the XML response received:", wsResp.SourceXML)
END
END
END


Observações
Propriedades específicas para a descrição das variáveis ​​wsResponse
As seguintes propriedades podem ser usadas para manipular uma variável wsResponse :
Nome da propriedade Tipo utilizado Efeito
ResponsePart Array Usado para obter o código XML correspondente à resposta especificada.
Você também tem a capacidade de usar a seguinte notação:
Name_wsResponse_Variable ["Response_name"]
Esta propriedade está disponível somente para leitura.
XMLSource Binário / Buffer Origem XML recebida do servidor.
Esta propriedade está disponível somente para leitura.
Valor Cadeia de caracteres Retorna o código XML correspondente à primeira parte da resposta.
Esta propriedade está disponível somente para leitura.
Cuidado: Se o Webservice ne retorna uma única resposta, recomendamos que você mantenha a seguinte sintaxe:

res is ReturnType = WSProcedure()


Nota : Essas propriedades podem ser usadas com uma das seguintes sintaxes:
<Nome da variável> .. <Nome da propriedade>
<Nome da variável>. <Nome da propriedade>
Modo operacional
O tipo wsResponse é usado para obter a origem XML da solicitação enviada para o consumo do Webservice.
SOAPPrepare já fornece as informações para o caso geral, mas não quando o Webservice requer:
Dados específicos em seu cabeçalho ( SOAPAddHeader ),
Uma asserção ( SOAPAddSAMLAssertion ) no caso de Sesam Vitale por exemplo.
Praticamente, a chamada padrão para uma função:

WebserviceResponse = WebserviceFunction(Param1, Param2)


Pode ser substituído por:

MyRequest is wsRequest
WebserviceResponse = WebserviceFunction(MyRequest, Param1, Param2)


A fonte XML inteira da solicitação pode ser incluída em um buffer através do seguinte código:

MyRequest..XMLSource


Esse recurso pode ser útil durante a etapa de design e é necessário obter algumas certificações.

:merci:

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
203 messages
Popularité : +25 (25 votes)
Posté le 06 avril 2017 - 18:05
Seria muito legal se fosse disponibilizado um exemplo usando o webservice do Google Adwords!

--
André Martini
IS2 Automotive http://www.is2.inf.br/is2automotive/index.html
IS2 Construtive http://www.is2.inf.br/is2construtive/index.html
IS2 Store http://www.is2.inf.br/is2store/index.html
IS2 Gerent http://www.is2.inf.br/is2gerent/index.html
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 11 mai 2017 - 15:30
Material adicional sobre o assunto:



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