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


     
     
     
     
     
     





  • 相关阅读:
    hashmap的一些基础原理
    关于uuid
    读锁跟写锁的区别
    栈为什么效率比堆高
    MySQL行级锁、表级锁、页级锁详细介绍
    MYSQL MyISAM与InnoDB对比
    MYSQL锁表问题解决
    mysql查询锁表语句
    三种排序方法
    正则表达式
  • 原文地址:https://www.cnblogs.com/president/p/971513f96cfb0ae88db9b6803208b055.html
Copyright © 2011-2022 走看看