C#调用java 编写的webservice时不会自动生成 soapheader 类接口的,需要改动Reference.cs
在生成的代理类referende.cs中进行如下操作:

一、在声明public new string Url{....}前声明 public AuthenticationToken header { get; set; },然后在相应位置添加

 

/// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public class AuthenticationToken : System.Web.Services.Protocols.SoapHeader
    {
        /// <remarks/>
        public string Username{ get;  set;  }  //要传入的账号

        /// <remarks/>
        public string Password { get; set; }   //要传入的密码
    }   

 

 
 
二、  在要调用的接口的方法前添加(注:Referende.cs 中的方法
        /// <remarks/>
        [System.Web.Services.Protocols.SoapHeaderAttribute("header")]

 

 
三、页面中调用用方法
 GuestService gs = new GuestService(); //引用的服务
 AuthenticationToken t = new AuthenticationToken();
 t.Username = "admin123";
 t.Password = "admin123";
 gs.header = t;
 gs.methodName();

 



 
 
 
 
 
 





相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-30
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-10
  • 2021-06-01
  • 2022-12-23
  • 2021-10-14
  • 2021-09-10
  • 2021-11-07
相关资源
相似解决方案