Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# web服务函数调用中out参数存在问题_C#_.net_Web Services - Fatal编程技术网

C# web服务函数调用中out参数存在问题

C# web服务函数调用中out参数存在问题,c#,.net,web-services,C#,.net,Web Services,我的web服务具有以下功能: [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET A

我的web服务具有以下功能:

[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
 public class Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";

        }

        [WebMethod]
        public void Login(string url, string id, out int ClientType, out int ClientID)
        {
            ClientID = 11;
            ClientType = 12;
        }
    }
}
在客户端,我在对象引用中看到它,没有out参数。这是全部代码,我对
公共void登录(string url、string id、out int ClientType、out int ClientID)感兴趣。
,我只想在客户端使用in,就像我在服务器端看到的那样。我应该在服务器上做什么更改,我将在没有更改的情况下使用它

namespace ConsoleApplication1.ServiceReference1 {


    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference1.Service1Soap")]
    public interface Service1Soap {

        // CODEGEN: Generating message contract since element name HelloWorldResult from namespace http://tempuri.org/ is not marked nillable
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/HelloWorld", ReplyAction="*")]
        ConsoleApplication1.ServiceReference1.HelloWorldResponse HelloWorld(ConsoleApplication1.ServiceReference1.HelloWorldRequest request);

        // CODEGEN: Generating message contract since element name url from namespace http://tempuri.org/ is not marked nillable
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Login", ReplyAction="*")]
        ConsoleApplication1.ServiceReference1.LoginResponse Login(ConsoleApplication1.ServiceReference1.LoginRequest request);
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class HelloWorldRequest {

        [System.ServiceModel.MessageBodyMemberAttribute(Name="HelloWorld", Namespace="http://tempuri.org/", Order=0)]
        public ConsoleApplication1.ServiceReference1.HelloWorldRequestBody Body;

        public HelloWorldRequest() {
        }

        public HelloWorldRequest(ConsoleApplication1.ServiceReference1.HelloWorldRequestBody Body) {
            this.Body = Body;
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.Runtime.Serialization.DataContractAttribute()]
    public partial class HelloWorldRequestBody {

        public HelloWorldRequestBody() {
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class HelloWorldResponse {

        [System.ServiceModel.MessageBodyMemberAttribute(Name="HelloWorldResponse", Namespace="http://tempuri.org/", Order=0)]
        public ConsoleApplication1.ServiceReference1.HelloWorldResponseBody Body;

        public HelloWorldResponse() {
        }

        public HelloWorldResponse(ConsoleApplication1.ServiceReference1.HelloWorldResponseBody Body) {
            this.Body = Body;
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")]
    public partial class HelloWorldResponseBody {

        [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
        public string HelloWorldResult;

        public HelloWorldResponseBody() {
        }

        public HelloWorldResponseBody(string HelloWorldResult) {
            this.HelloWorldResult = HelloWorldResult;
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class LoginRequest {

        [System.ServiceModel.MessageBodyMemberAttribute(Name="Login", Namespace="http://tempuri.org/", Order=0)]
        public ConsoleApplication1.ServiceReference1.LoginRequestBody Body;

        public LoginRequest() {
        }

        public LoginRequest(ConsoleApplication1.ServiceReference1.LoginRequestBody Body) {
            this.Body = Body;
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")]
    public partial class LoginRequestBody {

        [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
        public string url;

        [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=1)]
        public string id;

        public LoginRequestBody() {
        }

        public LoginRequestBody(string url, string id) {
            this.url = url;
            this.id = id;
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class LoginResponse {

        [System.ServiceModel.MessageBodyMemberAttribute(Name="LoginResponse", Namespace="http://tempuri.org/", Order=0)]
        public ConsoleApplication1.ServiceReference1.LoginResponseBody Body;

        public LoginResponse() {
        }

        public LoginResponse(ConsoleApplication1.ServiceReference1.LoginResponseBody Body) {
            this.Body = Body;
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")]
    public partial class LoginResponseBody {

        [System.Runtime.Serialization.DataMemberAttribute(Order=0)]
        public int ClientType;

        [System.Runtime.Serialization.DataMemberAttribute(Order=1)]
        public int ClientID;

        public LoginResponseBody() {
        }

        public LoginResponseBody(int ClientType, int ClientID) {
            this.ClientType = ClientType;
            this.ClientID = ClientID;
        }
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface Service1SoapChannel : ConsoleApplication1.ServiceReference1.Service1Soap, System.ServiceModel.IClientChannel {
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class Service1SoapClient : System.ServiceModel.ClientBase<ConsoleApplication1.ServiceReference1.Service1Soap>, ConsoleApplication1.ServiceReference1.Service1Soap {

        public Service1SoapClient() {
        }

        public Service1SoapClient(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        }

        public Service1SoapClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }

        public Service1SoapClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }

        public Service1SoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        ConsoleApplication1.ServiceReference1.HelloWorldResponse ConsoleApplication1.ServiceReference1.Service1Soap.HelloWorld(ConsoleApplication1.ServiceReference1.HelloWorldRequest request) {
            return base.Channel.HelloWorld(request);
        }

        public string HelloWorld() {
            ConsoleApplication1.ServiceReference1.HelloWorldRequest inValue = new ConsoleApplication1.ServiceReference1.HelloWorldRequest();
            inValue.Body = new ConsoleApplication1.ServiceReference1.HelloWorldRequestBody();
            ConsoleApplication1.ServiceReference1.HelloWorldResponse retVal = ((ConsoleApplication1.ServiceReference1.Service1Soap)(this)).HelloWorld(inValue);
            return retVal.Body.HelloWorldResult;
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        ConsoleApplication1.ServiceReference1.LoginResponse ConsoleApplication1.ServiceReference1.Service1Soap.Login(ConsoleApplication1.ServiceReference1.LoginRequest request) {
            return base.Channel.Login(request);
        }

        public int Login(string url, string id, out int ClientID) {
            ConsoleApplication1.ServiceReference1.LoginRequest inValue = new ConsoleApplication1.ServiceReference1.LoginRequest();
            inValue.Body = new ConsoleApplication1.ServiceReference1.LoginRequestBody();
            inValue.Body.url = url;
            inValue.Body.id = id;
            ConsoleApplication1.ServiceReference1.LoginResponse retVal = ((ConsoleApplication1.ServiceReference1.Service1Soap)(this)).Login(inValue);
            ClientID = retVal.Body.ClientID;
            return retVal.Body.ClientType;
        }
    }
}
命名空间控制台应用程序1.ServiceReference1{
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”,“4.0.0.0”)]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName=“ServiceReference1.Service1Soap”)]
公共接口服务SOAP{
//CODEGEN:从命名空间生成元素名HelloWorldResult之后的消息协定http://tempuri.org/ 不标记为零
[System.ServiceModel.OperationContractAttribute(操作=”http://tempuri.org/HelloWorld“,ReplyAction=“*”)]
ConsoleApplication1.ServiceReference1.HelloWorldResponse HelloWorld(ConsoleApplication1.ServiceReference1.HelloWorldRequest请求);
//CODEGEN:从命名空间中的元素名称url生成消息协定http://tempuri.org/ 不标记为零
[System.ServiceModel.OperationContractAttribute(操作=”http://tempuri.org/Login“,ReplyAction=“*”)]
ConsoleApplication1.ServiceReference1.LoginResponse登录(ConsoleApplication1.ServiceReference1.LoginRequest请求);
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”,“4.0.0.0”)]
[System.ComponentModel.EditorBrowsBalAttribute(System.ComponentModel.EditorBrowsBalState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
公共部分类HelloWorldRequest{
[System.ServiceModel.MessageBodyMemberAttribute(Name=“HelloWorld”,命名空间=”http://tempuri.org/“,顺序=0)]
公共控制台应用程序1.ServiceReference1.HelloWorldRequestBody;
公共HelloWorldRequest(){
}
公共HelloWorldRequest(ConsoleApplication1.ServiceReference1.HelloWorldRequestBody){
这个。身体=身体;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”,“4.0.0.0”)]
[System.ComponentModel.EditorBrowsBalAttribute(System.ComponentModel.EditorBrowsBalState.Advanced)]
[System.Runtime.Serialization.DataContractAttribute()]
公共部分类HelloWorldRequestBody{
公共HelloWorldRequestBody(){
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”,“4.0.0.0”)]
[System.ComponentModel.EditorBrowsBalAttribute(System.ComponentModel.EditorBrowsBalState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
公共部分类HelloWorldResponse{
[System.ServiceModel.MessageBodyMemberAttribute(Name=“HelloWorldResponse”,命名空间=”http://tempuri.org/“,顺序=0)]
公共控制台应用程序1.ServiceReference1.HelloWorldResponse主体;
公共HelloWorldResponse(){
}
公共HelloWorldResponse(控制台应用程序1.ServiceReference1.HelloWorldResponse主体){
这个。身体=身体;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”,“4.0.0.0”)]
[System.ComponentModel.EditorBrowsBalAttribute(System.ComponentModel.EditorBrowsBalState.Advanced)]
[System.Runtime.Serialization.DataContractAttribute(命名空间=”http://tempuri.org/")]
公共部分类HelloWorldResponseBody{
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false,Order=0)]
公共字符串HelloWorldResult;
公共HelloWorldResponseBody(){
}
公共HelloWorldResponseBy(字符串HelloWorldResult){
this.HelloWorldResult=HelloWorldResult;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”,“4.0.0.0”)]
[System.ComponentModel.EditorBrowsBalAttribute(System.ComponentModel.EditorBrowsBalState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
公共部分类登录请求{
[System.ServiceModel.MessageBodyMemberAttribute(Name=“Login”,命名空间=”http://tempuri.org/“,顺序=0)]
公共控制台应用程序1.ServiceReference1.LoginRequestBody;
公共登录请求(){
}
公共登录请求(ConsoleApplication1.ServiceReference1.LoginRequestBody){
这个。身体=身体;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”,“4.0.0.0”)]
[System.ComponentModel.EditorBrowsBalAttribute(System.ComponentModel.EditorBrowsBalState.Advanced)]
[System.Runtime.Serialization.DataContractAttribute(命名空间=”http://tempuri.org/")]
公共部分类LoginRequestBody{
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false,Order=0)]
公共字符串url;
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false,Order=1)]
公共字符串id;
公共登录请求体(){
}
公共登录请求正文(字符串url、字符串id){
this.url=url;
this.id=id;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”,“4.0.0.0”)]
[System.ComponentModel.EditorBrowsBalAttribute(System.ComponentModel.EditorBrowsBalState.Advanced)]
[System.ServiceModel.MessageContractAttribu
public class LoginResult
{
    public LoginResult(int clientType, int clientId)
    {
         ClientType = clientType;
         ClientID = clientId;
    }

    public int ClientType { get; set; };
    public int ClientID{ get; set; };
}

[WebMethod]        
public LoginResult Login(string url, string id)
{
    return new LoginResult( 11, 12 );      
}