Re: Post to web service on iOS
Posted: Sun Sep 01, 2013 9:02 pm
Ok I have a workaround that consistently returns the correct information:
That first "put url..." stinks! I don't understand why that would be needed.
Setting the httpHeaders to empty makes some sense.
All I can say is that with those two additional lines the code does work consistently in the sim.
Simon
Code: Select all
-- Only needs a button with this code and a text field called 'consola'
local arrayListado
on mouseUp
put url "http://www.google.com" into temp --NEW LINE
put "borrado" into cd fld "consola"
Listado
end mouseUp
private command Listado
put "" into datosPeticion
put "<?xml version='1.0' encoding='utf-8'?>" \
& return & "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" \
& return & tab & "<soap:Body>" \
& return & tab & tab & "<Listado xmlns=" & quote & "http://ws.escrol.es/" & quote & " />" \
& return & tab & "</soap:Body>" \
& return & "</soap:Envelope>" \
into datosPeticion
set the httpHeaders to "POST /WebService.asmx HTTP/1.1" \
& return & "Host: ws.escrol.es" \
& return & "Content-Type: text/xml; charset=utf-8" \
& return & "Content-Length: " & the length of datosPeticion \
& return & "SOAPAction: http://ws.escrol.es/Listado"
put "petición iniciada" &cr&cr into field "consola"
post datosPeticion to url "http://ws.escrol.es/WebService.asmx"
put the result into resultado
put it into datosRespuesta
put "the result: " & resultado &cr&cr after field "consola"
put "it: " & datosRespuesta &cr&cr after field "consola"
put "petición terminada"&cr&cr after field "consola"
set the httpHeaders to empty --NEW LINE
---
end ListadoSetting the httpHeaders to empty makes some sense.
All I can say is that with those two additional lines the code does work consistently in the sim.
Simon