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.
[XmlSchemaProvider("GetEntitySchema")]
[XmlRoot("CatalogEntity", Namespace = "http://yournamespace", IsNullable = true)]
Next you need to implement the static method GetEntitySchema.
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
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
Creating the schemaimport extension is a whole another ball game, so i just included this so you could better see whats going on.
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
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.