WebService Java + Servidor JBoss + Client Delphi 7

0 respostas
regifelix

WebService Java + Servidor JBoss + Client Delphi 7

Estou fazendo testes em WebService no JBoss e estou com um problema ao acessar o webservice pelo Delphi.
Criei dois metodos no WebService, o primeiro não recebe parametro nenhum so devolve um valor string. O Segundo recebe um parametro String e devolve uma string concatenada.
No segundo estou tendo problema na passagem de parâmetro do delphi para o webservice. O seviço esta recebendo null no parametro.
Alguem sabe o que pode estar ocorrendo ?

Segue o codigo do webservice e o codigo de acesso do delphi:
No codigo abaixo a funçao gravar com parametro esta recebendo sempre null no parametro de envio.


//codigo webservice

package com.sistemabancario.servico;

import javax.ejb.;
import javax.jws.
;

@Stateless
@WebService
public class GerenteWS implements GerenteWSRemote {

public String gravarSemParametro() {
	//
	System.out.println("WebService executado no servidor.");
	//
	return "ParametroDeRetorno";
}

@Override
public String gravarComParametro(String envio) {
	// TODO Auto-generated method stub
	return envio + " adicionei mais texto no retorno";
}

}


Codigo Delphi da Classe de Acesso ao WebService

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost:8080/SistemaBancarioEJB/GerenteWS?wsdl
// (20/07/2009 09:59:40 - 1.33.2.5)
// ************************************************************************ //

unit GerenteWS1;

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 : <a href="http://servico.sistemabancario.com/">http://servico.sistemabancario.com/</a>

// transport : <a href="http://schemas.xmlsoap.org/soap/http">http://schemas.xmlsoap.org/soap/http</a>

// style     : document

// binding   : GerenteWSBinding

// service   : GerenteWSService

// port      : GerenteWSPort

// URL       : <a href="http://127.0.0.1:8080/SistemaBancarioEJB/GerenteWS">http://127.0.0.1:8080/SistemaBancarioEJB/GerenteWS</a>

// ************************************************************************ //

GerenteWS = interface(IInvokable)

[’{4FBA3E30-3C2B-2579-2B43-B1676B2FB70F}’]

function  gravarComParametro(const arg0: WideString): WideString; stdcall;

function  gravarSemParametro: WideString; stdcall;

end;

type

TWSGerenteWS = class(TObject)

public

function gravarSemParametro: WideString;

function  gravarComParametro(const arg0: WideString): WideString; stdcall;

private

end;
function GetGerenteWS(UseWSDL: Boolean=System.False; Addr: string=’’; HTTPRIO: THTTPRIO = nil): GerenteWS;

implementation

function TWSGerenteWS.gravarSemParametro: WideString;

var RIO: THTTPRIO;

ws: GerenteWS;

oldSeparator: Char;

retorno: WideString;

begin
try

RIO := THTTPRIO.Create(nil);

RIO.HTTPWebNode.ConnectTimeout := 100;

RIO.HTTPWebNode.SendTimeout    := 100;

RIO.HTTPWebNode.ReceiveTimeout := 100;

ws := GetGerenteWS(false, ‘’, RIO);

retorno := ws.gravarSemParametro;

result := retorno;

Finally
end;

end;

function TWSGerenteWS.gravarComParametro(const arg0: WideString): WideString;

var RIO: THTTPRIO;

ws: GerenteWS;

oldSeparator: Char;

retorno: WideString;

begin
try

RIO := THTTPRIO.Create(nil);

RIO.HTTPWebNode.ConnectTimeout := 100;

RIO.HTTPWebNode.SendTimeout    := 100;

RIO.HTTPWebNode.ReceiveTimeout := 100;

ws := GetGerenteWS(false, ‘’, RIO);

retorno := ws.gravarComParametro(arg0);

result := retorno;

Finally

end;
end;

function GetGerenteWS(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): GerenteWS;

const

defWSDL = <a href="http://localhost:8080/SistemaBancarioEJB/GerenteWS?wsdl">http://localhost:8080/SistemaBancarioEJB/GerenteWS?wsdl</a>;

defURL  = <a href="http://127.0.0.1:8080/SistemaBancarioEJB/GerenteWS">http://127.0.0.1:8080/SistemaBancarioEJB/GerenteWS</a>;

defSvc  = GerenteWSService;

defPrt  = GerenteWSPort;

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 GerenteWS);

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(GerenteWS), <a href="http://servico.sistemabancario.com/">http://servico.sistemabancario.com/</a>’, ‘’);

InvRegistry.RegisterDefaultSOAPAction(TypeInfo(GerenteWS), ‘’);

InvRegistry.RegisterInvokeOptions(TypeInfo(GerenteWS), ioDocument);

end.


Codigo Delphi da classe de teste

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type

TForm1 = class(TForm)

Button: TButton;

procedure ButtonClick(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var
Form1: TForm1;

implementation

uses GerenteWS1;

{$R *.dfm}

procedure TForm1.ButtonClick(Sender: TObject);

var GerenteWS : TWSGerenteWS;

begin

GerenteWS := TWSGerenteWS.create;

showmessage(GerenteWs.gravarSemParametro);

showmessage(GerenteWS.gravarComParametro(parametro enviado));

end;

end.

Criado 20 de julho de 2009
Respostas 0
Participantes 1