Martin,
I sure can. This is what I have:
Type contract = ProxyAssembly.GetType(contractName);
MethodInfo method = contract.GetMethod(operationName);
ParameterInfo[] parameters = method.GetParameters();
List<XmlDocumentxmlDocs = new List<XmlDocument>();
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
DataContractSerializer dcs;
XmlDocument doc;
XsdDataContractExporter dce;
foreach (ParameterInfo parameter in parameters)
{
object inst =
ProxyAssembly.CreateInstance(parameter.ParameterTy pe.FullName);
dce = new XsdDataContractExporter();
dce.Options = eo;
dce.Export(parameter.ParameterType);
dcs = new DataContractSerializer(parameter.ParameterType);
dcs.WriteObject(xtw, inst);
doc = new XmlDocument();
doc.LoadXml(sw.ToString());
doc.Schemas = dce.Schemas;
xmlDocs.Add(doc);
}
Without going in to too many specifics, I'm generating a dynamic proxy on a
WCF service using some code I found, and then using the assembly created to
get the methods on the contract and the parameters of those methods.
I then want create an instance of the class, serialize it, use the
XsdDataContractExporter to get the XSD definitions for the class and then
assign them to the XmlDocument schemas collection. If I then take a look at
any node within my XmlDocument to get back the SchemaInfo, it is null.
This is driving me mad, I think I'm probably missing something really
simple. I think I may need to validate first but using an XmlSchemaValidator
seems onerous at best.
I need to the types because I then want to generate and ASP.NET form with
appropriate controls (checkbox for boolean, etc.) to allow testing the client.
I originally wanted to use InfoPath, but it doesn't work with WSHttpBinding,
and nor do any of the other tools out there!!
Thx,
CD
"Martin Honnen" wrote:
Competitive Dad wrote:
I figured I could use the DataContractSerializer and XsdDataContractExporter
for create the Xml, get the XSD from the class and assign the resulting
XmlSchemaSet to the XmlDocument.Schemas collection. This works, but I still
cannot get to the XmlNode.SchemaInfo.SchemaType.BaseSchemaType property of a
node within the XmlDocument.
Can you show us the relevant code, in particular the order in which you
set the Schemas property and call the Load method?
It might help to call the Validate method to ensure the nodes have type
annotations.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/