Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
dost
Üye
Mesajlar: 104 Kayıt: 08 Oca 2004 11:33
Mesaj
gönderen dost » 18 Oca 2012 06:11
merhaba arkadaşlar,
Kod: Tümünü seç
procedure TForm1.Button1Click(Sender: TObject);
begin
HTTPRIO1.WSDLLocation := 'http://www.webservicex.net/globalweather.asmx?WSDL';
Memo1.Text := (HTTPRIO1 as GlobalWeatherSoap).GetCitiesByCountry(Edit1.Text);
Memo1.Lines.SaveToFile('test.xml');
end;
delphi xe2 ile WSDL import edemedim.
nasıl yapılacağı konusunda yardımcı olabilirmisiniz?
teşekkürler.
En son
dost tarafından 19 Oca 2012 12:30 tarihinde düzenlendi, toplamda 1 kere düzenlendi.
r3n4m3
Üye
Mesajlar: 16 Kayıt: 17 Ağu 2010 04:31
Konum: Ankara
Mesaj
gönderen r3n4m3 » 19 Oca 2012 08:47
Arkadaşım merhabar
Senin yazdığın gibi olmuyor
WSDL ilk önce bir unite çevireceksin ondan sonra kullanacaksın.
Sana wsdlin uniti veriyorum onu dahil et ve kullan.
Kod: Tümünü seç
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://www.webservicex.net/WeatherForecast.asmx?WSDL
// >Import : http://www.webservicex.net/WeatherForecast.asmx?WSDL>0
// Encoding : utf-8
// Version : 1.0
// (19.01.2012 08:45:28 - - $Rev: 12980 $)
// ************************************************************************ //
unit WeatherForecast;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
const
IS_OPTN = $0001;
IS_UNBD = $0002;
IS_REF = $0080;
type
// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:float - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl]
WeatherForecasts = class; { "http://www.webservicex.net"[GblCplx] }
WeatherData = class; { "http://www.webservicex.net"[GblCplx] }
WeatherForecasts2 = class; { "http://www.webservicex.net"[GblElm] }
ArrayOfWeatherData = array of WeatherData; { "http://www.webservicex.net"[GblCplx] }
// ************************************************************************ //
// XML : WeatherForecasts, global, <complexType>
// Namespace : http://www.webservicex.net
// ************************************************************************ //
WeatherForecasts = class(TRemotable)
private
FLatitude: Single;
FLongitude: Single;
FAllocationFactor: Single;
FFipsCode: WideString;
FFipsCode_Specified: boolean;
FPlaceName: WideString;
FPlaceName_Specified: boolean;
FStateCode: WideString;
FStateCode_Specified: boolean;
FStatus: WideString;
FStatus_Specified: boolean;
FDetails: ArrayOfWeatherData;
FDetails_Specified: boolean;
procedure SetFipsCode(Index: Integer; const AWideString: WideString);
function FipsCode_Specified(Index: Integer): boolean;
procedure SetPlaceName(Index: Integer; const AWideString: WideString);
function PlaceName_Specified(Index: Integer): boolean;
procedure SetStateCode(Index: Integer; const AWideString: WideString);
function StateCode_Specified(Index: Integer): boolean;
procedure SetStatus(Index: Integer; const AWideString: WideString);
function Status_Specified(Index: Integer): boolean;
procedure SetDetails(Index: Integer; const AArrayOfWeatherData: ArrayOfWeatherData);
function Details_Specified(Index: Integer): boolean;
public
destructor Destroy; override;
published
property Latitude: Single read FLatitude write FLatitude;
property Longitude: Single read FLongitude write FLongitude;
property AllocationFactor: Single read FAllocationFactor write FAllocationFactor;
property FipsCode: WideString Index (IS_OPTN) read FFipsCode write SetFipsCode stored FipsCode_Specified;
property PlaceName: WideString Index (IS_OPTN) read FPlaceName write SetPlaceName stored PlaceName_Specified;
property StateCode: WideString Index (IS_OPTN) read FStateCode write SetStateCode stored StateCode_Specified;
property Status: WideString Index (IS_OPTN) read FStatus write SetStatus stored Status_Specified;
property Details: ArrayOfWeatherData Index (IS_OPTN) read FDetails write SetDetails stored Details_Specified;
end;
// ************************************************************************ //
// XML : WeatherData, global, <complexType>
// Namespace : http://www.webservicex.net
// ************************************************************************ //
WeatherData = class(TRemotable)
private
FDay: WideString;
FDay_Specified: boolean;
FWeatherImage: WideString;
FWeatherImage_Specified: boolean;
FMaxTemperatureF: WideString;
FMaxTemperatureF_Specified: boolean;
FMinTemperatureF: WideString;
FMinTemperatureF_Specified: boolean;
FMaxTemperatureC: WideString;
FMaxTemperatureC_Specified: boolean;
FMinTemperatureC: WideString;
FMinTemperatureC_Specified: boolean;
procedure SetDay(Index: Integer; const AWideString: WideString);
function Day_Specified(Index: Integer): boolean;
procedure SetWeatherImage(Index: Integer; const AWideString: WideString);
function WeatherImage_Specified(Index: Integer): boolean;
procedure SetMaxTemperatureF(Index: Integer; const AWideString: WideString);
function MaxTemperatureF_Specified(Index: Integer): boolean;
procedure SetMinTemperatureF(Index: Integer; const AWideString: WideString);
function MinTemperatureF_Specified(Index: Integer): boolean;
procedure SetMaxTemperatureC(Index: Integer; const AWideString: WideString);
function MaxTemperatureC_Specified(Index: Integer): boolean;
procedure SetMinTemperatureC(Index: Integer; const AWideString: WideString);
function MinTemperatureC_Specified(Index: Integer): boolean;
published
property Day: WideString Index (IS_OPTN) read FDay write SetDay stored Day_Specified;
property WeatherImage: WideString Index (IS_OPTN) read FWeatherImage write SetWeatherImage stored WeatherImage_Specified;
property MaxTemperatureF: WideString Index (IS_OPTN) read FMaxTemperatureF write SetMaxTemperatureF stored MaxTemperatureF_Specified;
property MinTemperatureF: WideString Index (IS_OPTN) read FMinTemperatureF write SetMinTemperatureF stored MinTemperatureF_Specified;
property MaxTemperatureC: WideString Index (IS_OPTN) read FMaxTemperatureC write SetMaxTemperatureC stored MaxTemperatureC_Specified;
property MinTemperatureC: WideString Index (IS_OPTN) read FMinTemperatureC write SetMinTemperatureC stored MinTemperatureC_Specified;
end;
// ************************************************************************ //
// XML : WeatherForecasts, global, <element>
// Namespace : http://www.webservicex.net
// ************************************************************************ //
WeatherForecasts2 = class(WeatherForecasts)
private
published
end;
// ************************************************************************ //
// Namespace : http://www.webservicex.net
// soapAction: http://www.webservicex.net/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : WeatherForecastSoap
// service : WeatherForecast
// port : WeatherForecastSoap
// URL : http://www.webservicex.net/WeatherForecast.asmx
// ************************************************************************ //
WeatherForecastSoap = interface(IInvokable)
['{45A46EB0-5550-8C38-49AC-AE13AD113F74}']
function GetWeatherByZipCode(const ZipCode: WideString): WeatherForecasts; stdcall;
function GetWeatherByPlaceName(const PlaceName: WideString): WeatherForecasts; stdcall;
end;
function GetWeatherForecastSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): WeatherForecastSoap;
implementation
uses SysUtils;
function GetWeatherForecastSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): WeatherForecastSoap;
const
defWSDL = 'http://www.webservicex.net/WeatherForecast.asmx?WSDL';
defURL = 'http://www.webservicex.net/WeatherForecast.asmx';
defSvc = 'WeatherForecast';
defPrt = 'WeatherForecastSoap';
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 WeatherForecastSoap);
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;
destructor WeatherForecasts.Destroy;
var
I: Integer;
begin
for I := 0 to System.Length(FDetails)-1 do
SysUtils.FreeAndNil(FDetails[I]);
System.SetLength(FDetails, 0);
inherited Destroy;
end;
procedure WeatherForecasts.SetFipsCode(Index: Integer; const AWideString: WideString);
begin
FFipsCode := AWideString;
FFipsCode_Specified := True;
end;
function WeatherForecasts.FipsCode_Specified(Index: Integer): boolean;
begin
Result := FFipsCode_Specified;
end;
procedure WeatherForecasts.SetPlaceName(Index: Integer; const AWideString: WideString);
begin
FPlaceName := AWideString;
FPlaceName_Specified := True;
end;
function WeatherForecasts.PlaceName_Specified(Index: Integer): boolean;
begin
Result := FPlaceName_Specified;
end;
procedure WeatherForecasts.SetStateCode(Index: Integer; const AWideString: WideString);
begin
FStateCode := AWideString;
FStateCode_Specified := True;
end;
function WeatherForecasts.StateCode_Specified(Index: Integer): boolean;
begin
Result := FStateCode_Specified;
end;
procedure WeatherForecasts.SetStatus(Index: Integer; const AWideString: WideString);
begin
FStatus := AWideString;
FStatus_Specified := True;
end;
function WeatherForecasts.Status_Specified(Index: Integer): boolean;
begin
Result := FStatus_Specified;
end;
procedure WeatherForecasts.SetDetails(Index: Integer; const AArrayOfWeatherData: ArrayOfWeatherData);
begin
FDetails := AArrayOfWeatherData;
FDetails_Specified := True;
end;
function WeatherForecasts.Details_Specified(Index: Integer): boolean;
begin
Result := FDetails_Specified;
end;
procedure WeatherData.SetDay(Index: Integer; const AWideString: WideString);
begin
FDay := AWideString;
FDay_Specified := True;
end;
function WeatherData.Day_Specified(Index: Integer): boolean;
begin
Result := FDay_Specified;
end;
procedure WeatherData.SetWeatherImage(Index: Integer; const AWideString: WideString);
begin
FWeatherImage := AWideString;
FWeatherImage_Specified := True;
end;
function WeatherData.WeatherImage_Specified(Index: Integer): boolean;
begin
Result := FWeatherImage_Specified;
end;
procedure WeatherData.SetMaxTemperatureF(Index: Integer; const AWideString: WideString);
begin
FMaxTemperatureF := AWideString;
FMaxTemperatureF_Specified := True;
end;
function WeatherData.MaxTemperatureF_Specified(Index: Integer): boolean;
begin
Result := FMaxTemperatureF_Specified;
end;
procedure WeatherData.SetMinTemperatureF(Index: Integer; const AWideString: WideString);
begin
FMinTemperatureF := AWideString;
FMinTemperatureF_Specified := True;
end;
function WeatherData.MinTemperatureF_Specified(Index: Integer): boolean;
begin
Result := FMinTemperatureF_Specified;
end;
procedure WeatherData.SetMaxTemperatureC(Index: Integer; const AWideString: WideString);
begin
FMaxTemperatureC := AWideString;
FMaxTemperatureC_Specified := True;
end;
function WeatherData.MaxTemperatureC_Specified(Index: Integer): boolean;
begin
Result := FMaxTemperatureC_Specified;
end;
procedure WeatherData.SetMinTemperatureC(Index: Integer; const AWideString: WideString);
begin
FMinTemperatureC := AWideString;
FMinTemperatureC_Specified := True;
end;
function WeatherData.MinTemperatureC_Specified(Index: Integer): boolean;
begin
Result := FMinTemperatureC_Specified;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(WeatherForecastSoap), 'http://www.webservicex.net', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WeatherForecastSoap), 'http://www.webservicex.net/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(WeatherForecastSoap), ioDocument);
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfWeatherData), 'http://www.webservicex.net', 'ArrayOfWeatherData');
RemClassRegistry.RegisterXSClass(WeatherForecasts, 'http://www.webservicex.net', 'WeatherForecasts');
RemClassRegistry.RegisterXSClass(WeatherData, 'http://www.webservicex.net', 'WeatherData');
RemClassRegistry.RegisterXSClass(WeatherForecasts2, 'http://www.webservicex.net', 'WeatherForecasts2', 'WeatherForecasts');
end.
Education is what you get from reading the small print. Experience is what you get from not reading it.
vkamadan
Kıdemli Üye
Mesajlar: 1935 Kayıt: 17 Mar 2004 03:52
Konum: Adapazarı
İletişim:
Mesaj
gönderen vkamadan » 19 Oca 2012 09:14
Merhaba ,
Bir WSDL dosyasını yada WSDL çıktı üreten bir URL yi projenize Interface uniti olarak eklemek için kullanmanız gereken "New-Project-Others" altında Web Services kırılımında yer alan WSDL Importer aracıdır.
Kolay gelsin.
dost
Üye
Mesajlar: 104 Kayıt: 08 Oca 2004 11:33
Mesaj
gönderen dost » 19 Oca 2012 12:33
merhaba,
ilgilenen arkadaşlara çok teşekkür ederim.
kolay gelsin.