【发布时间】:2012-04-04 17:17:25
【问题描述】:
我有一个带有方法的肥皂网络服务:
string startReaction(object reaction);
在该方法中,我将此对象转换为它的真实类型:
Reaction reactionObj = (Reaction)reaction;
...
我在表单项目中有相同的Reaction 类(该窗口应该调用这个ws)。在这里,我创建了 Reaction 对象实例并用数据填充它并尝试发送到 Web 服务。
string data = webserviceReference1.startReaction(reaction);
我也试过了:
string data = webserviceReference1.startReaction(reaction as object);
但什么都没有。 然后我尝试在 Reaction 类上添加这个属性:
[XmlInclude(typeof(object))]
public class Reaction{...
但什么都没有。 我得到的错误是:
There was an error generating the XML document. :: System.InvalidOperationException: The type Demo.Form1+Reaction was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
【问题讨论】:
-
为什么不
string startReaction(Reaction reaction);?
标签: c# web-services soap xml-serialization