在使用Web参考重建项目时,将生成没有必要属性的访问服务的每种方法。我必须手动编辑Reference.cs文件才能还原它们。下面生成的带有添加属性的代码。
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/IEdaService/SyncItems", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
[SoapHeader( "ToHeader" )] // This attribute disappears.
[SoapHeader( "ActionHeader" )] // This attribute disappears.
public SyncItems SyncItems(
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string login,
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string pass,
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string guid,
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string serial)
{
object[] results = this.Invoke("SyncItems", new object[] {
login,
pass,
guid,
serial});
return ((SyncItems)(results[0]));
}
如何设置正确的代码生成,或者至少在程序运行时如何将这些属性添加到每个调用中?