AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / SOAP
  • Propiedades específicas de las variables wsResponse
  • Modo de funcionamiento
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Otros
Procedimientos almacenados
wsResponse (Tipo de Variable)
 
El tipo wsResponse se usa para get:
  • el código fuente XML de la respuesta del servicio web.
  • el valor de las diferentes partes de la respuesta del servicio web (para los servicios web que devuelven varias respuestas).
Las características de este tipo se pueden definir y cambiar mediante diferentes propiedades WLanguage.
Observación: Para obtener más información sobre la declaración de este tipo de variable y el uso de propiedades WLanguage, consulte Declarar una variable.
Ejemplo
Para un servicio web que devuelve 2 respuestas (y no una respuesta estructurada)
wsResp is wsResponse = WSProcedure()
Trace(wsResp["part1"].subElement1)
Trace(wsResp["part2"].subElement2)
Para un servicio web para el que queremos recuperar toda la respuesta XML (y el 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 timeout of the request: example HTTPTimeOut(10*1000)
wsResp = GlobalWeather.GetWeather(wsReq,paramGetWeather)
IF ErrorOccurred THEN
// Ability to get the entire XML returned with: wsResp.XMLSource
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 can get the entire XML result with wsResp.XMLSource
//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
Observaciones

Propiedades específicas de las variables wsResponse

Las siguientes propiedades pueden utilizarse para manipular variables de tipo wsResponse:
Nombre de la propiedadTipo utilizadoEfecto
ResponsePartArrayUsó para get el código XML correspondiente a la respuesta especificada.
Usted también tiene la capacidad de usar la siguiente notación:
Name_wsResponse_Variable["Response_name"]
Esta propiedad es de solo lectura.
ValorCadena de caracteresDevuelve el código XML correspondiente a la primera parte de la respuesta.
Esta propiedad es de solo lectura.
XMLSourceBinario/BufferFuente XML recibida del servidor.
Esta propiedad es de solo lectura.

Atención: Si el Webservice devuelve sólo una respuesta, se recomienda mantener la siguiente sintaxis:
res is ReturnType = WSProcedure()

Modo de funcionamiento

El tipo wsResponse se utiliza para get la fuente XML de la solicitud enviada para el consumo del Webservice.
SOAPPrepare ya da la información para el caso general pero no cuando el Webservice lo requiere:
Prácticamente, la llamada estándar a una función:
WebserviceResponse = WebserviceFunction(Param1, Param2)
puede ser sustituido por:
MyRequest is wsRequest
WebserviceResponse = WebserviceFunction(MyRequest, Param1, Param2)
La fuente XML completa de la solicitud puede incluirse en un buffer mediante el siguiente código:
MyRequest..XMLSource
Esta característica puede ser útil durante el paso de diseño y se requiere para get algunas certificaciones.
Versión mínima requerida
  • Versión 18
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 22/06/2023

Señalar un error o enviar una sugerencia | Ayuda local