开发者

How to get rid of XmlIgnoreAttribute() when creating proxy dynamically from wsdl?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜