WCF较新版本侦听先前版本的地址并引发异常 [英] WCF newer version to listen on previous version address and throw exception
问题描述
你好
我们在服务器上升级了服务,它在新的端点上进行侦听.我希望新服务在较旧的终结点上(在基本地址处)侦听并引发自定义异常.我该怎么做.
我尝试添加自定义消息过滤器并匹配To.AbsoluteUri.像这样的东西:
如果(!message.Headers.To.AbsoluteUri.EndsWith("4.1"))
抛出新的ServiceUpgradedException();
但是,客户端仅接收通用通信异常.
请咨询.
谢谢
您好,RajPCoop,
根据您的描述,我无法直接找到解决方案.
您从何处获取异常?并且您想抓住服务器端还是客户端?
我建议您看看通用通信异常中的内部异常.
如果要在客户端获取异常,则将为服务操作创建一个FaultContract:
#定义和指定故障
http://msdn.microsoft.com/en-us/library/ms733841 >
#发送和接收故障
http://msdn.microsoft.com/en-us/library/ms732013 >
希望有帮助.
Hello,
We upgraded our service on the server and it listens on a new endpoint. I would like the new service to listen on the older endpoint (at base address) and throw custom exception. How can I accomplish this.
I tried adding a custom message filter and match the To.AbsoluteUri. Something like this:
if (!message.Headers.To.AbsoluteUri.EndsWith("4.1"))
throw new ServiceUpgradedException();
However, the client is only receiving a generic communication exception.
Please advice.
Thank you
Hi RajPCoop,
According to your description I cannot reach the solution directly.
Where do you get the catch the exception? And do you want to catch at server-side or Client-side?
I suggest you to have a look at the inner exception in the generic communication exception.
If you want to get the exception at client side , you would create a FaultContract for the service operation:
#Defining and Specifying Faults
http://msdn.microsoft.com/en-us/library/ms733841
#Sending and Receiving Faults
http://msdn.microsoft.com/en-us/library/ms732013
Hope helpful.
这篇关于WCF较新版本侦听先前版本的地址并引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!