该DEMO的服务器由.NET构建,客户端由JAVA程序访问
一、   WEB SERVICE构建
       在一台机器上用.NET构建一个WEB SERVICE工程,用C#作为编程语言。
       假设代码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
 
namespace Service1.asmx
{
    /// <summary>
    /// Service1 的摘要说明。
    /// </summary>
    public class Service1 : System.Web.Services.WebService
    {
        public Service1()
        {
            //CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
            InitializeComponent();
        }
 
        #region 组件设计器生成的代码
        
        //Web 服务设计器所必需的
        private IContainer components = null;
                
        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
        }
 
        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if(disposing && components != null)
            {
                components.Dispose();
            }
            base.Dispose(disposing);        
        }
        
        #endregion
 
        // WEB 服务示例
        // HelloWorld() 示例服务返回字符串 Hello World
        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
 
        // WEB 服务示例
        // 通过传入参数在服务器端计算结果并返回
        [WebMethod]
        public int addval(int i, int j)
        {
            ADDLib.mathClass obj = new ADDLib.mathClass();
            return obj.addval(i,j);
        }
 
        // WEB 服务示例
        // 返回一维数组
        [WebMethod]
        public int[] returnIntArr()
        {
            int[] bb = new int[6];
            bb[0] = 1;
            bb[1] = 2;
            bb[2] = 3;
            bb[3] = 4;
            bb[4] = 5;
            bb[5] = 6;
            return bb;
        }
 
 
 
        // WEB 服务示例
        // 返回多维数组
        [WebMethod]
        public ArrayList returnArrs()
        {
            
            ArrayList al=new ArrayList();
            for(int jj=1;jj<10;jj++){
                al.Add(returnAlist(jj));
            }
            return al;
        }
        private ArrayList returnAlist(int i)
        {
            ArrayList al=new ArrayList();
            for(int j=0;j<6;j++)
            {
                al.Add("wyl"+j);
            }
            return al;
        }
 
        // WEB 服务示例
            //返回自构建对象
        [WebMethod]
        public MyObject_hhf returnMyObj(int i)
        {
            MyObject_hhf myobj=new MyObject_hhf(i);
            myobj.SetVal();
            return myobj;
        }
    }
 
    // WEB 服务示例
    //自构建对象
    [Serializable]
    public class MyObject_hhf //: DataSet  // : ISerializable 
    {
        public int m_iRowCount;
        public int m_iColCount;
        public int i;
        
        public ArrayList aryobj=new ArrayList();
        
        public MyObject_hhf()
        {}
 
        public MyObject_hhf(int i)
        {
            this.i=i;
            this.m_iColCount=i+1;
            this.m_iRowCount=i+2;
        }
 
        public void SetVal()
        {
            for(int j=0;j<i;j++)
            {
                aryobj.Add(j);
            }
        }
    }
}
以上代码暴露了5个接口:返回字符串、一个方法、一维数组、多维数组、一个自构建对象。