Fórum Consumindo webservice java em delphi 7 #392091
08/12/2010
0
Galera, estou precisando consumir um WebService feito em Java no Delphi 7. Pelo que já li na internet isso é possível.. mas não estou conseguindo..
Estou fazendo o seguinte processo:
vou em File-> New->Other->WebServices -> Wsdl Importer
e ponho o endereço
http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean?wsdl
ele monta para mim o xml
Código:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean?wsdl
// (03/12/2010 09:46:51 - 1.33.2.5)
// ************************************************************************ //
unit BionexoBean_h;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
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.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// ************************************************************************ //
// Namespace : http://webservice.bionexo.com/
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : BionexoInterfaceBinding
// service : BionexoBeanService
// port : BionexoPort
// URL : http://192.168.10.180:8380/bionexo-wsEAR-bionexo-wsn/BionexoBean
// ************************************************************************ //
BionexoInterface = interface(IInvokable)
['{7EC6C30E-714E-00C5-74ED-246F3531CC8C}']
function post(const login: WideString; const password: WideString; const operation: WideString; const parameters: WideString; const xml: WideString): WideString; stdcall;
function request(const login: WideString; const password: WideString; const operation: WideString; const parameters: WideString): WideString; stdcall;
end;
function GetBionexoInterface(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): BionexoInterface;
implementation
function GetBionexoInterface(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): BionexoInterface;
const
defWSDL = 'http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean?wsdl';
defURL = 'http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean';
defSvc = 'BionexoBeanService';
defPrt = 'BionexoPort';
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 BionexoInterface);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
RIO.URL := defURL;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(BionexoInterface), 'http://webservice.bionexo.com/', '');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(BionexoInterface), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(BionexoInterface), ioLiteral);
end.
obs.: precisei mudar o endereço defURL para
defURL = 'http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean';
Montei um uma nova unit e instanciei da seguinte forma.
Código:
unit uBionexo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
const
login = 'ws_';
paswd = '1234';
WGG = 'WGG';
WHS = 'WHS';
WHU = 'WHU';
implementation
uses BionexoBean_h;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
bionexo: BionexoInterface;
begin
bionexo := GetBionexoInterface();
bionexo.request(login, paswd, WGG, 'TOKEN=0');
end;
end.
quando clico em no botão ele me dá a msg.
Código:
Endpoint {http://webservice.bionexo.com/}BionexoPort does not contain operation meta data for: login.
obs.: o usuário e senha do exemplo acima citado são inválidos.são somente teste.
Estou fazendo o seguinte processo:
vou em File-> New->Other->WebServices -> Wsdl Importer
e ponho o endereço
http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean?wsdl
ele monta para mim o xml
Código:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean?wsdl
// (03/12/2010 09:46:51 - 1.33.2.5)
// ************************************************************************ //
unit BionexoBean_h;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
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.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// ************************************************************************ //
// Namespace : http://webservice.bionexo.com/
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : BionexoInterfaceBinding
// service : BionexoBeanService
// port : BionexoPort
// URL : http://192.168.10.180:8380/bionexo-wsEAR-bionexo-wsn/BionexoBean
// ************************************************************************ //
BionexoInterface = interface(IInvokable)
['{7EC6C30E-714E-00C5-74ED-246F3531CC8C}']
function post(const login: WideString; const password: WideString; const operation: WideString; const parameters: WideString; const xml: WideString): WideString; stdcall;
function request(const login: WideString; const password: WideString; const operation: WideString; const parameters: WideString): WideString; stdcall;
end;
function GetBionexoInterface(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): BionexoInterface;
implementation
function GetBionexoInterface(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): BionexoInterface;
const
defWSDL = 'http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean?wsdl';
defURL = 'http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean';
defSvc = 'BionexoBeanService';
defPrt = 'BionexoPort';
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 BionexoInterface);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
RIO.URL := defURL;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(BionexoInterface), 'http://webservice.bionexo.com/', '');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(BionexoInterface), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(BionexoInterface), ioLiteral);
end.
obs.: precisei mudar o endereço defURL para
defURL = 'http://homolog.bionexo.com.br/bionexo-wsEAR-bionexo-wsn/BionexoBean';
Montei um uma nova unit e instanciei da seguinte forma.
Código:
unit uBionexo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
const
login = 'ws_';
paswd = '1234';
WGG = 'WGG';
WHS = 'WHS';
WHU = 'WHU';
implementation
uses BionexoBean_h;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
bionexo: BionexoInterface;
begin
bionexo := GetBionexoInterface();
bionexo.request(login, paswd, WGG, 'TOKEN=0');
end;
end.
quando clico em no botão ele me dá a msg.
Código:
Endpoint {http://webservice.bionexo.com/}BionexoPort does not contain operation meta data for: login.
obs.: o usuário e senha do exemplo acima citado são inválidos.são somente teste.
Politran Ltda
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)