Web Service Architecture

Posts   
 
    
Answer
User
Posts: 363
Joined: 28-Jun-2004
# Posted on: 24-Feb-2005 18:50:01   

Hi Guys,

I have to say i love my llblgen. I have only used it on one project, and i would lke to use it on the next however webservices are a requirement and also the ability to run on compact framework. I paid for it, so i want to use it..heheh

So how do you guys make your webservice layer?

Since we have the awsome template editor now, how hard would it be to create a template that would convert the llblgen into simple objects (i am talking real simple) or better yet, change the internale storage of an entity from a sortedlist into a simple class? I am prolly not making myself real clear on this one...hehe..but i dont know how to explain it. Oh Well

So, should i use datasets for this project, or nhibernate(simple objects), or llblgen?

Kristian
User
Posts: 30
Joined: 24-Feb-2005
# Posted on: 24-Feb-2005 22:16:43   

Hello,

Since you plan on creating a distributed architecure, I would go with the adapter scenario, which splits out the persistence info, from the actual domain entities. Also, the entities are already marked as serializable right out of the box, so you should be good to go.

lyndon_h
User
Posts: 79
Joined: 14-Sep-2004
# Posted on: 25-Feb-2005 00:17:35   

Kristian wrote:

Hello,

Since you plan on creating a distributed architecure, I would go with the adapter scenario, which splits out the persistence info, from the actual domain entities. Also, the entities are already marked as serializable right out of the box, so you should be good to go.

I could be wrong, but i thought that there was a problem with circular dependencies with objects and the ISerializable interface. I think you have to jump through a couple of loops in order to get webservices working with webservices.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 25-Feb-2005 09:42:08   

lyndon_h wrote:

Kristian wrote:

Hello,

Since you plan on creating a distributed architecure, I would go with the adapter scenario, which splits out the persistence info, from the actual domain entities. Also, the entities are already marked as serializable right out of the box, so you should be good to go.

I could be wrong, but i thought that there was a problem with circular dependencies with objects and the ISerializable interface. I think you have to jump through a couple of loops in order to get webservices working with webservices.

Webservices don't use the ISerializable interface, but use the XmlSerializer, which uses the undocumented IXmlSerializable interface, which is only implemented on the dataset.

The xmlserializer is a crappy class, it can't deal with cyclic references as you mentioned, nor can it handle hashtables and interface based types. Furthermore, it thinks that every class which implements IXmlSerializable is a dataset.

The current code is therefore not directly compatible with webservices, as in, an entity is not returnable from a webmethod. You can however return the XmlNode from the webmethod, which is filled by WriteXml() on an entity.

The webservices code in vs.net is also not that clever. If you embed a webreference in your project, vs.net will generate NEW classes for the types returned from the webservice. You don't want that, as you want to use the rich entity objects of the generated code. To make that happen, you have to alter the vs.net generated mock objects (according to MS support), but this is of course not that great, because your changes are not preserved when the stuff has to be regenerated by vs.net.

So, if you have a .NET client and a .NET service, please use remoting. It's build into the code and works flawlessly. If you have a .NET service and a non-.NET client, webservices are your goal, and you then should return as raw xml as you can, so the non-.net client can consume it.

Frans Bouma | Lead developer LLBLGen Pro
freewalker
User
Posts: 6
Joined: 15-Mar-2005
# Posted on: 17-Mar-2005 22:41:20   

Hi, We have web services as connection point to our middle tier for external users/developers. Internaly we use .net remoting. I doubt exposing middle tier / persistence layer entities through web services is good idea first of all, but it is not about this. Our clients want to have access somehow to middle tier API by using web services. What can I do here, so I did this.

Example: how to extend llblgen entity adapter template in order to expose class through web service.

add using

using System.Xml; using System.Xml.Schema; using System.Xml.Serialization;

add IXmlSerializable interface to class definition

public class <[CurrentEntityName]>Entity : EntityBase2, ISerializable, IXmlSerializable

down in template add block like this

region IXMLSerializable implementation

public virtual XmlSchema GetSchema() { return null; }

public virtual void ReadXml( XmlReader reader ) { string s = reader.ReadInnerXml(); this.ReadXml( s ); }

public virtual void WriteXml( XmlWriter writer ) { XmlDocument doc = new XmlDocument(); XmlNode entityNode = null; base.WriteXml(doc,out entityNode); writer.WriteNode(new XmlNodeReader(entityNode),false); }

endregion IXMLSerializable implementation

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 18-Mar-2005 11:45:33   

In 1.0.2004.2 (now in beta), IXmlSerializable is implemented on entities and collections.

Though, in .NET 1.x, IXmlSerializable is not documented as the WSDL tools in vs.net threat every implementing class as a dataset.

Frans Bouma | Lead developer LLBLGen Pro