关于C#访问JAVA中的map类型的体会

 最近,有个项目需要用到WebService的一些调用.对方的Webservice服务程序是用JAVA开发的,现在要在C#中调用.一般的类型数据还可以,但遇到了map类型的数据到是费了不少的周折,下面就将具体实现写出来与大家一起讨论.

定义访问对象:UserService.FaxUserService service = new UserService.FaxUserService();
 验证:        service.Credentials = new System.Net.NetworkCredential("053188113396","000000");


1、修改访问的代理类:

    修改URL(包括Map和MapItem):http://xml.apache.org/xml-soap1如:
    [System.Xml.Serialization.SoapTypeAttribute("Map", "http://xml.apache.org/xml-soap1")]
    public class Map {
       
        /// <remarks/>
        public mapItem[] item;
    }
  
   修改各Map类型的函数返回类型如:
      public object faxRec(string agentID, string userID, string startTime, string endTime) {
            object[] results = this.Invoke("faxRec", new object[] {
                        agentID,
                        userID,
                        startTime,
                        endTime});
            return ((object)(results[0]));
        }

2、对修改后的函数调用:

                       System.Xml.XmlElement erm=null;
   string tmpstr=null;
   System.Array tmpary=(System.Array)service.faxRec(this.AgentID,this.UserID,startTime,endTime);
   int pm=tmpary.Length-1;
   for(int i=6;i<=pm;i++)
   {
    erm=(System.Xml.XmlElement)tmpary.GetValue(i);
    tmpstr=erm.InnerText;
    this.add_table(tmpstr); //插入到数据表格中
   }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值