【问题标题】:The remote server returned an error: NotFound远程服务器返回错误:NotFound
【发布时间】:2023-03-20 09:37:01
【问题描述】:

我有一个 Silverlight 应用程序,它在我的 asp.net 应用程序中使用 WCF 服务。silverlight 应用程序以墨水笔划的形式保存“绘图”。这些笔画采用 xaml 的形式(可能有点大),我将其转换为字符串并发送到服务以将字符串保存到 sql server。 (基本上和这个应用程序http://msdn.microsoft.com/en-us/magazine/cc721604.aspx做相同类型的事情)。

这很有效,当绘图相对较小时,我可以看到我的服务方法被击中,但如果绘图变大,我会收到这个很大的错误,并且服务方法断点永远不会被击中。似乎我通过了大小阈值,但我不知道我是否正确或要更改什么来解决问题。

我已经搜索了 google 和 SO,但没有成功,因此我们将不胜感激。提前致谢。

我的服务:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class DrawingService: IDrawingService
{
    #region IDrawingService Members
    public bool SaveEvalAreaDrawing(int EvalAreaId, string xmlToSave)
    {
        return true;
    }

    public bool SaveEvalItemDrawing(int EvalItemId, string xmlToSave)
    {
        return true;
    }

    public string GetEvalAreaDrawing(int EvalAreaId, string xmlToSave)
    {

        return "you got the eval drawing!";
    }

    public string GetEvalItemDrawing(int EvalItemId, string xmlToSave)
    {

        return "you got the eval item drawing!";
    }

    #endregion
}

我的带有服务 web.config 的 asp.net 应用程序

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyNameSpace.Services.DrawingServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <customBinding>
    <binding name="customBinding0">
      <binaryMessageEncoding />
      <httpTransport>
        <extendedProtectionPolicy policyEnforcement="Never" />
      </httpTransport>
    </binding>
  </customBinding>
  <wsHttpBinding>
    <binding name="wsPlainBinding" maxBufferPoolSize="2147483647"
      maxReceivedMessageSize="2147483647">
      <security mode="None">
        <transport clientCredentialType="None">
          <extendedProtectionPolicy policyEnforcement="Never" />
        </transport>
        <message clientCredentialType="None" negotiateServiceCredential="false"
          establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
  <service behaviorConfiguration="HSD.ECERS.Services.DrawingServiceBehavior"
    name="HSD.ECERS.Services.DrawingService">
    <endpoint address="Services" binding="wsHttpBinding" bindingConfiguration="wsPlainBinding"
      name="wsPlainHttp" contract="HSD.ECERS.Services.IDrawingService" />
    <endpoint address="mex" binding="mexHttpBinding" name="wsdl"
      contract="IMetadataExchange" />
  </service>
</services>

ServiceReferences.ClientConfig

<configuration>
<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="wsPlainHttp">
                <textMessageEncoding messageVersion="Default" writeEncoding="utf-8" />
                <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
                    <extendedProtectionPolicy policyEnforcement="Never" />
                </httpTransport>
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:41594/Services/DrawingService.svc/Services"
            binding="customBinding" bindingConfiguration="wsPlainHttp"
            contract="EvalDrawingService.IDrawingService" name="wsPlainHttp" />
    </client>
</system.serviceModel>
</configuration>

VS 显示错误的地方

public bool EndSaveEvalAreaDrawing(System.IAsyncResult result) {
            object[] _args = new object[0];
            bool _result = ((bool)(base.EndInvoke("SaveEvalAreaDrawing", _args, result))); // Here is where is popping up
            return _result;
        }

异常

{System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
   --- End of inner exception stack trace ---
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
   at EvaluaionAncillaryControl.EvalDrawingService.DrawingServiceClient.DrawingServiceClientChannel.EndSaveEvalAreaDrawing(IAsyncResult result)
   at EvaluaionAncillaryControl.EvalDrawingService.DrawingServiceClient.EvaluaionAncillaryControl.EvalDrawingService.IDrawingService.EndSaveEvalAreaDrawing(IAsyncResult result)
   at EvaluaionAncillaryControl.EvalDrawingService.DrawingServiceClient.OnEndSaveEvalAreaDrawing(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}

【问题讨论】:

  • 实际错误内容在哪里?
  • @Mr.失望 - 很抱歉最初没有发布它,因为从我读过的所有内容来看,这是一个非常普遍且无益的错误,但我会编辑我的帖子。

标签: silverlight wcf


【解决方案1】:

您是否尝试过开启WCF Tracing?我不确定这是否适用于 Silverlight(鉴于 Silverlight 在本地硬盘方面有很多安全限制),因此您可能需要设置一个简单的无 silverlight 客户端并在打开诊断的情况下重现呼叫。

编辑:或者,可以是 readerQuotas 的 maxArrayLength 成员...

【讨论】:

    【解决方案2】:

    尝试增加 readerQuotas -- 在 binding 元素中添加此元素

    <readerQuotas maxStringContentLength="2147483647" />
    

    http://msdn.microsoft.com/en-us/library/ms731325.aspx

    【讨论】:

    • 或者,它可能是 maxArrayLength。图像可能被序列化为数组。
    • 我们赢了!非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 2012-08-31
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    相关资源
    最近更新 更多