Jump to content

ertank

Members
  • Content Count

    244
  • Joined

  • Last visited

Everything posted by ertank

  1. Hello, I tried to find solution to my problem in several places already including stackoverflow When consuming a SOAP web service, response to a request comes in fine, but it is not populated in response object in code. I already provided details in above link. Let me know if they really need to be in this post, please. I added all files needed to test my case. I did not provide username and password as they are irrelevant to my problem. Below is an example code to use provided units. uses EFinans.EArsivFatura; procedure TForm1.Button1Click(Sender: TObject); var Input: TFaturaOlusturInput; begin // required before calling any EFinans.EArsivFatura procedure/function EFinans.EArsivFatura.URLEArsivFatura := 'https://earsiv.efinans.com.tr/earsiv/ws/EarsivWebService'; EFinans.EArsivFatura.Username := 'someuser'; EFinans.EArsivFatura.Password := 'somepassword'; // preparing parameters Input.donenBelgeFormati := Ord(TGelenBelgeFormatlari.gePDF); Input.goruntuOlusturulsunMu := 1; // 0=hayır, 1=evet Input.islemId := TGUID.NewGuid.ToString().Substring(1, 36).ToLower(); Input.vkn := '123456789'; Input.sube := '000000'; Input.kasa := '0000'; Input.numaraVerilsinMi := 0; Input.faturaSeri := EmptyStr; Input.sablonAdi := 'einvoice_efinans_15_06_04_3.xslt'; Input.erpKodu := 'ERP1'; Input.gzip := 1; if not EFinans.EArsivFatura.AFaturaOlustur(Input, TGidenBelgeFormatlari.PDF, 'test.zip', 'test.pdf') then begin ShowMessage(EFinans.EArsivFatura.LastError); Exit(); end; end; Above sample code will get you an error response from web service. That response will be saved in "response.xml" file in same directory as your EXE. If you debug and put a break point in line 237 of EFinans.EArsivFatura.pas you should see that Response.return is nil. That is my problem. I have same problem in other methods, too. Just trying to see how I fix this single one now. Thanks & regards, Ertan EarsivWebService1.pas EFinans.EarsivFatura.Utils.pas EFinans.EArsivFatura.pas response.xml test.zip
  2. ertank

    Delphi SOAP response is always nil

    My knowledge, Delphi does not support namespaces in web services. I now believe, response cannot be parsed by Delphi because both request and response contain "namespaces". I sincerely hope both namespace and easy security header support gets introduced in following versions of Delphi. For now, I give up searching for a solution. I will be generating my own request XML by code, and I will be parsing incoming response XML by code using THTTPRIO.OnBeforeExecute() and THTTPRIO.OnAfterExecute() events. Thanks to everyone. Regards, Ertan
  3. ertank

    XML FindNode

    Hello, Using Delphi 10.2.3. I have attached xml file. I would like to find specific node (if it exists) in it and retrieve it's value. My node existence check list is: 1- AdditionalDocumentReference (This is an optional node. Can be more than once in XML. I have to loop through all of them to be sure that node I am searching for exists or not. If no such node exists, searched node is certainly not exists) 2- DocumentType = XSLT (I am seaching DocumentType to be "XSLT". if current node is something else, I need to check other AdditionalDocumentReference nodes if there is any) 3- EmbeddedDocumentBinaryObject (I need Base64 encoded string of that node) My current code is: uses Xml.OmniXmlDom, // <- this is for Omni XML (only available in XE7 and higher!) Xml.XmlDom, // <- add this (important, otherwise the var DefaultDOMVendor isn’t available) Using "Omni XML" as default DOM provider Xml.XmlDoc, Xml.XmlIntf; procedure DisplayInvoice(const Filename: string); var Xml: IXmlDocument; ElementNode: IXMLNode; BaseNode: IXMLNode; ChildNode: IXMLNode; XSLTBase64: string; begin if not TFile.Exists(Filename) then Exit(); Xml := TXMLDocument.Create(Filename); ElementNode := Xml.ChildNodes.FindNode('Invoice'); if ElementNode <> nil then begin BaseNode := ElementNode.ChildNodes.FindNode('cac:AdditionalDocumentReference', 'http://www.w3.org/2001/XMLSchema-instance'); // <--- here BaseNode returns nil if BaseNode <> nil then begin ChildNode := BaseNode.ChildNodes.FindNode('DocumentType'); if ChildNode <> nil then begin if ChildNode.Text.ToUpper = 'XSLT' then begin ChildNode := BaseNode.ChildNodes.FindNode('Attachment'); if ChildNode <> nil then begin ChildNode := ChildNode.ChildNodes.FindNode('EmbeddedDocumentBinaryObject'); if ChildNode <> nil then begin XSLTBase64 := ChildNode.Text; end; end; end; end; end; end; end; Above code does not take into account multiple AdditionalDocumentReference as I failed to have a working code in the first place. I have also tried not to use namespaces when using FindNode and that also failed. Any help is appreciated. Thanks & regards, Ertan ubl-tr.xml
  4. ertank

    XML FindNode

    I found how to use XML namespaces. Suggestion of @ergeka also works. It is possible to have same node name in different namespaces and that may result in a wrong node reading. I needed to match namespace identifier in XMLNode and pass string of that identifier indicated at the beginning of xml file. Thanks. const cac = 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2'; // can be found at the beginning of XML cbc = 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'; // can be found at the beginning of XML function GetXSLTFromXML(const Filename: string): Boolean; var Xml: IXmlDocument; ElementNode: IXMLNode; BaseNode: IXMLNode; ChildNode: IXMLNode; XSLTBase64: string; XSLTBytes: TBytes; begin if not TFile.Exists(Filename) then Exit(False); Xml := TXMLDocument.Create(Filename); ElementNode := Xml.ChildNodes.FindNode('Invoice'); if ElementNode <> nil then begin BaseNode := ElementNode.ChildNodes.FindNode('AdditionalDocumentReference', cac); while BaseNode <> nil do begin ChildNode := BaseNode.ChildNodes.FindNode('DocumentType', cbc); if ChildNode <> nil then begin if ChildNode.Text.ToUpper = 'XSLT' then begin ChildNode := BaseNode.ChildNodes.FindNode('Attachment', cac); if ChildNode <> nil then begin ChildNode := ChildNode.ChildNodes.FindNode('EmbeddedDocumentBinaryObject', cbc); if ChildNode <> nil then begin XSLTBase64 := ChildNode.Text; XSLTBytes := TNetEncoding.Base64.DecodeStringToBytes(XSLTBase64); TFile.WriteAllBytes(TPath.ChangeExtension(Filename, '.xslt'), XSLTBytes); Exit(True); end; end; end; end; BaseNode := BaseNode.NextSibling; end; end; Result := False; end;
  5. ertank

    Delphi SOAP response is always nil

    I did not. I used WSDLImp.exe and unit is what it imported. Code is not formatted.
  6. ertank

    Delphi SOAP response is always nil

    Unfortunately, I do not have REST version of the same web service. Only SOAP. Probably government enforcement. I will see if I can find anyone familiar with C# and web services. I do not have enough knowledge of C# to import and then wrap for importing WSDL from Delphi. Thanks. Ertan
  7. ertank

    Delphi SOAP response is always nil

    SOAP service side is most likely prepared in C#. Not my web service at all. This is an electronic invoice service provider. Company between government and developers.
  8. ertank

    Delphi SOAP response is always nil

    Added more details. Thanks.
×