客户端和服务器端之间的 WCF 服务契约名称不匹配
我试图将我的 Web 应用程序与两个 WCF 服务集成,这两个服务具有相同的服务合同名称,但位于两个不同的地址。问题是我想在一个 DLL 中为这两个服务创建代理,但是这是不可行的,因为两个合约具有相同的名称,我尝试使用类似嵌套的名称空间,而且它也不起作用,因为代理托管在一个除了Web项目之外的单独的DLL,我更改了一个服务合同的名称,但出现了此错误:
带有操作的消息 'http://ws.aramex.net/ShippingAPI/v1/RateCalculateService/CalculateRate' 由于 ContractFilter 不匹配,无法在接收方进行处理 在 EndpointDispatcher 处。这可能是因为合同 不匹配(发送者和接收者之间的操作不匹配)或 发送者和接收者之间的绑定/安全不匹配。查看 发送者和接收者具有相同的合同和相同的绑定 (包括安全要求,例如消息、传输、无)。
是否有可能在客户端使用与服务器中不同的合约名称?
端点:
<client>
<endpoint address="http://ws.dev.aramex.net/shippingapi/shipping/service_1_0.svc"
binding="basicHttpBinding" bindingConfiguration="basic"
contract="Service_1_0" name="BasicHttpBinding_Service_1_0" />
<endpoint address="http://ws.aramex.net/shippingapi/ratecalculator/service_1_0.svc"
binding="basicHttpBinding" bindingConfiguration="basic"
contract="RateCalculateService" name="BasicHttpBinding_Service_1_0" />
</client>
第二个端点的原始合约名称是“Service_1_0”
I was trying to integrate my Web application with two WCF services provided with the same Service Contracts names but in two different addresses. The thing is I want to create proxies for both services within one DLL, but that was not doable as both contracts hold the same name, I tried to use like nested name spaces, also it didn't work as the proxies are hosted in a separate DLL other than the web project, I changed the name of one service contract, but I got this error:
The message with Action
'http://ws.aramex.net/ShippingAPI/v1/RateCalculateService/CalculateRate'
cannot be processed at the receiver, due to a ContractFilter mismatch
at the EndpointDispatcher. This may be because of either a contract
mismatch (mismatched Actions between sender and receiver) or a
binding/security mismatch between the sender and the receiver. Check
that sender and receiver have the same contract and the same binding
(including security requirements, e.g. Message, Transport, None).
Is it possible by any means to have different contract name in client side than the one in the server?
endpoints:
<client>
<endpoint address="http://ws.dev.aramex.net/shippingapi/shipping/service_1_0.svc"
binding="basicHttpBinding" bindingConfiguration="basic"
contract="Service_1_0" name="BasicHttpBinding_Service_1_0" />
<endpoint address="http://ws.aramex.net/shippingapi/ratecalculator/service_1_0.svc"
binding="basicHttpBinding" bindingConfiguration="basic"
contract="RateCalculateService" name="BasicHttpBinding_Service_1_0" />
</client>
The original contract name of the second endpoint was "Service_1_0"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您说的是相同的服务合同名称吗?您的意思是服务合同是相同的吗?
如果是这样,为什么不只指定两个具有不同名称和相同约定的端点:
然后指定端点名称(对于上面的示例,
BasicHttpBinding_Service_1_0_Instance1
或BasicHttpBinding_Service_1_0_Instance2
)作为参数endpointConfigurationName
到适当的代理类构造函数重载。You say the same Service Contract names? Do you mean the service contracts are identical?
If so, why not just specify two endpoints with different names and the same contract:
Then specify the endpoint name (
BasicHttpBinding_Service_1_0_Instance1
orBasicHttpBinding_Service_1_0_Instance2
for the above example) as the parameterendpointConfigurationName
to the appropriate proxy class constructor overload.虽然不是 WCF 专家,但为什么不通过创建 2 个服务来代理原始服务并为每个服务创建唯一的合约名称来解决这个问题呢?
Not a WCF expert, but why not work around this by creating 2 services that proxy the original services and create unique contract name for each?
引用 WSDL 文件时,您应该执行以下操作:
when referencing your WSDL file you should have done the following: