C# 远程服务器返回错误:NotFound。Silverlight + WCF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9335789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 06:57:35  来源:igfitidea点击:

The remote server returned an error: NotFound. Silverlight + WCF

c#wcfsilverlight

提问by GrzesiekO

I'm trying to call web service for few hours. I have added clientaccesspolicy.xml:

我正在尝试调用 Web 服务几个小时。我添加了clientaccesspolicy.xml:

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

and crossdomain.xml:

和 crossdomain.xml:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>

to root directory of my web site. Web service is called from IIS, and it's working here.

到我网站的根目录。Web 服务是从 IIS 调用的,它在这里工作。

But when I'm trying to call my wcf web service from silverlight application I get this error:

但是当我尝试从 Silverlight 应用程序调用我的 wcf Web 服务时,我收到此错误:

The remote server returned an error: NotFound.

远程服务器返回错误:NotFound。

This is log from Fiddler:

这是 Fiddler 的日志:

a:InternalServiceFaultThe server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

a:InternalServiceFault 由于内部错误,服务器无法处理请求。有关错误的详细信息,请在服务器上打开 IncludeExceptionDetailInFaults(从 ServiceBehaviorAttribute 或从 <serviceDebug> 配置行为)以将异常信息发送回客户端,或者根据 Microsoft .NET Framework 打开跟踪3.0 SDK 文档并检查服务器跟踪日志。

This is code, when I get an error:

这是代码,当我收到错误时:

public int EndUserExist(System.IAsyncResult result) {
       object[] _args = new object[0];
       int _result = ((int)(base.EndInvoke("UserExist", _args, result))); //Here
       return _result;
            }

What am I doing wrong?

我究竟做错了什么?

采纳答案by GrzesiekO

All right ;) Now it's working. I turned on debug in web.config so I got exception message in Fiddler. I need to set identity user in pool on IIS for sql database.

好的;) 现在它可以工作了。我在 web.config 中打开了调试,所以我在 Fiddler 中收到了异常消息。我需要在 IIS 的池中为 sql 数据库设置身份用户。

回答by bperreault

Look in your web.config for this text: IncludeExceptionDetailInFaults set that to true. Then run your service request again and watch Fiddler this time it will tell you what you need to know. May be anything from a SQL error to a null reference. :-)

在您的 web.config 中查找此文本:IncludeExceptionDetailInFaults 将其设置为 true。然后再次运行您的服务请求并观看 Fiddler 这次它会告诉您需要了解的内容。可能是从 SQL 错误到空引用的任何内容。:-)

回答by Mustafa ?zkan

In your mobile device, go to wifi settings and edit current wifi connection. Set proxy "Automatically detect settings".

在您的移动设备中,转到 wifi 设置并编辑当前的 wifi 连接。设置代理“自动检测设置”。