【问题标题】:Web Service returned error : Not FoundWeb 服务返回错误:未找到
【发布时间】:2013-06-28 17:25:15
【问题描述】:

我正在使用的 Web 服务返回了 Web 异常。从 Silverlight 应用程序调用服务。基本上我正在尝试将 eps 文件转换为 png 。在本地主机上一切正常,但是当我部署在 Web 服务器上时,我收到了这个错误。 Silverlight 代码是 --

  private void btnUploadImage_Click(object sender, RoutedEventArgs e)
        {
            string fileextn = string.Empty;
            OpenFileDialog openDialog = new OpenFileDialog();
            if (openDialog.ShowDialog() == true)
            {
                try
                {
                    string fileExtension = openDialog.File.Extension.ToString();
                    if (fileExtension.Contains("jpeg") || fileExtension.Contains("jpg") || fileExtension.Contains("png") || fileExtension.Contains("tif") || fileExtension.Contains("tiff") || fileExtension.Contains("bmp") || fileExtension.Contains("gif"))
                    {

                        using (Stream stream = openDialog.File.OpenRead())
                        {
                            HtmlPage.Window.Invoke("showProcessingAndBlockUI");
                            // Don't allow really big files (more than 2 MB).
                            if (stream.Length < 5 * 1024 * 1025)
                            {
                                MemoryStream tempStream = new MemoryStream();
                                byte[] data = new byte[stream.Length];
                                stream.Position = 0;
                                stream.Read(data, 0, (int)stream.Length);
                                tempStream.Write(data, 0, (int)stream.Length);
                                stream.Close();
                                ProductConfiguratorServiceClient pcs = new ProductConfiguratorServiceClient();
                                string virtualpath = HelperClass.GetVirtual();
                                pcs.Endpoint.Address = new System.ServiceModel.EndpointAddress(virtualpath + "/Services/ProductConfiguratorService.svc/basic");
                                pcs.GetFormattedImageCompleted += new EventHandler<GetFormattedImageCompletedEventArgs>(pcs_GetFormattedImageCompleted);
                                pcs.GetFormattedImageAsync(data);
                                pcs.CloseAsync();
                                tempStream.Close();
                            }
                            else
                            {
                                MessageBox.Show("Files must be less than 5 MB.");
                            }
                        }
                    }
                    else if (openDialog.File.Extension.Contains("eps"))
                    {
                        HtmlPage.Window.Invoke("showProcessingAndBlockUI");
                        using (Stream stream = openDialog.File.OpenRead())
                        {
                            if (stream.Length < 5 * 1024 * 1025)
                            {
                                MemoryStream tempStream = new MemoryStream();
                                byte[] data = new byte[stream.Length];
                                stream.Position = 0;
                                stream.Read(data, 0, (int)stream.Length);
                                tempStream.Write(data, 0, (int)stream.Length);
                                stream.Close();
                                ProductConfiguratorServiceClient pcs = new ProductConfiguratorServiceClient();
                                string virtualpath = HelperClass.GetVirtual();
                                pcs.Endpoint.Address = new System.ServiceModel.EndpointAddress(virtualpath +                                                                                              "/Services/ProductConfiguratorService.svc/basic");
                                pcs.GetEpsFileIntoPngCompleted += new EventHandler<GetEpsFileIntoPngCompletedEventArgs>(pcs_GetEpsFileIntoPngCompleted);
                                pcs.GetEpsFileIntoPngAsync(data);
                                tempStream.Close();
                            }
                            else
                            {
                                MessageBox.Show("Files must be less than 5 MB.");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please Check the Image Format.");
                    }
                }
                catch (Exception)
                {
                    HtmlPage.Window.Invoke("hideBlockUI");
                    MessageBox.Show("Somr Error Occured, Please Try Again Later .");
                }
            }

        }

        void pcs_GetEpsFileIntoPngCompleted(object sender, GetEpsFileIntoPngCompletedEventArgs e)
        {
                busi.CurrentlySelectedOverlayImage.UploadedImageStream = e.Result;
                busi.CurrentlySelectedOverlayImage.ImageFileType = "png";
                RefreshStatus();
                busi.CurrentlySelectedOverlayImageChanged = true;
                HtmlPage.Window.Invoke("hideBlockUI");
        }

        void pcs_GetFormattedImageCompleted(object sender, GetFormattedImageCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null)
                {
                    MessageBox.Show(e.Error.ToString());
                }
                else
                {
                    busi.CurrentlySelectedOverlayImage.UploadedImageStream = e.Result;
                    busi.CurrentlySelectedOverlayImage.ImageFileType = "jpeg";
                    RefreshStatus();
                    busi.CurrentlySelectedOverlayImageChanged = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            //throw new NotImplementedException();
        }

错误在System.Net.Browser.BrowserHttpWebRequest

请问这是什么问题?

【问题讨论】:

    标签: c# asp.net web-services silverlight-4.0


    【解决方案1】:

    这可能与这条线有关。

    pcs.Endpoint.Address = new System.ServiceModel.EndpointAddress(virtualpath + 
    

    你错过了它的其余部分。 很确定这是一个编译错误。

    所以要么这个错误被吃掉并且通用的错误正在弹出,要么你还有其他一些问题。

    【讨论】:

    • 如您所见,我提供了完整的地址。那我应该这样做吗?
    • 您上面列出的代码中存在编译错误。没有问题。它在这个条件中 else if (openDialog.File.Extension.Contains("eps"))
    • 那么它怎么可能在 localhost 上成功运行呢?我对此感到困惑,如果可能的话,请提供一种解决此问题的方法。
    • 也许您正在运行旧版本,或者您发布了损坏的代码,但您运行的代码很好,或者您本地计算机上的代码与生产代码不同...。不胜枚举。我告诉你这是一个语法错误。
    • 感谢您的帮助。我会考虑你的意见来解决这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-05
    • 2014-09-07
    • 2010-11-07
    • 2011-01-26
    • 2011-05-05
    • 1970-01-01
    • 2010-10-23
    相关资源
    最近更新 更多