WSDL response

Vse drugo, kar ne spada v nobeno zgornjo kategorijo.
Odgovori
Stupa
Prispevkov: 44
Pridružen: 20.10.2003 21:17:37

WSDL response

Odgovor Napisal/-a Stupa » 27.01.2014 13:56:34

Živjo!

Imam težave pri uvažanju wsdl datoteke za obdelavo homologacij.
Preko importerja sem kreiral tole kodo.

Koda: Izberi vse

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : https://ws.drsc.gov.si/drsc_ws/Ws_drsc?WSDL
// Encoding : UTF-8
// Version  : 1.0
// (20.1.2014 13:22:27 - 1.33.2.5)
// ************************************************************************ //

unit Ws_drsc;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type
  ElementWrapper       = class;                 { "http://igea.org/" }

  // ************************************************************************ //
  // Namespace : http://igea.org/
  // Serializtn: [xoLiteralParam]
  // ************************************************************************ //
  ElementWrapper = class(TRemotable)
  private
  public
    constructor Create; override;
  published
  end;
  // ************************************************************************ //
  // Namespace : http://igea.org/
  // soapAction: urn:MailTest
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : rpc
  // binding   : MyWebService1SoapHttp
  // service   : Homologacija
  // port      : Ws_drsc
  // URL       : https://ws.drsc.gov.si/drsc_ws/Ws_drsc
  // ************************************************************************ //
  //ArrayOfElementWrapper = array of ElementWrapper;
  MyWebService1 = interface(IInvokable)
  ['{1902994D-1443-9B4B-3902-CE739C452B04}']
    function  shraniHomologacijo(const xml: WideString; const uporabnik: WideString; const geslo: WideString): ElementWrapper; stdcall;
  end;

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

implementation

function GetMyWebService1(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): MyWebService1;
const
  defWSDL = 'https://ws.drsc.gov.si/drsc_ws/Ws_drsc?WSDL';
  defURL  = 'https://ws.drsc.gov.si/drsc_ws/Ws_drsc';
  defSvc  = 'Homologacija';
  defPrt  = 'Ws_drsc';
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 MyWebService1);
    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;


constructor ElementWrapper.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

initialization
  InvRegistry.RegisterInterface(TypeInfo(MyWebService1), 'http://igea.org/', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(MyWebService1), 'urn:MailTest');
  InvRegistry.RegisterInvokeOptions(TypeInfo(MyWebService1), ioLiteral);
  RemClassRegistry.RegisterXSClass(ElementWrapper, 'http://igea.org/', 'ElementWrapper');
  RemClassRegistry.RegisterSerializeOptions(ElementWrapper, [xoLiteralParam]);

end.
Vrniti bi moral response v xml-ju, vendar mi ne gre...

Koda: Izberi vse

procedure TForm4.Button4Click(Sender: TObject);
var res1 : ElementWrapper;
    a : WideString;
begin
    a := '<?xml version="1.0" encoding="UTF-8"?> ... ';    
    res1 := GetMyWebService1().shraniHomologacijo(a,'user','pass');
end;
Ima kdo kakšen predlog kaj je treba spremenit/dodat?

riko
Prispevkov: 444
Pridružen: 25.02.2004 12:40:57

Re: WSDL response

Odgovor Napisal/-a riko » 28.01.2014 09:54:57

Jaz za pošiljanje homologacij uporabljam tole:

Koda: Izberi vse

function WebPostData(const UserAgent: string; const Server: string; const Resource: string; const Data: AnsiString): WideString;
var
  hInet: HINTERNET;
  hHTTP: HINTERNET;
  hReq: HINTERNET;
  BufStream: TMemoryStream;
  BytesRead: Cardinal;
  aBuffer     : Array[0..4096] of Char;
  flags       : DWord;
const
  accept: packed array[0..1] of PChar = (PChar('*/*'), nil);
  header: string = 'Content-Type: text/xml';
begin
  hInet := InternetOpen(PChar(UserAgent), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  try
    hHTTP := InternetConnect(hInet, PChar(Server), INTERNET_DEFAULT_HTTPS_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 1);
    try
      flags := INTERNET_FLAG_SECURE or INTERNET_FLAG_KEEP_CONNECTION;
      hReq := HttpOpenRequest(hHTTP, PChar('POST'), PChar(Resource), nil, nil, @accept, flags, 1);
      try
        if not HttpSendRequest(hReq, PChar(header), length(header), PChar(Data), length(Data)) then begin
          raise Exception.Create('HttpSendRequest failed. ' + SysErrorMessage(GetLastError));
        end else begin
           BufStream := TMemoryStream.Create;
            try
              while InternetReadFile(hReq, @aBuffer, SizeOf(aBuffer), BytesRead) do
              begin
                if (BytesRead = 0) then Break;
                BufStream.Write(aBuffer, BytesRead);
              end;

              aBuffer[0] := #0;
              BufStream.Write(aBuffer, 1);
              Result := PChar(BufStream.Memory);
            finally
              BufStream.Free;
            end;
        end;
      finally
        InternetCloseHandle(hReq);
      end;
    finally
      InternetCloseHandle(hHTTP);
    end;
  finally
    InternetCloseHandle(hInet);
  end;
end;
Pošiljam pa ta takole:

Koda: Izberi vse

    Result := UTF8Decode(WebPostData('Borland SOAP 1.2', 'ws.drsc.gov.si', 'drsc_ws/Ws_drsc', UTF8Encode(soapXml)));

Stupa
Prispevkov: 44
Pridružen: 20.10.2003 21:17:37

Re: WSDL response

Odgovor Napisal/-a Stupa » 28.01.2014 11:12:15

Tole sem tud že gledu, pa mi response čudno izpiše (vprašaji in kitajski znaki)
pošljem pa tole

Koda: Izberi vse

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:igea="http://igea.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <igea:shraniHomologacijo>
         <xml><![CDATA[<?xml version="1.0" encoding="UTF-8"?> ...

riko
Prispevkov: 444
Pridružen: 25.02.2004 12:40:57

Re: WSDL response

Odgovor Napisal/-a riko » 28.01.2014 11:21:51

UTF8Decode rezultata bo verjetno pomagal.
Objavi primer podatkov, ki jih pošlješ po tej varianti, pa bova hitro videla kje je problem.
Podatke, ki jih daš me <XML></XML> moraš zakodirati takole:
v podatkih o vozilu:
& = &#x26;
< nadomestiš z <
> nadomestiš z >


primer:

Koda: Izberi vse

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:igea="http://igea.org/">
<soapenv:Header/>
<soapenv:Body>
<igea:shraniHomologacijo>
<xml><?xml version="1.0" encoding="UTF-8" standalone="no"?><Svezenj xsi:schemaLocation="http://www.dc.gov.si https://ws.drsc.gov.si/drsc_ws/shema/svezenj_A_v1.1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.dc.gov.si"><Glava Referenca="" Verzija="1.0" Datum="2012-04-04T04:04:04" Prejemnik="DRSC" Posiljatelj="testtest" Baza="CRV"/><Vsebina><HOMOLOGACIJA><STEVILKA_POTRDILA>SA6543218</STEVILKA_POTRDILA><VLOZNIK_POOBLASCENEC>testtest</VLOZNIK_POOBLASCENEC><DATUM_IZDAJE>28.01.2014</DATUM_IZDAJE&gt...............</HOMOLOGACIJA></Vsebina></Svezenj></xml>
<uporabnik>uporabnik</uporabnik>
<geslo>geslo</geslo>
</igea:shraniHomologacijo>
</soapenv:Body>
</soapenv:Envelope>
potem ti pa mora delat.

Odgovori