PAGUE 6 MESES
LEVE 12 MESES
GARANTIR DESCONTO

Fórum Dificuldade pra envio de arquivo XML simples para um WebService #410615

15/12/2011

0

Estou com dificuldades em fazer o envio de um xml pra um web service , tenho que enviar o xml de retorno da receita pro web service mas na hora de carregar o arquivo o retorno do web service da que o não é um xml.
Utilizei o WSDL importer do delphi 7

segue codigo fonte se alguem puder me auxiliar.

arquivo aakonline.pas
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://portaldealerasp.t-systems.com.br/aakonline/aakonline.asmx?wsdl
// Encoding : utf-8
// Codegen : [wfDebug,wfOutputLiteralTypes,wfUseSerializerClassForAttrs]
// Version : 1.0
// (13/12/2011 16:26:29 - 1.33.2.5)
// ************************************************************************ //

unit aakonline;

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


NFe = type WideString; { http://portaldealerasp.t-systems.com.br/aakonline/aakonline }
EnviaXMLResult = type WideString; { http://portaldealerasp.t-systems.com.br/aakonline/aakonline }

// ************************************************************************ //
// Namespace : http://portaldealerasp.t-systems.com.br/aakonline/aakonline
// soapAction: http://portaldealerasp.t-systems.com.br/aakonline/aakonline/EnviaXML
// transport : http://schemas.xmlsoap.org/soap/http
// binding : AAKOnLineSoap
// service : AAKOnLine
// port : AAKOnLineSoap
// URL : http://portaldealerasp.t-systems.com.br/aakonline/aakonline.asmx
// ************************************************************************ //
AAKOnLineSoap = interface(IInvokable)
[{9651C8A8-8D29-3313-BCDE-497C079231E6}]
function EnviaXML(const NFe: NFe): EnviaXMLResult; stdcall;
end;

function GetAAKOnLineSoap(UseWSDL: Boolean=System.False; Addr: string=; HTTPRIO: THTTPRIO = nil): AAKOnLineSoap;


implementation

function GetAAKOnLineSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): AAKOnLineSoap;
const
defWSDL = http://portaldealerasp.t-systems.com.br/aakonline/aakonline.asmx?wsdl;
defURL = http://portaldealerasp.t-systems.com.br/aakonline/aakonline.asmx;
defSvc = AAKOnLine;
defPrt = AAKOnLineSoap;
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 AAKOnLineSoap);
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(AAKOnLineSoap), http://portaldealerasp.t-systems.com.br/aakonline/aakonline, utf-8);
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(AAKOnLineSoap), http://portaldealerasp.t-systems.com.br/aakonline/aakonline/EnviaXML);
RemClassRegistry.RegisterXSInfo(TypeInfo(NFe), http://portaldealerasp.t-systems.com.br/aakonline/aakonline, NFe);
RemClassRegistry.RegisterXSInfo(TypeInfo(EnviaXMLResult), http://portaldealerasp.t-systems.com.br/aakonline/aakonline, EnviaXMLResult);

end.

arquivo de envio pro webservice unt1.pas.
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, aakonline, StdCtrls, InvokeRegistry, Rio, SOAPHTTPClient,
SOAPDomConv, OPToSOAPDomConv, WSDLIntf, SOAPPasInv, SOAPHTTPPasInv, XmlIntf, XMLDoc;

type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
OpenDialog1: TOpenDialog;
Button2: TButton;
HTTPRIO: THTTPRIO;
HTTPSoapPascalInvoker1: THTTPSoapPascalInvoker;
Memo: TMemo;
Button3: TButton;
Memo4: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Envia: AAKOnLineSoap;
dados: WideString;
retorno: string;
XMLDoc: TXMLDocument;

begin
retorno := Edit1.Text;
//------------------------
//XMLDoc := TXMLDocument.Create(self);
//XMLDoc.LoadFromFile(EnviNFe.xml);

Envia := HTTPRIO as AAKOnLineSoap;
Envia := GetAAKOnLineSoap();
//dados := Envia.EnviaXML(XMLDoc.XML.Text);
dados := Envia.EnviaXML(retorno);

ShowMessage(dados);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenDialog1.Execute then
Edit1.Text := OpenDialog1.FileName;
//ShowMessage(Edit1.Text);
end;
end.


Tentei fazer o envio do arquivo e da String do arquivo como comentario no fonto acima mas nas duas formas retornou o mesmo errro.

arquivo do projeto.
program Project1;

uses
Forms,
Unit1 in Unit1.pas ,
aakonline in aakonline.pas;

{$R *.res}

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.


Grato se alguem puder me dar um auxilio.
Denilson Andrade

Denilson Andrade

Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar