Forum:  LLBLGen Pro Runtime Framework

Thread:  WebServices working!


Answer (User)   Posted on: 17-Oct-2005 21:17:56.
Frans,

I have sucessfully gotten the wsdl.exe in .NET 2.0 to generate the correct proxy using LLBLGen entities. I was wondering if you could include the code in this release since its pretty simple.

First off, you need two attributes above each entity that you want serializable. Actually i dont believe XMLRoot is needed, but i used it on mine and it worked, so i would prolly put it in there.

Code:

[XmlSchemaProvider("GetEntitySchema")]
[XmlRoot("CatalogEntity", Namespace = "http://yournamespace", IsNullable = true)]


Next you need to implement the static method GetEntitySchema.

Code:

const string NS = "http://yournamespace/xml/serialization";

public static XmlQualifiedName CatalogSchema(XmlSchemaSet xss)
{
XmlSchema xs = XmlSchema.Read(new StringReader(
"<xs:schema id='CatalogSchema' targetNamespace='" + NS +
"' elementFormDefault='qualified' xmlns='" + NS + "' xmlns:mstns='" +
NS + "' xmlns:xs='http://www.w3.org/2001/XMLSchema'><xs:complexType " +
"name='CatalogEntity'></xs:complexType></xs:schema>"), null);
xss.XmlResolver = new XmlUrlResolver();
xss.Add(xs);
return new XmlQualifiedName("CatalogEntity", NS);
}


Now i relealize this isnt a correct schema, but it does want i need it to do and seems to work perfectly. Now, this needs to be implemented on every entity that implements IXmlSerializable. In the code i past above, its from a generated CatalogEntity. The Attribute and GetEntitySchema is required becuase it gives the wsdl the name and namespace of the object. So when its generating its proxy it passes the name "CatalogEntity" with the namespace of "http://yournamespace/xml/serialization" to the schemaimportextension. If the attribute and GetEntitySchema function is missing the wsdl just assumes its a dataset, and never passes the info to the schemaimport extension so you dont get a chance to modify the return type for the client proxy.

Here is a SchemaImportExtension i created to replace client proxy generated junk with rich llblgen entities Regular Smiley This could easily be made into a llbgen template and it generated at the time of creating the entities but ill be happy if youjust include the attributes and schema function Regular Smiley Creating the schemaimport extension is a whole another ball game, so i just included this so you could better see whats going on.

Code:

public class SchemaImporter : SchemaImporterExtension {

static SchemaImporter()
        {
        }

        public override string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider)
{
     return null;
}

public override string ImportSchemaType(string name, string ns, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer, CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider)
{

if (ns.Equals("http://yournamespace/xml/serialization"))
{
switch (name)
{
case "CatalogEntity":
{
compileUnit.ReferencedAssemblies.Add("yourassemblywhichcontainsllblgenentities.dll");
mainNamespace.Imports.Add(new CodeNamespaceImport ("yournamespace.EntityClasses"));
return "CatalogEntity";
}
}
}
}
}



I hope i made this as clear as possible, but it seems to work beautifully and i have been passing lllbgen entities across web services all morning and its nice not having to manually edit the proxy every time its regenerated Regular Smiley

Im guessing this will take no longer then 30 minutes to add to the templates. I amnot familar with llblgen template editing yet, so i wanted to see if this is something you could add since im sure other will use this too.


Otis (LLBLGen Pro Team)   Posted on: 17-Oct-2005 22:36:21.
Great stuff! I'll try to merge the stuff tomorrow (tuesday) !! Regular Smiley

Answer (User)   Posted on: 18-Oct-2005 00:07:19.
WonderFul!

I made a small mistake on teh code i pasted, the attribute has teh function name "GetEntitySchema" , the function code i pasted has the name "CatalogSchema", change it to GetEntitySchema Regular Smiley


Also, is it possible for you to create a template to generate the SchemaImporterExtension. All you have to do is take the code i pasted above, and for every entity that is generated add a case statement for it, and of course add case statements for EntityCollection and any other entity that implements IXmlSerializable. This would make doing web services ALMOST effortless Tongue

I am pretty sure i created a template to do this a while back when i first tried getting this to work but i seem to have lost it in a reformat. Angry

Otis (LLBLGen Pro Team)   Posted on: 18-Oct-2005 08:53:20.
That schema extension class, where is it located? In the same assembly as the generated code?

Marcus (User)   Posted on: 18-Oct-2005 12:54:33.
Wow this is a great addition!! Laugh
Answer (User)   Posted on: 18-Oct-2005 17:26:46.
The SchemaImportExtension can go anywhere really. In order for it to work though, you have to takea couple steps...

1.) Compile it into a library.
(You could add it the generic adapter portion for instance, or any other class library project really. I created a seperate class library project with just the extension in it. But theres no reason really you couldnt add it to the generic adapter portion.)
2.) Sign the assembly
3.) Install the library into the GAC (from cmd.exe gacutil -i assemblyname.dll)
4.) Modify the machine.config to include the extension.

To be honest, its a pain in the butt, but it sure beats modifying the proxy every time its regenerated.

Example setting to add to the machine.config

Code:

    <system.xml.serialization>
        <schemaImporterExtensions>
            <add name="SchemaImporter" type="yournamespace.SchemaImporter, assemblyname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=051e40d08c44d2e0" />
        </schemaImporterExtensions>
    </system.xml.serialization>


Now, its kinda finiky. So after you install the assembly into the GAC or modify the machine.config make sure you close VS.NET 2005 and restart it. I also was unable to get it to work if i didnt specify the PublicKeyToken in the machine.config. You can use the commands below to create a key file and get the PublicKeyToken for your assembly.

sn -k sn1.snk
Generates and stores the key pair in the file 'sn1.snk'.

sn -p sn1.snk snpub1.snk
Extracts the public key from the key pair file 'snk1.snk' and stores the public key in the file 'snpub1.snk'.

sn -t snpub1.snk
Generates the Public Key Token from the Public Key.


SchemaImportExtension MSDN page
http://msdn2.microsoft.com/en-us/library/ms163210(en-us,vs.80).aspx

Hope this is helps. I suppose i could write a small tutorial on the steps to do it specifically if needed.

Ryan


Otis (LLBLGen Pro Team)   Posted on: 18-Oct-2005 17:54:39.
Thanks! Regular Smiley

I think I'll add the necessary code to the entities/runtime libs and will provide a template / tutorial for the extension class, as it really should be in its own assembly, as you said.

It could be I generate the class in the dbgeneric project so the user can just copy the class and create a separate assembly.

I hope to have it done by today, though I think it will be tomorrow. (although adding it all is not that big I think Regular Smiley). I still have an hour to go before I pack the new beta.
Answer (User)   Posted on: 18-Oct-2005 22:52:34.
Ok, i have found one problem so far...
And i have no idea on how to fix this. But for some reason when using WSE 3.0 , it converts all < characters to &lt; and all > characters to &gt;

POCO objects go through wse 3.0 just fine. I suspect that becuase the object doesnt have a true schema being returned, that something along with way thinks its a string and encodes the string.
So im working on actually returning a valid schema. See if that fixes it.






Otis (LLBLGen Pro Team)   Posted on: 19-Oct-2005 15:49:05.
Is there a way to specify the schemaimporter assembly in the web.config of the service? It's of course not workable to have the extension added to the machine.config.
Otis (LLBLGen Pro Team)   Posted on: 19-Oct-2005 16:23:12.
Ok got it working! Regular Smiley

I'll now see if I can use the attribute on EntityBase2

(edit) That doesn't seem to work, you have to have the attribute on the class you want to return.

Hmm. Well, I'll generate one file into the EntityClasses namespace, with partial classes for every entity with the attribute and the GetEntitySchema method. As it's a static method, I can't use a generic piece of code in the base class.

I'll then document how to create the schemaimporter and how to enable it. THough I think, the altering of machine.config is pretty bad, even though you only need it during development...



Otis (LLBLGen Pro Team)   Posted on: 19-Oct-2005 17:14:29.
It is however a lot of work to get this documented in full, and to get the stuff generated properly, as the schemaimporter has to be separated, and users have to be guided what to do. I also don't know if the schema is correct...

I'll postpone it till .NET 2.0 RTM is available on November 7th, where the .NET 2.0 runtime libs have to be re-released anyway. I've lost a lot of time this afternoon by searching for docs of beta2 classes which weren't there.

For teh people interested, you can generate an XmlWebservicesHelper class with the following structure:

Code:

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

namespace <[Rootnamespace]>.EntityClasses
{
<[Foreach Entity]>
    [XmlSchemaProvider("GetEntitySchema")]
    public partial class <[CurrentEntityName]>Entity
    {
        /// <summary>
        /// Method which provides a schema for IXmlSerializable implementation so no proxies are generated.
        /// </summary>
        /// <param name="schemaSet">schema set which is the current schema for the type to produce</param>
        /// <returns></returns>
        public <[If IsSubtype]>new<[EndIf]> static XmlQualifiedName GetEntitySchema(XmlSchemaSet schemaSet)
        {
            string entityNamespace = "http://<[RootNamespace]>/xml/serialization";
            XmlSchema xs = XmlSchema.Read(
                new StringReader(
                    string.Format("<xs:schema id='<[CurrentEntityName]>EntitySchema' targetNamespace='{0}' elementFormDefault='qualified' xmlns='{0}' xmlns:mstns='{0}' xmlns:xs='http://www.w3.org/2001/XMLSchema'><xs:complexType name='<[CurrentEntityName]>Entity'></xs:complexType></xs:schema>",
                        entityNamespace)), null);
            schemaSet.XmlResolver = new XmlUrlResolver();
            schemaSet.Add(xs);
            return new XmlQualifiedName("<[CurrentEntityName]>Entity", entityNamespace);
        }
    }
<[NextForeach]>
}

namespace <[RootNamespace]>.HelperClasses
{
    [XmlSchemaProvider("GetEntityCollectionSchema")]
    public partial class EntityCollection
    {
        /// <summary>
        /// Method which provides a schema for IXmlSerializable implementation so no proxies are generated.
        /// </summary>
        /// <param name="schemaSet">schema set which is the current schema for the type to produce</param>
        /// <returns></returns>
        public static XmlQualifiedName GetEntityCollectionSchema(XmlSchemaSet schemaSet)
        {
            string entityNamespace = "http://<[RootNamespace]>/xml/serialization";
            XmlSchema xs = XmlSchema.Read(
                new StringReader(
                    string.Format("<xs:schema id='EntityCollectionSchema' targetNamespace='{0}' elementFormDefault='qualified' xmlns='{0}' xmlns:mstns='{0}' xmlns:xs='http://www.w3.org/2001/XMLSchema'><xs:complexType name='EntityCollection'></xs:complexType></xs:schema>",
                        entityNamespace)), null);
            schemaSet.XmlResolver = new XmlUrlResolver();
            schemaSet.Add(xs);
            return new XmlQualifiedName("EntityCollection", entityNamespace);
        }
    }
}


For the schema importer:
Code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Xml.Serialization.Advanced;

namespace SchemaImporter<[RootNamespace]>
{
    public class SchemaImporter : SchemaImporterExtension
    {
        static SchemaImporter()
        {
        }

        public override string ImportSchemaType(XmlSchemaType type, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer,
                CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider)
        {
            return null;
        }

        public override string ImportSchemaType(string name, string ns, XmlSchemaObject context, XmlSchemas schemas, XmlSchemaImporter importer,
            CodeCompileUnit compileUnit, CodeNamespace mainNamespace, CodeGenerationOptions options, CodeDomProvider codeProvider)
        {
            if (ns.Equals("http://<[RootNamespace]>/xml/serialization"))
            {
                switch (name)
                {
<[Foreach Entity]>
                    case "<[CurrentEntityName]>Entity":
                    {
                        compileUnit.ReferencedAssemblies.Add("<[RootNamespace]>.dll");
                        mainNamespace.Imports.Add(new CodeNamespaceImport("<[RootNamespace]>.EntityClasses"));
                        return "<[CurrentEntityName]>Entity";
                    }<[NextForeach]>
                    case "EntityCollection":
                    {
                        compileUnit.ReferencedAssemblies.Add("<[RootNamespace]>.dll");
                        mainNamespace.Imports.Add(new CodeNamespaceImport("<[RootNamespace]>.HelperClasses"));
                        return "EntityCollection";
                    }
                }
            }

            return null;
        }
    }
}
Answer (User)   Posted on: 19-Oct-2005 17:21:57.
Quote:
Is there a way to specify the schemaimporter assembly in the web.config of the service? It's of course not workable to have the extension added to the machine.config.


I know why they chooose the machin.config but i cant figure out why the also didnt have it look in the web.config.


Yes, each entity must have the function and attribute.

As far as the schema importer, just generating the class is enough.

im still working on the schema.


Otis (LLBLGen Pro Team)   Posted on: 19-Oct-2005 18:00:59.
Answer wrote:
Quote:
Is there a way to specify the schemaimporter assembly in the web.config of the service? It's of course not workable to have the extension added to the machine.config.


I know why they chooose the machin.config but i cant figure out why the also didnt have it look in the web.config.

After a while it made sense though: the service is on the server, the wsdl.exe is not on the server, so the schemaimporter should be on the client, not on the server Laugh. Prettly logical, but without any documentation it's pretty hard (you must have had a really hard time figuring this all out) to figure it all out...

Quote:

Yes, each entity must have the function and attribute.
As far as the schema importer, just generating the class is enough.
im still working on the schema.

I've provided teh templates (from my bare head, some syntax issues here and there might need correction) above. I'll postpone the full docs of this and the inclusion of templates for this till .NET 2.0 is released, as it will take me at least half a day to add it all, test it in vb.net and c# etc., and I don't have that time now (as the deadline is friday evening, so 1.0.2005.1 can be released on sunday)

Keep up the good work, I'll include it a.s.a.p. after the release into the final code (it can be done solely by templates so that's a good thing Regular Smiley) and docs.Regular Smiley
Answer (User)   Posted on: 19-Oct-2005 19:04:02.
Yeah, i ahve spent a TON of time working on this. I couldnt get it to work the first day or two and i got frustrated with the serious lack of documentation so i started my project using NHibernate. For some reason i decided to give it another try, and i got it work in like a half hour. GO figure!

Ok, the schema doesnt matter! When using regular web services they work beautifully. When using WSE 3.0 it encodes the xml for some reason. Now i figured out that its something to do with the writer.writeraw(string xml) function that use you to create the xml for the entities.


If i implment IXmlSerializable myself on the entity (not entitybase2) and use
Code:

void IXmlSerializable.WriteXml(XmlWriter writer)
{
writer.WriteRaw("<name>Ryan</name>");
}


The WSE trace file looks liek this. As you can see its encoding the < and > characters.

Code:

<GetAddressEntitiesResponse xmlns="http://namespace.com/xml/serialization">
<GetAddressEntitiesResult>&lt;name&gt;Ryan&lt;/name&gt;</GetAddressEntitiesResult>
</GetAddressEntitiesResponse>


Now if change IXmlSerializable to this

Code:

void IXmlSerializable.WriteXml(XmlWriter writer)
{
writer.WriteElementString("name", "Ryan");
}


The wse trace looks liek this. As you can see its NOT encoding it.

Code:

<GetAddressEntitiesResponse xmlns="http://namespace.com/xml/serialization">
<GetAddressEntitiesResult>
<name>Ryan</name>
</GetAddressEntitiesResult>
</GetAddressEntitiesResponse>



im guessing this is a bug in WSE?


Otis (LLBLGen Pro Team)   Posted on: 19-Oct-2005 20:06:29.
that's really strange... because IXmlSerializable should just dump the xml into the writer, though, I do that, I don't create <name> strings as tags, so that's even more strange...

Also, I don't know of WSE is out of beta (I don't know anything about WSE actually Wink)
Answer (User)   Posted on: 19-Oct-2005 20:44:24.
SOLVED!

ok, two options. Either modify the IXmlSerializable.WriteXml method on Entitybase2...etc OR implement IXmlSerializable on every generated entity. Obvisouly the easiest way is to modify teh base classes.

to

Code:

        public virtual void WriteXml(XmlWriter writer)
        {
            string xmlOutput = string.Empty;
            WriteXml(XmlFormatAspect.Compact | XmlFormatAspect.MLTextInCDataBlocks | XmlFormatAspect.DatesInXmlDataType, out xmlOutput);
             XmlReader reader = XmlReader.Create(new StringReader(xmlOutput));
writer.WriteNode(reader, true);
        }


by using WriteNode it works over both standard web services and WSE. When you use writeraw() it does no checking and apparently in the WSE it treats it like a string and html encodes it. By using writenode it performs as expected!

Btw...this is all new to me. I've never used web services before nor WSE.

Waiting till nov 7+ isnt going to help me Angry
Can you include the code but just neglect the docs until later?




Answer (User)   Posted on: 19-Oct-2005 23:50:27.
Well ive taken the liberty to actually attempt and learn your generator. I had the hardest time with all the tasks etc...

but i managed to get it!

So i've created a template set for web services.

I guess just post here with your email if your interested.


Just a note, but until frans modifies the EntityBase2 class, passing a EntityBase2 object across a web service using WSE wont work. So if you plan on using WSE make sure you use the entity name, ie CatalogEntity.


Otis (LLBLGen Pro Team)   Posted on: 20-Oct-2005 08:34:16.
Answer wrote:
SOLVED!

ok, two options. Either modify the IXmlSerializable.WriteXml method on Entitybase2...etc OR implement IXmlSerializable on every generated entity. Obvisouly the easiest way is to modify teh base classes.

to

Code:

        public virtual void WriteXml(XmlWriter writer)
        {
            string xmlOutput = string.Empty;
            WriteXml(XmlFormatAspect.Compact | XmlFormatAspect.MLTextInCDataBlocks | XmlFormatAspect.DatesInXmlDataType, out xmlOutput);
             XmlReader reader = XmlReader.Create(new StringReader(xmlOutput));
writer.WriteNode(reader, true);
        }


by using WriteNode it works over both standard web services and WSE. When you use writeraw() it does no checking and apparently in the WSE it treats it like a string and html encodes it. By using writenode it performs as expected!

Btw...this is all new to me. I've never used web services before nor WSE.

Waiting till nov 7+ isnt going to help me Angry
Can you include the code but just neglect the docs until later?

Sure, as long as it works over standard webservices as well, but it does as you said Regular Smiley

I'll eventually create a conditional compile for 2.0, that's no problem.

The writeraw was a fix for an issue where 2 or more entities passed to or returned from a webmethod gave invalid xml.

Could elaborate a bit, if time permits, what was so hard to learn the generator stuff, so we can improve our docs? Thanks Regular Smiley


Answer (User)   Posted on: 20-Oct-2005 08:46:52.
Hmm, i dont believe any of my quick test functions passed more then one parameter that was an LLBLGen entity. Ill have to check that out tomorow. I am going to start porting my Nhibernate code over to llblgen tomorow so it will be more tested by the end of the week.
But so far everything i have thrown at it has passed.

As for the generator stuff, i think it was mostly a naming issue. Once i figured it out its actually quite simple and pretty nifty. I think creating a tutorial that takes you step by step on how the generator works with some sample templates would help a lot. Like maybe walk through how the generator works with adapter.

Answer (User)   Posted on: 20-Oct-2005 18:51:22.
So far everything i have thrown at it including passing more then one entity as a parameter works wonderfully in both standard WS and WSE enchanced WS Laugh

Im quite impressed with its speed too.


Otis (LLBLGen Pro Team)   Posted on: 20-Oct-2005 19:52:44.
Regular Smiley

I have to admit I forgot to add your change to the beta released today. Will do tomorrow
Otis (LLBLGen Pro Team)   Posted on: 21-Oct-2005 12:08:23.
There's a problem.

Hierarchical entities returned from a webmethod, with polymorphism.

Say I have the webmethod:
[WebMethod()]
public CustomerEntity GetCustomer(string customerID)
{
...
}

now, what if I return a FemaleCustomerEntity (subtype of CustomerEntity) ? -> the client creates a CustomerEntity, because that's what the method's return type is, which means that there are just the customer fields, while the xml contains the FemaleCustomerEntity fields.

I don't have a clue how to solve this though, apparently, MS didn't think through this well enough, as is often the case when it comes to something related to Xml Dissapointed


Answer (User)   Posted on: 21-Oct-2005 18:18:11.
Hmmm, yes that is an issue. But not one that is limited to just your entities. It would act the same way with POCO would it not? Infact, i know it would. Thats a downside to web services.

The only option i can think of to solve this would be to change the the GetSchema function for abstract classes so it returns something else, like maybe AbstractEntity. Then have a AbstractEntity class (generated of course) with a function of GetCustomer etc...

This AbstractEntity class would of course store the returned XML, and init the correct object.

its one extra step, but i cant really thinkg of any other way.

BTW....a microsoft support guy is looking into the writer.writeraw() problem.
MikeH (User)   Posted on: 05-Nov-2005 00:02:12.
I'm just wondering: when we can expect this to be released? I'm REALLY looking forward to it! Laugh

Answer (User)   Posted on: 05-Nov-2005 04:12:05.
Hopefully monday. I created the templates to do it already and made my own task generator. Works great.. Regular Smiley

Otis (LLBLGen Pro Team)   Posted on: 05-Nov-2005 12:04:53.
Answer wrote:
Hopefully monday. I created the templates to do it already and made my own task generator. Works great.. Regular Smiley

Looking forward! Regular Smiley. Thanks for putting the time into this. Regular Smiley


Answer (User)   Posted on: 05-Nov-2005 19:05:56.
Frans, are you planning on including these in your release or do you want to make this a 3rd party addon? I know you mention earlier you were going to include it once vs went RTM and then make the docs etc on how to do it. Just curious if thats the still the case?


Either way, i can email you what i have for my templates if you wish.



Otis (LLBLGen Pro Team)   Posted on: 05-Nov-2005 20:24:37.
I've to check what's necessary to get it working. If it's a lot of hassle, I might decide to go for an add-on. If it's a thing which can be enabled easily, it's a no-brainer to add it to the main release. What I want to avoid at the moment is to change a lot in the released code, but what I tried out earlier using your info, it's a couple of templates and it works Regular Smiley

Answer (User)   Posted on: 02-Dec-2005 06:51:17.
Quote:
There's a problem.

Hierarchical entities returned from a webmethod, with polymorphism.

Say I have the webmethod:
[WebMethod()]
public CustomerEntity GetCustomer(string customerID)
{
...
}

now, what if I return a FemaleCustomerEntity (subtype of CustomerEntity) ? -> the client creates a CustomerEntity, because that's what the method's return type is, which means that there are just the customer fields, while the xml contains the FemaleCustomerEntity fields.

I don't have a clue how to solve this though, apparently, MS didn't think through this well enough, as is often the case when it comes to something related to Xml


I think i found a way to solve this. This is untested cuase my project doesnt use inheritance at the moment, but i believe this cna be solved by 2 methods.

Either include the
Code:
[XmlInclude(typeof(FemaleCustomerEntity))]
attribute above the webmethod OR above the base class Regular Smiley

This works on types that the XmlSerializer serializes, but i think it should work on IXmlSerializable as well.
Otis (LLBLGen Pro Team)   Posted on: 02-Dec-2005 10:09:34.
Thanks for the update! Regular Smiley I'll check it out.

swallace (User)   Posted on: 02-Dec-2005 15:41:21.
I'm just starting a Webservice application now. Was this released as a feature, or available as a template? Is there a way someone can email me this if it's a template?

Thanks!
Answer (User)   Posted on: 05-Dec-2005 17:57:21.
I can email you the templates i created and am using but i need your email Regular Smiley

swallace (User)   Posted on: 05-Dec-2005 20:38:24.
Answer wrote:
I can email you the templates i created and am using but i need your email Regular Smiley

It's sparky at developerfood dot com

Thanks!
Answer (User)   Posted on: 06-Dec-2005 16:30:51.
Emailed!

swallace (User)   Posted on: 06-Dec-2005 16:56:43.
Answer wrote:
Emailed!

Got it, thanks! I appreciate your work.

Regular Smiley

davisg (User)   Posted on: 07-Dec-2005 10:53:59.
Answer wrote:
I can email you the templates i created and am using but i need your email Regular Smiley

Hi Answer, I would like to use your code too, can you email it to ezydev dash software at yahoo dot co dot uk

Many thanks and looking forward to seeing it.

Geoff.


sami (User)   Posted on: 07-Dec-2005 15:09:01.
If you don't mind, send those to me too Laugh address: shavonen at hotmail dot com
arschr (User)   Posted on: 07-Dec-2005 17:29:58.
Is this going to be incorporated into the standard package, if not could it be added to the 3rd party downloads?

Otis (LLBLGen Pro Team)   Posted on: 07-Dec-2005 18:22:40.
arschr wrote:
Is this going to be incorporated into the standard package, if not could it be added to the 3rd party downloads?

in v2.0 it's included. Till then it could be a 3rd party add on, but I don't have the archive yet.
swallace (User)   Posted on: 07-Dec-2005 19:36:10.
Otis wrote:
arschr wrote:
Is this going to be incorporated into the standard package, if not could it be added to the 3rd party downloads?

in v2.0 it's included.

Sweeet!


Answer (User)   Posted on: 08-Dec-2005 03:37:53.
I'll get them emailed you to you guys asap in the morning since there on my work computer...i would have added them to the 3rd party section earlier, however i didnt know where to email them and since no one needed them i didnt bother trying to find out Regular Smiley

I know where to send them now, so ill send them to you frans for addition to 3rd party...

Otis (LLBLGen Pro Team)   Posted on: 09-Dec-2005 08:57:00.
I've received the archive. I'll see if I can put it up today! Regular Smiley

davisg (User)   Posted on: 09-Dec-2005 16:52:27.
Answer wrote:
I'll get them emailed you to you guys asap in the morning since there on my work computer...i would have added them to the 3rd party section earlier, however i didnt know where to email them and since no one needed them i didnt bother trying to find out Regular Smiley

I know where to send them now, so ill send them to you frans for addition to 3rd party...


Thanks, got them the other day so I will be checking them out this weekend. Appreciated.

Geoff.
sami (User)   Posted on: 10-Dec-2005 11:01:36.
Answer wrote:
I'll get them emailed you to you guys asap in the morning since there on my work computer...i would have added them to the 3rd party section earlier, however i didnt know where to email them and since no one needed them i didnt bother trying to find out Regular Smiley

I know where to send them now, so ill send them to you frans for addition to 3rd party...




Great! Thanks mate!


Otis (LLBLGen Pro Team)   Posted on: 10-Dec-2005 13:37:44.
They're online available now: in the customer area -> third party section. Regular Smiley
Indlex (User)   Posted on: 11-Dec-2005 17:00:37.
I have generated the BL successfully by using the Web Service generator. I am not quite sure how to use the wsdl.exe tool to generate the proxy. Can anyone please describe (or point me to some external resources) what I have to do next?

Thanks


Answer (User)   Posted on: 11-Dec-2005 22:21:56.
first page of this thread, 6th post down. Laugh
dvdstelt (User)   Posted on: 05-Jan-2006 10:35:40.
How do I use these templates? I've searched through the manual, but cannot seem to find how I should run these from LLBLGen Pro.

Where do I copy them to?
How do I run them?
Can I integrate these with my regular DAL generation templates, supplied with LLBLGen?

I've just copied the files to the LLBLGen Pro root (including folders) but I immediatly get an xml error when opening the "Generate..." dialog.


dvdstelt (User)   Posted on: 05-Jan-2006 14:07:39.
dvdstelt wrote:
How do I use these templates? I've searched through the manual, but cannot seem to find how I should run these from LLBLGen Pro.


I've downloaded the Template Designer, and I probably should use it. Add the given templates into the normal template project or something.

Any suggestions here?
Answer (User)   Posted on: 06-Jan-2006 05:04:45.
Extract zip file to your llblgen folder. You can then select the task performer from the generation menu...

dvdstelt (User)   Posted on: 07-Jan-2006 21:47:45.
Answer wrote:
Extract zip file to your llblgen folder. You can then select the task performer from the generation menu...

Unfortunatly not... First of all, all files are in a root folder called "VS.NET2005WebServiceTemplates". When the three folders in that folder are moved to the LLBLGen Pro folder, you get a nasty XML error, because there's an illegal character inside the template config file.

Then I got this error :

Task WebServiceHelperGenerator
Could not find template 'WebServiceHelperTemplate'. It is not defined in the template set config file.

Now, I then figured out that I should also select the C# template for SQL2005 with web service support (there's a typo in there btw, it's "serice support", without a v).

Then I tried to run it over my already existing project, generated without webservice support, but got a nice "Object reference not set" error.

Then I generated all code into a new clean folder, and it worked. I'm now going to check out what has been generated. Regular Smiley
Answer (User)   Posted on: 08-Jan-2006 18:40:10.
Hmm, i dont remember putting them in that folder, but okay Regular Smiley..These templates are by no means a polished 3rd party addon. They are meant to serve as a quick helper until frans adds the functionality in the next version. But most likely you will probably want to do some modding/tweaking to them to fit your project etc..but they will get you started..


As as side note, you might want to check out my last post in here
http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4973

it explains some of the issues (for me anyway) that i discovered with llblgen going over the web service wire Regular Smiley



dvdstelt (User)   Posted on: 16-Jan-2006 12:49:05.
Or check this thread, where discussion seems to continue:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=5139
Reginald (User)   Posted on: 21-Jan-2006 13:36:32.
Otis, is it possible to get my hands on this 3rd party add-on? I'm not yet a customer and dont have access to the 3rd party add-on's. Or can someone email it to me (reginald dot henderson at gmail dot com)?

Also, when is the 2.0 version going to be released?

-Reginald


Otis (LLBLGen Pro Team)   Posted on: 23-Jan-2006 11:15:02.
Reginald wrote:
Otis, is it possible to get my hands on this 3rd party add-on? I'm not yet a customer and dont have access to the 3rd party add-on's. Or can someone email it to me (reginald dot henderson at gmail dot com)?

These particular templates don't have a readme etc. now, they're very rough. I'm not going to mail them to a potential customer, sorry. It's not that I don't want you to have them, but a potential customer doesn't know (in general) the system that good, and using these templates might cause problems which can result in a bad experience.

Quote:

Also, when is the 2.0 version going to be released?

I hope to be done programming at the end of march, beta in april, so that's the rough timetable Regular Smiley
Reginald (User)   Posted on: 23-Jan-2006 14:32:24.
Quote:
and using these templates might cause problems which can result in a bad experience.


I can respect that. I can really respect that. I think I'm going to buy in the next couple of weeks so I'll hit you up for the templates at that time. The support here is reason enough to buy the product.

And I'll have to be one of your first beta testers when you're ready. Happy coding.

-Reginald


Otis (LLBLGen Pro Team)   Posted on: 23-Jan-2006 21:09:38.
Reginald wrote:
Quote:
and using these templates might cause problems which can result in a bad experience.


I can respect that. I can really respect that. I think I'm going to buy in the next couple of weeks so I'll hit you up for the templates at that time. The support here is reason enough to buy the product.

Cool! Regular Smiley Thanks! Regular Smiley And thank you for understanding Regular Smiley

Otis (LLBLGen Pro Team)   Posted on: 25-Jan-2006 12:21:34.
I've updated the archive with a readme and have removed the '&' from the xml so it will properly load Regular Smiley

abdev (User)   Posted on: 07-Feb-2006 21:56:24.
Ok sorry if I am dense here, but I am trying to get all this to work. Since WebServices will be only way to do this with Vista, I wanted to get this done now.

Ok I downloaded the item from the 3rd party section I regenerated the code.

I built a SchemaImporter (I am assuming that I have to have a name entry for every entity type name I have (correct?)

Build this into a library, sign it and get it into the GAC? What would the name space be equal to for the serialization (the namespace I entered on the generated code piece)? Also the compileUnity.ReferencedAssemblies.Add - I am guessing this needs a full path to the assembly.

Thanks for any help here............

The readme is nice until getting to the client side work. Regular Smiley
dvdstelt (User)   Posted on: 13-Feb-2006 11:22:18.
I'm still confused here.

My proxy returns a "webservice.entitycollection" object, whereas I want it to be a "mynamespace.helperclasses.entitycollection" object. I cannot simply cast it to a helperclasses.entitycollection.

When in I put "mynamespace.helperclasses.entitycollection" into my templates, it does work. Problem then is, that I can only work with THAT EXACT namespace in all my projects. When going to the next project, or a POC project or something, the schemaimporter doesn't work anymore.

Kinda sucks.

Any suggestions? Am I seeing something wrong here?


Otis (LLBLGen Pro Team)   Posted on: 13-Feb-2006 12:28:55.
you could opt for returning an IEntityCollection2 object (haven't tried, probably does't work with the webservice 'system')

It indeed is kind of hardcoding whatever you want to use and ALSO have to modify the machine.config to get it to work... and indeed, it's not great to say the least. MS will never learn, I'm afraid.
dvdstelt (User)   Posted on: 13-Feb-2006 13:12:34.
I got it to work anyhow... For some reason, I thought it could not have more than one SchemaImporter per machine.config. Silly me. Embarassed

Anyway, it can also be done by HelperClasses.EntityCollection. I'm still working with the full namespace currently though, but now with the SchemaImporter Extensions. Like I explained in the doc I send you.


sburtonctr (User)   Posted on: 17-Feb-2006 23:35:00.
I have been following the discussion on Web Services and have been able to create a web service that returns the EntityCollection. The problem in my evaluation of the product is that the consumer of the Web service is SSIS and we do not reference the LLBL business tier, “nor do I think it is possible in SSIS”, objects to consume the Web Service like you would in a winform application or a WebSite. You make the Web Reference and it generates the proxy, but it seems that you must have a reference to the LLBL objects that contain the class being passed. Has anyone used SSIS to consume LLBL web services or is there something else I must do to get this part to work.

-- This is a sample of my web service.

[WebMethod]
public EntityCollection GetAllCommunities( )
{

DataAccessAdapter communityAdapter = new DataAccessAdapter( );
EntityCollection c = new EntityCollection(new CommunityEntityFactory());
communityAdapter.FetchEntityCollection( c, null );

return c;

}

I have not really had a lot of time with the product, but do you have any suggestions on how I should proceed with this. So far I tried hiding the IXmlSerializable methods to customize the XML message generated in the Entity and Collection classes so SSIS would not have to know about the LLBL objects and the default serialization xml structure. However, I still have a problem with comsuming the Web service with the schema problem defined in early postings. It works with Winforms and Website access to Web services but not with SSIS. I think this is because the proxy seems to reference the BBLB business objects.


Any suggestions:

Thanks
Otis (LLBLGen Pro Team)   Posted on: 18-Feb-2006 09:48:09.
What exactly does SSIS WANT to receive? This is a bit unclear to me. I haven't worked with SSIS and webservices, so I'm no expert on this, but if you can specify what SSIS wants to receive as data, I can perhaps point you to the direction how to convert an entity collection to that format (as it already produces Xml through the WriteXml() methods)

dan (User)   Posted on: 23-Feb-2006 18:56:55.
Hello,

Thank You for addon

I've followed all the steps in readme file, at moment my webservice methods return
System.Xml.XmlElement though declared as:

[WebMethod]
public KasutajaEntity getUser()


As I understand if followed all the steps in readme correctly my web method should return Entity objects, not XmlElemnt, is it correct?
Otis (LLBLGen Pro Team)   Posted on: 25-Feb-2006 12:45:36.
dan wrote:
Hello,

Thank You for addon

I've followed all the steps in readme file, at moment my webservice methods return
System.Xml.XmlElement though declared as:

[WebMethod]
public KasutajaEntity getUser()

As I understand if followed all the steps in readme correctly my web method should return Entity objects, not XmlElemnt, is it correct?

How do you test this? The webmethod under the hood of course returns an xml element, as that's what's happening under the hood, but in YOUR code consuming the service, you use the generated stub class which should return an entity. Could you paste some of your code? Thanks. Also could you examine the generated stub class and see what code is generated there?


dan (User)   Posted on: 25-Feb-2006 16:29:32.
Hello

Thank you for reply

The problem was in my machine config, now I can move entities around webservice
The generated Reference.cs had to be edit though

move this line -> using ShopNet.Business.EntityClasses;

above -> namespace ShopNet.TestingClient.ShopNet.Ws {


and rename

public ShopNet.Business.EntityClasses.KasutajaEntity getUser() {

to


public KasutajaEntity getUser() {

and now its working, but is there any way to do it without editing Reference.cs?


Thank You
Otis (LLBLGen Pro Team)   Posted on: 28-Feb-2006 11:13:20.
This is something in the converter classes but I don't think you should have to alter the generated stub class. The using statement is ok there, as well as the namespace references, or did it fail to compile?

PatrickHofman (User)   Posted on: 06-Mar-2006 15:33:32.
It is only working with Adapter, or is there also a template for SelfServicing. If not, why isn't it possible?
Otis (LLBLGen Pro Team)   Posted on: 06-Mar-2006 16:50:51.
PatrickHofman wrote:
It is only working with Adapter, or is there also a template for SelfServicing. If not, why isn't it possible?

SelfServicing isn't useful in a distributed scenario, as it supports lazyloading, which is triggered for example if you access a field mapped on a relation. This then causes the code to load the data, however this call is on the client and the data is on hte server, and the db is therefore thus not found. Adapter has a disconnected model, so the persistence logic is only available on the server.


PatrickHofman (User)   Posted on: 06-Mar-2006 17:03:06.
Good point...
yk (User)   Posted on: 08-Mar-2006 05:19:23.
Otis wrote:
There's a problem.

Hierarchical entities returned from a webmethod, with polymorphism.

Say I have the webmethod:
[WebMethod()]
public CustomerEntity GetCustomer(string customerID)
{
...
}

now, what if I return a FemaleCustomerEntity (subtype of CustomerEntity) ? -> the client creates a CustomerEntity, because that's what the method's return type is, which means that there are just the customer fields, while the xml contains the FemaleCustomerEntity fields.

I don't have a clue how to solve this though, apparently, MS didn't think through this well enough, as is often the case when it comes to something related to Xml Dissapointed


I think what you are describing is beyond the realm of web services. What cannot be described by the WSDL (in this case inheritance) is simply out of scope. You can have two methods -- GetCustomer and GetFemaleCustomer if you need to return both types.

Think about it - the consuming application cannot possibly know that you might return a female customer, and you cannot assume the consuming application will even be written in a language that supports inheritance (or objects -- e.g. ASP).


mkamoski (User)   Posted on: 24-May-2006 15:20:55.
Otis, Answer, AnyoneElseWhoKnows--

Please help.

I have two quick questions regarding the templates that include web service support.

As background, note that...

--I downloaded the templates from http://www.LLBLGen.com , >Customer's Area, >3rd Party.

--I have read this current thread.

--I have read the "readme.doc" included with the template download.

While some of my questions were addressed in the threads and documentation, I need to explicity double-check a couple of things.

My questions are...

(1) Is it true that the machine.config changes are only required on the development workstation and will not be required in a deployed production setting?

(2) Is it true that the GAC changes are only required on the development workstation and will not be required in a deployed production setting?


Please advise.

Thank you.

--Mark Kamoski
Otis (LLBLGen Pro Team)   Posted on: 24-May-2006 16:00:33.
mkamoski wrote:
Otis, Answer, AnyoneElseWhoKnows--

Please help.

I have two quick questions regarding the templates that include web service support.

As background, note that...

--I downloaded the templates from http://www.LLBLGen.com , >Customer's Area, >3rd Party.

--I have read this current thread.

--I have read the "readme.doc" included with the template download.

While some of my questions were addressed in the threads and documentation, I need to explicity double-check a couple of things.

My questions are...

(1) Is it true that the machine.config changes are only required on the development workstation and will not be required in a deployed production setting?

True. They're only required for the discovery service that builds the classes used during development for the CLIENT. So the changes are required for the machine on which you want to run wsdl.exe (or vs.net and add a webreference).

Quote:

(2) Is it true that the GAC changes are only required on the development workstation and will not be required in a deployed production setting?

Yes, same as 1)


mkamoski (User)   Posted on: 25-May-2006 15:11:07.
All--

FWIW, note the following from MSDN...

Web Services IXmlSerializable Technology Sample

This sample shows how to use IXmlSerializable to control the serialization of custom types in ASP.NET Web Services.

http://msdn2.microsoft.com/en-US/library/h2byscsb.aspx

...so, that is worth checking out, if someone is interested.

I am guessing; but, I think that this is the same sort of thing that the LLBLGen Templates With Web Service Support do in order to solve this issue.

But, I just thought I should mention it here, for completeness.

HTH.

Thank you.

--Mark Kamoski

mkamoski (User)   Posted on: 25-May-2006 22:09:38.
Otis and/or Answer and/or AnyoneWhoKnows--

I am testing out the LLBLGen Templates With Web Service Support (LTWWSS).

Preliminary testing indicates that they do work fine.

I have one question...

In the readme.doc, it shows this edit for the machine.config...

Code:

<system.xml.serialization>
<schemaImporterExtensions>
    <add name="SchemaImporter" type="yournamespace.SchemaImporter, assemblyname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=44a0feb02394e70a" />
</schemaImporterExtensions>
</system.xml.serialization>


...and my question is...

Note that we one does change the "yournamespace" part and the "assemblyname" part in the same. However, since the <add> node has name="SchemaImporter" and one does not change this, then what happens when the same machine wants to use >1 set of LLBLGen-generated objects using the LTWWSS? Won't there be a collision given >1 <add> node in the machine.config will have the same name="SchemaImporter" attribute setting?

You see, I am assuming that WSDL and other the other great things that VS.NET 2005 runs to create the proxy class does a lookup into machine.config at run-time when the proxy is gettting generate and looks for that "name" attribute and uses it. But, I am thinking, if there is >1 set of LLBLGen-generated objects, then there will >1 <add> node with the same name and I am wondering how WSDL will find the right one to match with the right output.

And so on.

What do you think?

Please advise.

Thank you.

(Post Script -- Yes, I plan to actually try this; but, I thought I should ask regardless because at this end there is A LOT of room for operator error and I will not know if it is LTWWSS or me, and so on.)

--Mark Kamoski


staffel95 (User)   Posted on: 03-Jan-2008 00:07:02.
Frans,
It's been a while since this thread has been active...
I am trying to eval LLBLGEN with webservices.
Now from this thread it seems like in the past you emailed people the templates directly if they were still in eval period, right? Is that still the process?

I dont have access to the download section on the main site yet since I am using the eval also, right?

I noticed some tasks under the 2.0 generation could be enabled, but I got the error listed below regarding the template 'SD_VsNet2005AdapterTemplate' not being found.

What to do now? Am I stuck unless I purchase LLBLGEN first?

Thank you,
Eric


Task group: SD.Tasks.Adapter.Webservices.SchemaImporter
            Task: SD.Tasks.Adapter.Webservices.SchemaImporter.DirectoryCreator
                    Directory 'C:\Documents and Settings\Owner\My Documents\LLBLGen Pro Projects\PetShopDAL20\SchemaImporter' created/preserved successfully.
            Task: SD.Tasks.Adapter.Webservices.SchemaImporter.SchemaImporterClassGenerator
                    Code generated into file 'C:\Documents and Settings\Owner\My Documents\LLBLGen Pro Projects\PetShopDAL20\SchemaImporter\SchemaImporter.vb' successfully.
            Task: SD.Tasks.Adapter.Webservices.SchemaImporter.ProjectCreator
                    Could not find template 'SD_VsNet2005AdapterTemplate'. It is not defined in the templatebindings or is empty.
        Task execution ended on: 02-Jan-2008 17:22.25



Walaa (Support Team)   Posted on: 03-Jan-2008 10:59:38.
Using LLBLGen Pro v.2.5 the schemaImporter template is provided with the package.

Please read the .NET 2.0 specific: Schema importers in the LLBLGen Pro v.2.5 documentation under:
Using the generated code -> Adapter -> Distributed system -> XML Webservices / WCF support

Next time please create a new thread as decribed here:
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722
Thanks