Problemas no consumo de um web service em C#

Delphi

21/10/2010

Olá   Estou precisando de ajuda para solucionar um problema de consumo de web service desenvolvido em C#. Trabalho com Delphi 2007 e fiz a importação do wsdl e instanciei a classe para ter acesso as funções.   Estou recebendo as informações porém estou tendo dificuldades em enviar informações.     O que acontece, no webservice tem uma função que envia dados chamada (enviadadostohygia) que pede três parametros são eles:   usuario : widestring senha:widestring dsdados:Dsdados     O problema está exatamente no dsdados que é uma classe no wsdl. Dentro do wsdl importado está definida da seguinte forma:     dsDados = class;
  EnviaDadosToHygiaResult = class;
  RecebeDadosFromHygiaResult = class;   dsDados = class(TRemotable)
  private
    Fschema: TXMLData;
  public
    destructor Destroy; override;
  published
    property schema: TXMLData read Fschema write Fschema;
  end;   EnviaDadosToHygiaResult = class(TRemotable)
  private
    Fschema: TXMLData;
  public
    destructor Destroy; override;
  published
    property schema: TXMLData read Fschema write Fschema;
  end;   RecebeDadosFromHygiaResult = class(TRemotable)
  private
    Fschema: TXMLData;
  public
    destructor Destroy; override;
  published
    property schema: TXMLData read Fschema write Fschema;
  end;   Hygia_InterLabSoap = interface(IInvokable)
    ['{28E4B79A-1325-AEFE-B7E2-27F8A48DB266}']
    function EnviaDadosToHygia(const strLaboratorio: WideString; const strSenha: WideString; const dsDados: dsDados): EnviaDadosToHygiaResult; stdcall;
    function RecebeDadosFromHygia(const strLaboratorio: WideString; const strSenha: WideString; const dsDados: dsDados): RecebeDadosFromHygiaResult; stdcall;
  end;
  function GetHygia_InterLabSoap(UseWSDL: Boolean=System.False; Addr: String=''; HTTPRIO: THTTPRIO = nil) : Hygia_InterLabSoap; implementation
  uses SysUtils; function GetHygia_InterLabSoap(UseWSDL: Boolean=System.False; Addr: String=''; HTTPRIO: THTTPRIO = nil) : Hygia_InterLabSoap;
const
  defWSDL = 'http://interlab.techne.com.br/Interface.asmx?WSDL';
  defURL  = 'http://interlab.techne.com.br/Interface.amsx';   defSvc = 'Hygia_Interlab';
  defPrt = 'Hygia_InterlabSoap'; 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 Hygia_InterLabSoap);     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 dsDados.Destroy;
begin
  FreeAndNil(Fschema);
  inherited Destroy;
end; destructor EnviaDadosToHygiaResult.Destroy;
begin
  FreeAndNil(Fschema);
  inherited Destroy;
end; destructor RecebeDadosFromHygiaResult.Destroy;
begin
  FreeAndNil(Fschema);
  inherited Destroy;
end; initialization
  InvRegistry.RegisterInterface(TypeInfo(Hygia_InterLabSoap),'http://techne.com.br/webservices/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Hygia_InterLabSoap), 'http://techne.com.br/webservices/%operationName%');
  InvRegistry.RegisterInvokeOptions(TypeInfo(Hygia_InterLabSoap), ioDocument);
  RemClassRegistry.RegisterXSClass(dsDados, 'http://techne.com.br/webservices/', 'dsDados');
  RemClassRegistry.RegisterXSClass(EnviaDadosToHygiaResult, 'http://techne.com.br/webservices/', 'EnviaDadosToHygiaResult');
  RemClassRegistry.RegisterXSClass(RecebeDadosFromHygiaResult, 'http://techne.com.br/webservices/', 'RecebeDadosFromHygiaResult');   RemClassRegistry.RegisterSerializeOptions(EnviaDadosToHygiaResult,[xoHolderClass,xoLiteralParam]);
  O que preciso fazer é gerar um xml, o que já estou gerando e enviar através deste parametro. Alguem tem ideia de como posso fazer isso?   Obrigado Marcos
Marcos Naves

Marcos Naves

Curtidas 0

Respostas

Jorge Andrade

Jorge Andrade

21/10/2010

Olá,

Voce conseguiu resolver este problema?
GOSTEI 0
POSTAR