views:

17

answers:

1

I am using WebClient to read wsdl from URI.

WebClient client = new WebClient();
Stream wsdlStream = client.OpenRead(wsdlURI);
ServiceDescription wsdl = ServiceDescription.Read(wsdlStream);

Then I set Namespace and CompileUnit and use ServiceDescriptionImporter's GenerateCodeFromCompileUnit method to generate .cs class file.

Then I compile assembly from it and use reflection to call methods. Problem is, that my created .cs file has additional xml attributes. And additional parameters like:

public void Calc(int a, [System.Xml.Serialization.XmlIgnoreAttribute()] bool aSpecified

When I create assembly from this source file, I get methods with more parameters, than they should have. Original method looks like:

public int Calc(int a, int b)

and method in generated source code looks like:

public int Calc(int a, bool aSpecified, int b, bool bSpecified, out int CalcResult, out bool CalcResultSpecified)

How can I get dynamically generated source file without these additional parameters? So I can compile it to assembly and use reflection to call original methods?

A: 

The ignored fields are there because the original WSDL specifies some of the parameters as optional but of value types, and the XmlSerializer doesn't support Nullable<T>, so the xxxSpecified parameters allow you to tell it if the value is null or not. Guess you're stuck with them.

tomasr
Thanks for reply, but as u said... I am stuck with them. :X
solar
Stuck in that you'll have to deal with them; you can't get rid of them so you will just have to write code to deal with them in your reflection calls, just like you do for the real parameters. It's not a huge deal, really.
tomasr