Utilisation du webservice de météo GlobalWeatherSoap avec Delphi
Bonjour
Je débute avec l'utilisation de webService avec Delphi 7.
J'ai récupéré le fichier WSDL que j'ai importé avec l'importateur de fichier WSDL de Delphi
J'ai mis alors l'instruction suivante :
Memo1.Text := GetGlobalWeatherSoap(True,'',nil).GetCitiesByCountry('PARIS'); mais j'ai l'erreur suivante à l'exécution :
Citation:
procedure or function 'getWCity' expects parameter @CountryName which was not supplied
Visiblement le paramètre n'est pas transmis
Est-ce quelqu'un aurait une idée pour me dépanner ?
Ci-dessous le code généré par l'importateur de WSDL
Merci d'avance
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| // ************************************************************************ //
// Les types déclaré dans ce fichier ont été générés à partir de données lues dans le fichier
// WSDL décrit ci-dessous :
// WSDL : C:\ESSAI\meteo.wsdl
// Codegen : [wfDebug,wfUseSerializerClassForAttrs]
// (24/09/2012 16:13:04 - 1.33.2.5)
// ************************************************************************ //
unit meteo;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
// ************************************************************************ //
// Les types suivants mentionnés dans le document WSDL ne sont pas représentés
// dans ce fichier. Ce sont soit des alias[@] de types représentés ou alors ils sont
// référencés mais jamais[!] déclarés dans ce document. Les types de la dernière catégorie
// sont en principe mappés à des types Borland ou XML prédéfinis/connus. Toutefois, ils peuvent aussi
// signaler des documents WSDL incorrects n'ayant pas réussi à déclarer ou importer un type de schéma.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// ************************************************************************ //
// Espace de nommage : <a href="http://www.webserviceX.NET" target="_blank">http://www.webserviceX.NET</a>
// soapAction : <a href="http://www.webserviceX.NET/%operationName%" target="_blank">http://www.webserviceX.NET/%operationName%</a>
// transport : <a href="http://schemas.xmlsoap.org/soap/http" target="_blank">http://schemas.xmlsoap.org/soap/http</a>
// liaison : GlobalWeatherSoap
// service : GlobalWeather
// port : GlobalWeatherSoap
// URL : <a href="http://www.webservicex.net/globalweather.asmx" target="_blank">http://www.webservicex.net/globalweather.asmx</a>
// ************************************************************************ //
GlobalWeatherSoap = interface(IInvokable)
['{8091B155-5793-08E1-8C8C-B170D069C2CB}']
function GetWeather(const CityName: WideString; const CountryName: WideString): WideString; stdcall;
function GetCitiesByCountry(const CountryName: WideString): WideString; stdcall;
end;
function GetGlobalWeatherSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): GlobalWeatherSoap;
implementation
function GetGlobalWeatherSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): GlobalWeatherSoap;
const
defWSDL = 'C:\ESSAI\meteo.wsdl';
defURL = 'http://www.webservicex.net/globalweather.asmx';
defSvc = 'GlobalWeather';
defPrt = 'GlobalWeatherSoap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as GlobalWeatherSoap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(GlobalWeatherSoap), 'http://www.webserviceX.NET', '');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(GlobalWeatherSoap), 'http://www.webserviceX.NET/%operationName%');
end. |