Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
10
Erster Beitrag:
vor 4 Jahren, 7 Monaten
Letzter Beitrag:
vor 4 Jahren, 6 Monaten
Beteiligte Autoren:
Danny Lauwers, Peter Holemans, Fabrice Harari

[WD18] Return class from Webservice ?

Startbeitrag von Danny Lauwers am 28.06.2013 23:55

Hello,

I am testing some stuff to build a 3-tier application. The Webservice is accessing the Hyperfile DB and retrieves the data in a Recordclass (OOP).

I have a global function GetData


PROCEDURE GetData()
clLst is CMyTestList
clLst.FetchData()

RESULT clLst.arrRec


It should return some data, but instead it gives me an error in the browser to test the webservice (tried other tools also)



---SOAP-ENV:ServerThe conversion from 'empty' to XML is not supported.What happened? The conversion from 'empty' to XML is not supported. Error code: 40071 Level: fatal error (EL_FATAL) Dump of the error of 'wd180xml.dll' module (18.0.48.0). Additional Information: EIT_XINFO :



Any idea what could be wrong ?

When I return a string or a structure itself, it works. Could it be that some fields are empty, NULL ?

In a Test Window I can see that the data look good in a table when I use the Recordclasses.

Hope you can help me, to work around this !
If it is member variable that is NULL, how would I solve this ?

Thanks
Danny

Antworten:

Hi Danny

If I understand correctly, you are counting on the automatic conversion of the webservice system to do everything for you. And it looks like you are in the a case that is not supported.

I haven't tested myself, but this is what I would do to test and find exactly what's happening:
- remove all the REAL class stuff
- replace it with a hardcoded system that will send:
- first a string
- then an empty string
- then a variable set to null
- then whatever it is you are sending from the class (an array, maybe) fully filled
- then the same thing with empty spots
- then the same thing with nulls

This will tell you exactly what is NOT supported. Once you know that, you'll be able to devise a strategy around the problem

Best regards

von Fabrice Harari - am 29.06.2013 14:24
Hi,

I have tested some more and currently the problem occures when in the class I have a protected member of type PROCEDURE.

I have tried to set it to Private, but that does not help.

Any way in hiding this variable that it wil not send from the webservice ?
I would only like to send the public members, is this posible ?

Thanks
Will test some more...
Danny

von Danny Lauwers - am 01.07.2013 20:56
Hi Danny,

You can serialise the class instance yourself (only members you want to pass back).
This can be done with getting the 'Definition' of the class.
Check the online help on the Definition variable type and the GetDefinition() function.

Just my 2 cents...

Cheers,

Peter H.

von Peter Holemans - am 03.07.2013 14:28
Hi,

I was looking for a 10x faster solution :rp: so I would hate to serialize all class fields (data) by hand that needs to go to all the other programs (WebDev, Android, .NET) via webservices.
If I can pass a structure, the other side of the development (GUI Side) can use this structure without first processing the raw XML data making it far more flexible and programmer friendly.

Maybe I can create a struct inside the class that contains all the database fields and in the class make a variable or array of this structure type, this way I could always return the pure data of the class and not all the releated member variables that are in the class for other purposes.

This way I could build 1 class "CCustomers" with a ST_DBFields structure and use this class for all the single instance data or array data that I need of the Customers.
Now I have 2 classes, a CCustomerRec and a CCustomerRecList.

Another Idea would be to use a class instead of a structure. This class would have only the DB fields and no other variables. This Class could then be generated via the Model from the HyperFile C/S Analysis File. Add a field in the analysis, Model is updated, Class is updated. Maybe this would work even better ??

Any insights ;) of the WXDev guru's if this would be a good Class solution to build a backoffice (webservice) part in WinDev ?

Any other tips I could use when starting my 3 Tier Project ? WebDev, Android, .NET application would communicate via this WebService to the database. All Business logic would be in the Service Tier, and only the GUI releated stuff would be in the different frontends.

Thanks, for your feedback !
Danny

von Danny Lauwers - am 05.07.2013 07:10
Hi Danny,

You can serialize the calss instance in one line of code and deserialize it again in one line of code so that seems fast enough, no?

Below is an idea I wrote out of my head. Not tested though, but it should give you an idea on how to proceed...

E.g.:

-- SERIALISATION CLASS DEFINTIONS
oSerialize is class
PUBLIC
SerializedInstance is buffer
PROTECTED
PRIVATE
END
PROCEDURE SerializeMyself()
Serialize(object, :SerializedInstance , psdXML)
PROCEDURE DeserializeMyself()
Deserialize(object, :SerializedInstance , psdXML)

-- BUSINESS CLASS DEFINTION
oCustomer is class
inherits oSerialize
PUBLIC
memberX is int
memberY is int
memberZ is int
PROTECTED
PRIVATE
END
PROCEDURE SeriliazeMyself()
Ancestor:SerializeMyself()
PROCEDURE DeseriliazeMyself()
Ancestor:DeserializeMyself()


-- IN CODE USAGE
Cust is oCustomer
Cust:memberX = 1
Cust:memberY = 2
Cust:memberZ = 3

--Serialize
Cust:Serialize()
trace("XML DATA:"+CR+Cust:SerializedInstance)

--Deserialize
Cust is oCustomer
Cust:SerializedInstance = floadfile("myXMLSerializedfile.xml")
Cust:Deserialize()
trace(Cust:memberX, Cust:memberY, Cust:memberZ)


As said before, this is non tested code, rather a conceptual idea on how to implement this in a reusable fashion.

Just my 2 cents,

Peter H.

von Peter Holemans - am 07.07.2013 10:43
Hi Danny,

Rereading your message, if you want to pass an instance as such without serialisation you have to use the keyword 'object' to pass 'self'...

See e.g. the 'object' keyword in the previous example to serialise/deserialise 'self' into an xml file.

Cheers,

Peter

von Peter Holemans - am 07.07.2013 10:48
Hi Peter,

Thanks for your concept code, I will have a look at it and see if it would help me.

But using the serialize command, I end up sending pure XML to the other clients (not all WxDev) and forces those clients to process the XML instead of directly use the structures the webservice sends.

I'll have to experiment with this a bit further to see what best matches my needs, keeping your ideas in mint.

Thanks again for the tips !
Danny

von Danny Lauwers - am 08.07.2013 07:14
Hi Danny,

Webservices communicate by design via xml. Otherwise we're talking about rpc or dcom or alike...

Just my 2 cents,

Peter H.

von Peter Holemans - am 09.07.2013 12:18
Peter,

Yes, that is correct. But is you send a structure back, the WSDL file (description of the Webservice) will have that type of structure defined as a type. So your program can use the structure type to get what everthe structure holds directly in that variable to work with, this is very very convinient.

If you send a structure as XML string, the WSDL will contain no definition of the structure send, and only will contain that your parameter is of type string.
This XML string will than have te be converted to the structure variable to easily access the data.
This is, as far as I know, code you have to write.

Danny

von Danny Lauwers - am 10.07.2013 11:14
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.