文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>【求助】.net1.1调用webservice返回二维数组时提示“XML 文档(1, 378)中有错误”的解决方法!

【求助】.net1.1调用webservice返回二维数组时提示“XML 文档(1, 378)中有错误”的解决方法!

时间:2010-08-31  来源:飛雪飄寒

  最近,由于业务需求,项目需要调用其他单位提供的接口来同步数据,对方提供的接口是java开发的WebService,返回的数据是二维数组。我们的项目是05年开发的.net1.1版本,在调用对方接口获取返回的二维数组数据时,提示“XML 文档(1, 378)中有错误”。经测试无论在哪个框架下添加引用对方服务时,生成的CS文件返回的都是一维数组,而并非二维数组,在.net2.0以上版本,强制性修改CS文件的方法来返回二维数组可以得到对方的数据,但在.net1.1版本,强制性修改CS文件的方法来返回二维数组时就提示“XML 文档(1, 378)中有错误”。上google搜索该问题,部分网友说.net1.1调用WebService不支持二维数组,不知道是否真是这样,如果支持二维数组,请问各位园友这个问题如何解决?期待园友的解答,谢谢!
  在.net1.1、.net2.0、.net3.0的测试情况具体如下:
  注意:修改后的CS文件主要对方法findRegisterQuota的返回类型作了修改,默认为一维数组,强制性修改为二维数组了。

  1、.net2.0环境  

  (1)调用对方服务生成的原始CS文件

代码 //------------------------------------------------------------------------------
// <auto-generated>
//     此代码由工具生成。
//     运行库版本:2.0.50727.3603
//
//     对此文件的更改可能会导致不正确的行为,并且如果
//     重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------

// 
// 此源代码是由 Microsoft.VSDesigner 2.0.50727.3603 版自动生成。
// 
#pragma warning disable 1591

namespace WebApplication2.WebReference {
    using System.Diagnostics;
    using System.Web.Services;
    using System.ComponentModel;
    using System.Web.Services.Protocols;
    using System;
    using System.Xml.Serialization;
    
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="RegisterServiceSoapBinding", Namespace="http://register.webservice.hnisi.com.cn")]
    public partial class RegisterService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        private System.Threading.SendOrPostCallback registerOperationCompleted;
        
        private System.Threading.SendOrPostCallback findRegisterQuotaOperationCompleted;
        
        private bool useDefaultCredentialsSetExplicitly;
        
        /// <remarks/>
        public RegisterService() {
            this.Url = global::WebApplication2.Properties.Settings.Default.WebApplication2_WebReference_RegisterService;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        public new string Url {
            get {
                return base.Url;
            }
            set {
                if ((((this.IsLocalFileSystemWebService(base.Url) == true) 
                            && (this.useDefaultCredentialsSetExplicitly == false)) 
                            && (this.IsLocalFileSystemWebService(value) == false))) {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }
        
        public new bool UseDefaultCredentials {
            get {
                return base.UseDefaultCredentials;
            }
            set {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        /// <remarks/>
        public event registerCompletedEventHandler registerCompleted;
        
        /// <remarks/>
        public event findRegisterQuotaCompletedEventHandler findRegisterQuotaCompleted;
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://register.webservice.hnisi.com.cn", ResponseNamespace="http://register.webservice.hnisi.com.cn")]
        [return: System.Xml.Serialization.SoapElementAttribute("RegisterReturn")]
        public string[] register(string userID, string password, string[] citizenInfos) {
            object[] results = this.Invoke("register", new object[] {
                        userID,
                        password,
                        citizenInfos});
            return ((string[])(results[0]));
        }
        
        /// <remarks/>
        public void registerAsync(string userID, string password, string[] citizenInfos) {
            this.registerAsync(userID, password, citizenInfos, null);
        }
        
        /// <remarks/>
        public void registerAsync(string userID, string password, string[] citizenInfos, object userState) {
            if ((this.registerOperationCompleted == null)) {
                this.registerOperationCompleted = new System.Threading.SendOrPostCallback(this.OnregisterOperationCompleted);
            }
            this.InvokeAsync("register", new object[] {
                        userID,
                        password,
                        citizenInfos}, this.registerOperationCompleted, userState);
        }
        
        private void OnregisterOperationCompleted(object arg) {
            if ((this.registerCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.registerCompleted(this, new registerCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://register.webservice.hnisi.com.cn", ResponseNamespace="http://register.webservice.hnisi.com.cn")]
        [return: System.Xml.Serialization.SoapElementAttribute("FindRegisterQuotaReturn")]
        public string[]findRegisterQuota(string userID, string password, string annual, string departmentCode) {
            object[] results = this.Invoke("findRegisterQuota", new object[] {
                        userID,
                        password,
                        annual,
                        departmentCode});
            return ((string[])(results[0]));
        }
        
        /// <remarks/>
        public void findRegisterQuotaAsync(string userID, string password, string annual, string departmentCode) {
            this.findRegisterQuotaAsync(userID, password, annual, departmentCode, null);
        }
        
        /// <remarks/>
        public void findRegisterQuotaAsync(string userID, string password, string annual, string departmentCode, object userState) {
            if ((this.findRegisterQuotaOperationCompleted == null)) {
                this.findRegisterQuotaOperationCompleted = new System.Threading.SendOrPostCallback(this.OnfindRegisterQuotaOperationCompleted);
            }
            this.InvokeAsync("findRegisterQuota", new object[] {
                        userID,
                        password,
                        annual,
                        departmentCode}, this.findRegisterQuotaOperationCompleted, userState);
        }
        
        private void OnfindRegisterQuotaOperationCompleted(object arg) {
            if ((this.findRegisterQuotaCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.findRegisterQuotaCompleted(this, new findRegisterQuotaCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
        
        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null) 
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if (((wsUri.Port >= 1024) 
                        && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                return true;
            }
            return false;
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    public delegate void registerCompletedEventHandler(object sender, registerCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class registerCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal registerCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public string[] Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((string[])(this.results[0]));
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    public delegate void findRegisterQuotaCompletedEventHandler(object sender, findRegisterQuotaCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class findRegisterQuotaCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal findRegisterQuotaCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public string[] Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((string[])(this.results[0]));
            }
        }
    }
}

#pragma warning restore 1591

   (2)调用对方服务修改后的CS文件 

代码 //------------------------------------------------------------------------------
// <auto-generated>
//     此代码由工具生成。
//     运行库版本:2.0.50727.3603
//
//     对此文件的更改可能会导致不正确的行为,并且如果
//     重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------

// 
// 此源代码是由 Microsoft.VSDesigner 2.0.50727.3603 版自动生成。
// 
#pragma warning disable 1591

namespace WebApplication2.WebReference {
    using System.Diagnostics;
    using System.Web.Services;
    using System.ComponentModel;
    using System.Web.Services.Protocols;
    using System;
    using System.Xml.Serialization;
    
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="RegisterServiceSoapBinding", Namespace="http://register.webservice.hnisi.com.cn")]
    public partial class RegisterService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        private System.Threading.SendOrPostCallback registerOperationCompleted;
        
        private System.Threading.SendOrPostCallback findRegisterQuotaOperationCompleted;
        
        private bool useDefaultCredentialsSetExplicitly;
        
        /// <remarks/>
        public RegisterService() {
            this.Url = global::WebApplication2.Properties.Settings.Default.WebApplication2_WebReference_RegisterService;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        public new string Url {
            get {
                return base.Url;
            }
            set {
                if ((((this.IsLocalFileSystemWebService(base.Url) == true) 
                            && (this.useDefaultCredentialsSetExplicitly == false)) 
                            && (this.IsLocalFileSystemWebService(value) == false))) {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }
        
        public new bool UseDefaultCredentials {
            get {
                return base.UseDefaultCredentials;
            }
            set {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        /// <remarks/>
        public event registerCompletedEventHandler registerCompleted;
        
        /// <remarks/>
        public event findRegisterQuotaCompletedEventHandler findRegisterQuotaCompleted;
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://register.webservice.hnisi.com.cn", ResponseNamespace="http://register.webservice.hnisi.com.cn")]
        [return: System.Xml.Serialization.SoapElementAttribute("RegisterReturn")]
        public string[] register(string userID, string password, string[] citizenInfos) {
            object[] results = this.Invoke("register", new object[] {
                        userID,
                        password,
                        citizenInfos});
            return ((string[])(results[0]));
        }
        
        /// <remarks/>
        public void registerAsync(string userID, string password, string[] citizenInfos) {
            this.registerAsync(userID, password, citizenInfos, null);
        }
        
        /// <remarks/>
        public void registerAsync(string userID, string password, string[] citizenInfos, object userState) {
            if ((this.registerOperationCompleted == null)) {
                this.registerOperationCompleted = new System.Threading.SendOrPostCallback(this.OnregisterOperationCompleted);
            }
            this.InvokeAsync("register", new object[] {
                        userID,
                        password,
                        citizenInfos}, this.registerOperationCompleted, userState);
        }
        
        private void OnregisterOperationCompleted(object arg) {
            if ((this.registerCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.registerCompleted(this, new registerCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://register.webservice.hnisi.com.cn", ResponseNamespace="http://register.webservice.hnisi.com.cn")]
        [return: System.Xml.Serialization.SoapElementAttribute("FindRegisterQuotaReturn")]
        public string[][] findRegisterQuota(string userID, string password, string annual, string departmentCode) {
            object[] results = this.Invoke("findRegisterQuota", new object[] {
                        userID,
                        password,
                        annual,
                        departmentCode});
            return ((string[][])(results[0]));
        }
        
        /// <remarks/>
        public void findRegisterQuotaAsync(string userID, string password, string annual, string departmentCode) {
            this.findRegisterQuotaAsync(userID, password, annual, departmentCode, null);
        }
        
        /// <remarks/>
        public void findRegisterQuotaAsync(string userID, string password, string annual, string departmentCode, object userState) {
            if ((this.findRegisterQuotaOperationCompleted == null)) {
                this.findRegisterQuotaOperationCompleted = new System.Threading.SendOrPostCallback(this.OnfindRegisterQuotaOperationCompleted);
            }
            this.InvokeAsync("findRegisterQuota", new object[] {
                        userID,
                        password,
                        annual,
                        departmentCode}, this.findRegisterQuotaOperationCompleted, userState);
        }
        
        private void OnfindRegisterQuotaOperationCompleted(object arg) {
            if ((this.findRegisterQuotaCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.findRegisterQuotaCompleted(this, new findRegisterQuotaCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
        
        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null) 
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if (((wsUri.Port >= 1024) 
                        && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                return true;
            }
            return false;
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    public delegate void registerCompletedEventHandler(object sender, registerCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class registerCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal registerCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public string[] Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((string[])(this.results[0]));
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    public delegate void findRegisterQuotaCompletedEventHandler(object sender, findRegisterQuotaCompletedEventArgs e);
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class findRegisterQuotaCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal findRegisterQuotaCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public string[] Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((string[])(this.results[0]));
            }
        }
    }
}

#pragma warning restore 1591

  (3)调用对方接口返回的数据

            WebApplication2.WebReference.RegisterService rs = new WebApplication2.WebReference.RegisterService();

            string[][] s = rs.findRegisterQuota("test1", "2222", "2010", "S44010300");

            Response.Write("<table border=\"1\">");

            for (int i = 0; i < s.Length; i++)

            {

                Response.Write("<tr>");

                string[] a = s[i];

                for (int j = 0; j < a.Length; j++)

                {

                    Response.Write("<td>" + Convert.ToString(a[j]) + "&nbsp;</td>");

                }

                Response.Write("</tr>");

            }

            Response.Write("</table>");
    [System.ServiceModel.ServiceContractAttribute(Namespace="http://register.webservice.hnisi.com.cn", ConfigurationName="ServiceReference1.RegisterService")]
    public interface RegisterService {
        
        [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
        [System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Rpc, Use=System.ServiceModel.OperationFormatUse.Encoded)]
        [return: System.ServiceModel.MessageParameterAttribute(Name="RegisterReturn")]
        string[] register(string userID, string password, string[] citizenInfos);
        
        [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
        [System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Rpc, Use=System.ServiceModel.OperationFormatUse.Encoded)]
        [return: System.ServiceModel.MessageParameterAttribute(Name="FindRegisterQuotaReturn")]
        string[] findRegisterQuota(string userID, string password, string annual, string departmentCode);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public interface RegisterServiceChannel : WebApplication1.ServiceReference1.RegisterService, System.ServiceModel.IClientChannel {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class RegisterServiceClient : System.ServiceModel.ClientBase<WebApplication1.ServiceReference1.RegisterService>, WebApplication1.ServiceReference1.RegisterService {
        
        public RegisterServiceClient() {
        }
        
        public RegisterServiceClient(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        }
        
        public RegisterServiceClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public RegisterServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public RegisterServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
        }
        
        public string[] register(string userID, string password, string[] citizenInfos) {
            return base.Channel.register(userID, password, citizenInfos);
        }
        
        public string[] findRegisterQuota(string userID, string password, string annual, string departmentCode) {
            return base.Channel.findRegisterQuota(userID, password, annual, departmentCode);
        }
    }
}

         (2)调用对方服务修改后的CS文件

代码 //------------------------------------------------------------------------------
// <auto-generated>
//     此代码由工具生成。
//     运行库版本:2.0.50727.3603
//
//     对此文件的更改可能会导致不正确的行为,并且如果
//     重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------

namespace WebApplication1.ServiceReference1 {
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="http://register.webservice.hnisi.com.cn", ConfigurationName="ServiceReference1.RegisterService")]
    public interface RegisterService {
        
        [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
        [System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Rpc, Use=System.ServiceModel.OperationFormatUse.Encoded)]
        [return: System.ServiceModel.MessageParameterAttribute(Name="RegisterReturn")]
        string[] register(string userID, string password, string[] citizenInfos);
        
        [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
        [System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Rpc, Use=System.ServiceModel.OperationFormatUse.Encoded)]
        [return: System.ServiceModel.MessageParameterAttribute(Name="FindRegisterQuotaReturn")]
        string[][] findRegisterQuota(string userID, string password, string annual, string departmentCode);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public interface RegisterServiceChannel : WebApplication1.ServiceReference1.RegisterService, System.ServiceModel.IClientChannel {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class RegisterServiceClient : System.ServiceModel.ClientBase<WebApplication1.ServiceReference1.RegisterService>, WebApplication1.ServiceReference1.RegisterService {
        
        public RegisterServiceClient() {
        }
        
        public RegisterServiceClient(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        }
        
        public RegisterServiceClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public RegisterServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public RegisterServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
        }
        
        public string[] register(string userID, string password, string[] citizenInfos) {
            return base.Channel.register(userID, password, citizenInfos);
        }
        
        public string[][] findRegisterQuota(string userID, string password, string annual, string departmentCode) {
            return base.Channel.findRegisterQuota(userID, password, annual, departmentCode);
        }
    }
}

  (3)调用对方接口返回的数据
            WebApplication1.ServiceReference1.RegisterServiceClient rs = new WebApplication1.ServiceReference1.RegisterServiceClient();
            string[][] s = rs.findRegisterQuota("test1", "2222", "2010", "S44010300");
            Response.Write("<table border=\"1\">");
            for (int i = 0; i < s.Length; i++)
            {
                Response.Write("<tr>");
                string[] a = s[i];
                for (int j = 0; j < a.Length; j++)
                {
                    Response.Write("<td>" + Convert.ToString(a[j]) + "&nbsp;</td>");
                }
                Response.Write("</tr>");
            }
            Response.Write("</table>");
        }
代码 //------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.2463
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

// 
// 此源代码是由 Microsoft.VSDesigner 1.1.4322.2463 版自动生成。
// 
namespace WebApplication1.WebReference {
    using System.Diagnostics;
    using System.Xml.Serialization;
    using System;
    using System.Web.Services.Protocols;
    using System.ComponentModel;
    using System.Web.Services;
    
    
    /// <remarks/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="RegisterServiceSoapBinding", Namespace="http://register.webservice.hnisi.com.cn")]
    public class RegisterService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        /// <remarks/>
        public RegisterService() {
            this.Url = "http://172.16.70.40:7001/rhsh/services/RegisterService";
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://register.webservice.hnisi.com.cn", ResponseNamespace="http://register.webservice.hnisi.com.cn")]
        [return: System.Xml.Serialization.SoapElementAttribute("RegisterReturn")]
        public string[] register(string userID, string password, string[] citizenInfos) {
            object[] results = this.Invoke("register", new object[] {
                        userID,
                        password,
                        citizenInfos});
            return ((string[])(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult Beginregister(string userID, string password, string[] citizenInfos, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("register", new object[] {
                        userID,
                        password,
                        citizenInfos}, callback, asyncState);
        }
        
        /// <remarks/>
        public string[] Endregister(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((string[])(results[0]));
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://register.webservice.hnisi.com.cn", ResponseNamespace="http://register.webservice.hnisi.com.cn")]
        [return: System.Xml.Serialization.SoapElementAttribute("FindRegisterQuotaReturn")]
        public string[] findRegisterQuota(string userID, string password, string annual, string departmentCode) {
            object[] results = this.Invoke("findRegisterQuota", new object[] {
                        userID,
                        password,
                        annual,
                        departmentCode});
            return ((string[])(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult BeginfindRegisterQuota(string userID, string password, string annual, string departmentCode, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("findRegisterQuota", new object[] {
                        userID,
                        password,
                        annual,
                        departmentCode}, callback, asyncState);
        }
        
        /// <remarks/>
        public string[] EndfindRegisterQuota(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((string[])(results[0]));
        }
    }
}

         (2)调用对方服务修改后的CS文件

代码 //------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.2463
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

// 
// 此源代码是由 Microsoft.VSDesigner 1.1.4322.2463 版自动生成。
// 
namespace WebApplication1.WebReference {
    using System.Diagnostics;
    using System.Xml.Serialization;
    using System;
    using System.Web.Services.Protocols;
    using System.ComponentModel;
    using System.Web.Services;
    
    
    /// <remarks/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="RegisterServiceSoapBinding", Namespace="http://register.webservice.hnisi.com.cn")]
    public class RegisterService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        /// <remarks/>
        public RegisterService() {
            this.Url = "http://172.16.70.40:7001/rhsh/services/RegisterService";
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://register.webservice.hnisi.com.cn", ResponseNamespace="http://register.webservice.hnisi.com.cn")]
        [return: System.Xml.Serialization.SoapElementAttribute("RegisterReturn")]
        public string[] register(string userID, string password, string[] citizenInfos) {
            object[] results = this.Invoke("register", new object[] {
                        userID,
                        password,
                        citizenInfos});
            return ((string[])(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult Beginregister(string userID, string password, string[] citizenInfos, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("register", new object[] {
                        userID,
                        password,
                        citizenInfos}, callback, asyncState);
        }
        
        /// <remarks/>
        public string[] Endregister(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((string[])(results[0]));
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://register.webservice.hnisi.com.cn", ResponseNamespace="http://register.webservice.hnisi.com.cn")]
        [return: System.Xml.Serialization.SoapElementAttribute("FindRegisterQuotaReturn")]
        public string[][] findRegisterQuota(string userID, string password, string annual, string departmentCode) {
            object[] results = this.Invoke("findRegisterQuota", new object[] {
                        userID,
                        password,
                        annual,
                        departmentCode});
            return ((string[][])(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult BeginfindRegisterQuota(string userID, string password, string annual, string departmentCode, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("findRegisterQuota", new object[] {
                        userID,
                        password,
                        annual,
                        departmentCode}, callback, asyncState);
        }
        
        /// <remarks/>
        public string[] EndfindRegisterQuota(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((string[])(results[0]));
        }
    }
}

     (3)调用对方接口返回数据时提示的错误

              WebApplication1.WebReference.RegisterService rs = new WebApplication1.WebReference.RegisterService();

              string[][] s = rs.findRegisterQuota("test1", "2222", "2010", "S44010300");

              Response.Write("<table border=\"1\">");

              for (int i = 0; i < s.Length; i++)

              {

                   Response.Write("<tr>");

                   string[] a = s[i];

                   for (int j = 0; j < a.Length; j++)

                   {

                       Response.Write("<td>" + Convert.ToString(a[j]) + "&nbsp;</td>");

                   }

                   Response.Write("</tr>");

              }

              Response.Write("</table>");

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载