Currently I am building up an external DLL for handling some business logic - we determined the best way to pass data from and to this DLL would be by strings and using XML - this all works fine, but now I want to make it easier to use the DLL by allowing the passage of the actual record which is retrieved with GET()
- currently we do it as follows:
xml.Save(Ktn:Record);
Wrapper.Method(xml.xmlData);
But I want to move the logic of creating the XML into the called procedure of Wrapper
so something like:
Wrapper.Method(Ktn:Record);
But I don’t know what type to use for the declaration of Wrapper.Method
- any idea’s?
I tried using ?
= but that it fails to serialize to XML - it’s just empty
Wrapper.Method(*GROUP pRecord)
Oh, I’ll try that - and guess it’s the same for returning a group?
Okay, this partially fixed it - sadly, now xml.Save(pRecord)
results in the following:
<record>
<group>
<data>
... fields of record
</data>
</group>
</record>
instead of when I use xml.Save(Ktn:Record)
:
<record>
... fields of record
</record>
Any idea how to fix that?
Hi,
If this is xFiles 4? then use @jslarve method above, declare the xml object as
xml xFilesTree
The save as follows
xml.Save(pRecord, 'filename.xml','record','')
In a simple test this gave me the following output
<?xml version="1.0" encoding="UTF-8"?>
<record>
<ID>1</ID>
<STRYESNO>No</STRYESNO>
</record>
I hope that helps
Bruce
May 13, 2023, 4:14am
#6
Yes, i think the key question here, is what class and what code, you are using yo create yhe xml from the record.
Also note that passing the record lije this excludes any memos or blobs - im not sure if thats an issue for you.
The whole procedure looks as follows:
EFinanceAPI.UpdateCustomer PROCEDURE(*GROUP customer)!,BSTRING
xml Class(xFileXML)
END
result BSTRING
CODE
xml.SOAPEnvelope = 1 ! tells xFiles to wrap the XML in a SOAP envelope
xml.SaveEncoding = 'utf-8' ! default is 'ISO-8859-1'
xml._pfileBoundary = '' ! no file boundary tag required by this server
xml._pRecordBoundary = ''
xml.TagCase = XF:CaseAsIs !XF:CaseAsIs !XF:CaseLower !XF:CaseAny !XF:CaseAsIs !XF:CaseLower
xml.SOAPEnvelopeBoundaryAttribute = Clip('xmlns="Company.Domain"')
xml.SOAPEnvelopeBoundary = 'Customer'
xml.SOAPBodyBoundary = ''
xml.RemovePrefix = TRUE
xml.DontReplaceColons = TRUE
xml.Save(customer);
result = External_DLL_UpdateCustomer(SELF.instance, xml.xmlData);
xml.Start();
xml.Load(EFinanceResponse, result);
RETURN xml.xmlData;
Edit: @Mark_Sarson it’s xFiles 3.16
Bruce
May 13, 2023, 4:12pm
#8
At the very least, download the latest build of xFiles 3 - which is 3.27. There’s no reason to be on an old build.
then change the Save line to read;
xml.Save(customer,'','')
BTW: Clarion doesn’t need semi-colons at the end of a line. And you can declare the object as just;
xml xFileXml
If you are using xFiles 4 then the xFileXML
class still exists, but you’re recommended to use the xFilesStream
class instead.
Thanks, changing xml.Save(customer)
to xml.Save(customer, '', '')
did indeed fix it
Any hint on how to return a group/object from the procedure also?
Currently I return the XML string, but I rather return the EFinanceResponse
if possible
Bruce
May 15, 2023, 1:51pm
#10
You can declare a group externally as a TYPE, then use that as a parameter to EFinanceAPI.UpdateCustomer.
as in
EFinanceAPI.UpdateCustomer PROCEDURE(*GROUP customer, *EFinanceResponseType rFinanceResponse )
then
xml.Load(rFinanceResponse , result);
Thank you! But for some reason the xml.Load isn’t loading the data for me - the Structure/Group stays empty - when I try to add the string LENGTH in the xml load as follows:
xml.Load(EFinanceResponse, xmlData, LEN(CLIP(xmlData)));
I get a No Matching prototype available
- probably because my xmlData
is a BSTRING
and not a *STRING
- any solution to that?
Bruce
May 16, 2023, 2:22pm
#12
create a string, copy xmldata into that string, then pass it to the LoadMethod. A StringTheory object would also work.