简体   繁体   English

Web服务(ASMX)代理创建和reference.cs文件未生成

[英]Web service (ASMX) proxy creation and reference.cs file not generating

i have developed a web service(ASMX) using c# version 4.0. 我已经使用c#版本4.0开发了一个Web服务(ASMX)。 which will just upload file to our web server. 它将仅将文件上传到我们的Web服务器。 after deploying web service i create a win form project using .net v4.0 and there i create the proxy of my web service. 部署Web服务后,我使用.net v4.0创建了一个win表单项目,并在那里创建了Web服务的代理。 after that i test the file upload process and found it is working. 之后,我测试了文件上传过程,发现它正在工作。 the problem start when i create a win form apps using .net v2.0 and when i create a proxy there of same web service then i saw proxy created without Reference.cs file. 问题开始于当我使用.net v2.0创建Win Form应用程序时,并且当我在其中创建相同Web服务的代理时,我看到代理创建时没有Reference.cs文件。 that is why i am not being able to call that web service. 这就是为什么我无法调用该Web服务的原因。 i am not being able to understand why Reference.cs file is not created when i try to create proxy using dotnet version 2.0. 我无法理解为什么尝试使用dotnet 2.0版创建代理时未创建Reference.cs文件。

so just tell me is there version specific issue. 因此,请告诉我是否存在版本特定的问题。 i guess problem occur because i develop this web service on dotnet v4.0 and proxy created on dotnet v2.0. 我猜会出现问题,因为我在dotnet v4.0上开发了此Web服务,并在dotnet v2.0上创建了代理。 please explain why Reference.cs file is not created. 请说明为什么未创建Reference.cs文件。 also guide me how could i solve this problem. 也指导我如何解决这个问题。

here i am posting my web service code. 在这里,我发布了我的Web服务代码。 just have a look and tell me is there anything wrong. 看看,告诉我有什么问题。

 [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 FileUploader : System.Web.Services.WebService
    {

        [WebMethod]
        public string UploadFile(byte[] f, string fileName)
        {
            // the byte array argument contains the content of the file
            // the string argument contains the name and extension
            // of the file passed in the byte array
            string uploadFolder = HttpContext.Current.Request.PhysicalApplicationPath + @"UPS_New\LabelImages\" + fileName;
            try
            {
                // instance a memory stream and pass the
                // byte array to its constructor
                MemoryStream ms = new MemoryStream(f);

                // instance a filestream pointing to the
                // storage folder, use the original file name
                // to name the resulting file
                FileStream fs = new FileStream(uploadFolder, FileMode.Create);

                // write the memory stream containing the original
                // file as a byte array to the filestream
                ms.WriteTo(fs);
                // clean up
                ms.Close();
                fs.Close();
                fs.Dispose();
                // return OK if we made it this far
                return "OK";
            }
            catch (Exception ex)
            {
                // return the error message if the operation fails
                return ex.Message.ToString();
            }

        }

    }

please guide me...i am looking for suggestion. 请指导我...我正在寻找建议。 thanks 谢谢

This is version specific issue , when the client is build below the version of service then service cannot be accessed in the client .to make this work , build the service in 2.0 framework and then do the reference .it will then accept the service dll as it is build with same version as client. 这是version specific issue when the client is build below the version of service then service cannot be accessed in the client version specific issuewhen the client is build below the version of service then service cannot be accessed in the client 。要使其正常工作,请build the service in 2.0 framework and then do the reference然后它将接受服务dll作为与客户端版本相同。

in your case build the service in 2.0 first and then use that proxy which is build in 2.0 in your client. 在您的情况下,请先在2.0中构建服务,然后再在客户端中使用在2.0中构建的代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM