Jump to content
Fórum Script Brasil
  • 0

WebService


Recife

Question

Bom dia Pessoal,

Estou com um problema em consumir webservice feito em delphi por uma aplicação tmb em delphi. Foi criado um webservice, em que consigo visualizar a WebService - Service Info Page, do mesmo.

Criei uma aplicação cliente que utiliza este webservice para acessar as funções e me retornar o valor solicitado. Porém, toda vez que chega na chamada do método da problema de acess violantion. Abaixo, coloco o código utilizado:

procedure TFExemplo.BitBtn1Click(Sender: TObject);
var Servico: IOperacoes;
    valor1, valor2: Currency;
begin
  Servico    := HTTPRIO1 as IOperacoes;

  valor1     := StrToCurr(Edit1.Text);
  valor2     := StrToCurr(Edit2.Text);
  Edit3.Text :=  CurrToStr(Servico.Somar(valor1,valor2));  [b]<---- aqui que esta dando o acess violantion[/b]
end;

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0
CurrToStr(Servico.Somar(valor1,valor2));

veja a função somar

abraço

Jhonas boa tarde,

é como se não existisse as funções que são as quatro operações, onde passo dois parâmetros e no lado server realiza o calculo. já tentei de varias formas mais não consigo ter retorno devido ao access violation.

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : http://localhost:8081/WebService.coServico/wsdl/IOperacoes
// Encoding : utf-8
// Version  : 1.0
// (03/01/2012 11:22:27 - 1.33.2.5)
// ************************************************************************ //

unit IOperacoes1;

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.
  // ************************************************************************ //
  // !:double          - "http://www.w3.org/2001/XMLSchema"


  // ************************************************************************ //
  // Namespace : urn:OperacoesIntf-IOperacoes
  // soapAction: urn:OperacoesIntf-IOperacoes#%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : rpc
  // binding   : IOperacoesbinding
  // service   : IOperacoesservice
  // port      : IOperacoesPort
  // URL       : http://localhost:8081/WebService.coServico/soap/IOperacoes
  // ************************************************************************ //
  IOperacoes = interface(IInvokable)
  ['{CC60E911-02EC-E7B1-52F5-0BE69C35D74A}']
    function  Somar(const x: Double; const y: Double): Double; stdcall;
    function  Subtrair(const x: Double; const y: Double): Double; stdcall;
    function  Mutiplicar(const x: Double; const y: Double): Double; stdcall;
    function  Dividir(const x: Double; const y: Double): Double; stdcall;
  end;

function GetIOperacoes(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): IOperacoes;

implementation

function GetIOperacoes(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IOperacoes;
const
  defWSDL = 'http://localhost:8081/WebService.coServico/wsdl/IOperacoes';
  defURL  = 'http://localhost:8081/WebService.coServico/soap/IOperacoes';
  defSvc  = 'IOperacoesservice';
  defPrt  = 'IOperacoesPort';
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 IOperacoes);
    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(IOperacoes), 'urn:OperacoesIntf-IOperacoes', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IOperacoes), 'urn:OperacoesIntf-IOperacoes#%operationName%');
end.

Este endereço "http://localhost:8081/WebService.coServico/wsdl/IOperacoes" consigo visualizar no webbrowser.

Edited by Recife
Link to comment
Share on other sites

  • 0

Rapaz,

Olhei o link que você indicou e o que fiz esta semelhante ao artigo. Mais não acessa, ou seja sempre esta dando erro de access violation. No momento de acessar a função somar da o erro citado.

Edited by Recife
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...