zoukankan      html  css  js  c++  java
  • C# 调用Java Webservice 加入SoapHeader 验证信息

    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();


     
     
     
     
     
     





  • 相关阅读:
    Debian ABC --- 1st time ---7
    django基础操作
    http协议
    css3种引入方式,样式与长度颜色,常用样式,css选择器
    前端3剑客
    视图,sql注入问题,事物,存储过程
    用户权限,pymysql
    表查询
    约束
    mysql数据类型
  • 原文地址:https://www.cnblogs.com/president/p/971513f96cfb0ae88db9b6803208b055.html
Copyright © 2011-2022 走看看