2

c# バージョン 4.0 を使用して Web サービス (ASMX) を開発しました。ファイルをウェブサーバーにアップロードするだけです。Web サービスをデプロイした後、.net v4.0 を使用して win フォーム プロジェクトを作成し、そこで Web サービスのプロキシを作成します。その後、ファイルのアップロード プロセスをテストし、動作していることを確認しました。問題は、.net v2.0 を使用して win フォーム アプリを作成したときに発生し、同じ Web サービスのプロキシを作成すると、Reference.cs ファイルなしでプロキシが作成されました。そのため、その Web サービスを呼び出すことができません。dotnet バージョン 2.0 を使用してプロキシを作成しようとすると、Reference.cs ファイルが作成されない理由がわかりません。

バージョン固有の問題があるか教えてください。このWebサービスをdotnet v4.0で開発し、プロキシをdotnet v2.0で作成したため、問題が発生したと思います。Reference.cs ファイルが作成されない理由を説明してください。また、この問題を解決する方法を教えてください。

ここに私の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 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();
            }

        }

    }

私を案内してください...私は提案を探しています。ありがとう

4

1 に答える 1

0

これはversion specific issue、.when 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 を受け入れます。

あなたの場合、最初に2.0でサービスをビルドしてから、クライアントで2.0でビルドされたプロキシを使用します。

于 2013-02-01T13:09:02.150 に答える