- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个第三方 API 的服务引用。我使用自定义 ChannelFactory 类来构建此 API 的 channel (类型为 System.ServiceModel.ClientBase 的 [WCF])。
我有一个自定义行为类(定义如下),我将其附加到此 channel 端点,以便处理从 API 返回的任何异常。在我正常的 .NET 代码中,这工作得很好。然而,在 Silverlight 中,仅当没有错误时才会调用 AfterReceiveReply 方法。
在这种情况下,当您尝试引用 eventArgs 的结果时,调用方法会遇到错误:'eventArgs.Result' 引发了类型为 'System.Reflection.TargetInitationException' 的异常
。
内部异常有:InnerException = {System.ServiceModel.CommunicationException:远程服务器返回错误:NotFound。
无论真实错误如何,我都会看到上述错误。在 Fiddler 中,我可以看到真正的错误返回。只是 channel 处理过程中隐藏了一些东西。下面是具有实际错误的 SOAP 响应的示例。 (一些值已被删除。)
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode><!-- REMOVED REAL CODE --></faultcode>
<faultstring><!-- REMOVED REAL FAULT --></faultstring>
<detail>
<!-- REMOVED DETAILS -->
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
我确信我还没有提供足够的相关信息,但我不知道所有内容都是相关的。在评论中询问更多信息。
我该如何调试这个?相同的代码可以在 .NET 中运行,但 Silverlight 不能很好地处理它。
下面是一些相关代码。
行为:
public class ExceptionMapperBehavior : IClientMessageInspector, IEndpointBehavior
{
public void AfterReceiveReply(ref Message reply, object correlationState)
{
//this is only called if there is no fault--not helpful!
if (reply == null || !reply.IsFault)
return;
//todo: make the exception pretty
}
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
//this is always called
return null;
}
}
channel 创建:
//...
var constructor = typeof(T).GetConstructor(new Type[] { typeof(Binding), typeof(EndpointAddress) });
var ret = (T)constructor.Invoke(new object[] { binding, endpointAddress });
ret.Endpoint.Behaviors.Add(new CredentialInserterEndpointBehavior(_authToken));
ret.Endpoint.Behaviors.Add(new ExceptionMapperBehavior());
return ret;
最佳答案
不知道这是否有帮助/有用。
默认情况下,silverlight 通过浏览器执行 HTTP 请求(包括 SOAP/REST)。通过这些调用,所有 HTTP/HTTPS 请求都将由 silverlight 客户端网络堆栈处理。
bool httpResult = WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
bool httpsResult = WebRequest.RegisterPrefix("https://", WebRequestCreator.ClientHttp);
关于.net - 为什么 Silverlight 不为我的自定义 ServiceModel.ClientBase<TChannel> channel 的行为调用 AfterReceiveReply?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4904702/
我正在 IIS 中运行我的 Web 项目。 这是一个4.0框架的APP。 我有一个 Service.svc,当我运行我的应用程序时收到此错误。 "Could not load type 'System
有一段时间,我在尝试使用 Azure 模拟器启动任何类型的应用程序时遇到以下错误: Microsoft Azure Tools: Method not found: 'Void Microsoft.W
我有一个由针对 .NET Standard 2.0 和 .NET Core 2.1.304 的项目组成的解决方案。在构建此解决方案时,它利用了旧的易受攻击版本的 System.ServiceModel
现象: 最近遇到了WCF 服务无法调用的错误,异常如下。 System.ServiceModel.ProtocolException, System.ServiceModel, Version=4
我在可移植类库中有一个接口(interface),启用了构建时的代码分析。当我用 WCF 服务的 ServceContract 和 OperationContract 标记它时,它开始从代码分析中抛出
我正在 sharepoint 上部署 webpart 并遇到一些错误。 webpart 使用来自 Web 服务的数据并使用 Microsoft Chart (Framework 3.5) 显示图表。当
我正在学习 WCF 并找到了 this article在一个简单的 WCF 示例中。 在下面的代码中(来自上面的文章),为什么System.ServiceModel.Dispatcher.Channe
我们有一个启动WCF服务器的应用程序,该应用程序从中读取数据。 它会启动,并且可以在所有Windows XP计算机上正常阅读。 但是,在Vista机器上,我们得到: System.ServiceMod
如果此问题在 stackOverflow 上出现两次,我们深表歉意 我试图在 Windows Server 2003 机器上运行 wcf 服务。我收到了 System.ServiceModel.Add
您好,当应用程序托管在服务器中时,我遇到了以下错误。该应用程序在本地盒子上运行良好。“已超过传入消息的最大消息大小配额 (100000000)。要增加配额,请在适当的绑定(bind)元素上使用 Max
我在 Win7(64 位)上使用 VS2010 express,我正在尝试使用 System.ServiceModel 但我收到一个错误,指出没有 ServiceModel System 命名空间:
我想在我的 Unity 应用程序中使用 WCF 服务(通过命名管道)。因此,我包括以下两个命名空间: using System.ServiceModel; using System.ServiceMo
我有以下代码: public partial class MyServiceClient : System.ServiceModel.ClientBase 派生,请使用此选项 m_MyClient.S
如何在我的应用程序中调试 system.servicemodel 类? 最佳答案 听起来您对调试 .NET 框架代码本身感兴趣吗?如果是这样,微软已经向公众发布了大部分 .NET 框架的源代码。 但是
我发现的所有与智能感知相关的问题似乎都与自定义配置设置有关。我正在尝试在已从 web.config 移出到 service.config 的 .net 标准部分上获得智能感知。 有办法吗? 最佳答案
我在客户端应用程序上遇到了这个异常,不知道如何解决这个问题。 当返回的数据(价格列表)超过 15MB,但适用于小于 15MB 的消息时,我遇到了这个异常。 错误消息: 接收对“http://local
我创建了一个 Core 3.1 应用程序,该应用程序使用基于 .net 标准 2.0 的 Web 服务。 在本地开发环境中,一切正常。在我将其部署到 UAT (IIS) 上之前,我收到以下异常: Ex
我添加了一个名为 http://192.168.5.180:8080/intg/CrmWebService.asmx 的服务引用。名称为 CrmWebProxy。 下面是代码行。 Microsoft.
当我将网站发布到我的 plesk 服务器时,我收到以下错误: Unrecognized configuration section system.serviceModel. 最佳答案 您的主机支持哪个
有什么方法可以访问“System.ServiceModel”客户端配置,即基于类 (dll) 项目中的 app.config? 最佳答案 ConfigurationManager.GetSection
我是一名优秀的程序员,十分优秀!