客户端和服务器端之间的 WCF 服务契约名称不匹配

发布于 2024-12-15 06:36:29 字数 1080 浏览 0 评论 0原文

我试图将我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ぶ宁プ宁ぶ 2024-12-22 06:36:29

我试图将我的 Web 应用程序与两个 WCF 服务集成,这两个 WCF 服务具有相同的服务合同名称,但位于两个不同的地址。

您说的是相同的服务合同名称吗?您的意思是服务合同是相同的吗?

如果是这样,为什么不只指定两个具有不同名称和相同约定的端点:

<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_Instance1" />

      <endpoint address="http://ws.aramex.net/shippingapi/ratecalculator/service_1_0.svc"
         binding="basicHttpBinding" bindingConfiguration="basic"
         contract="Service_1_0" name="BasicHttpBinding_Service_1_0_Instance2" />
</client>

然后指定端点名称(对于上面的示例,BasicHttpBinding_Service_1_0_Instance1BasicHttpBinding_Service_1_0_Instance2)作为参数endpointConfigurationName 到适当的代理类构造函数重载。

I was trying to integrate my Web application with two WCF services provided with the same Service Contracts names but in two different addresses.

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:

<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_Instance1" />

      <endpoint address="http://ws.aramex.net/shippingapi/ratecalculator/service_1_0.svc"
         binding="basicHttpBinding" bindingConfiguration="basic"
         contract="Service_1_0" name="BasicHttpBinding_Service_1_0_Instance2" />
</client>

Then specify the endpoint name (BasicHttpBinding_Service_1_0_Instance1 or BasicHttpBinding_Service_1_0_Instance2 for the above example) as the parameter endpointConfigurationName to the appropriate proxy class constructor overload.

雨的味道风的声音 2024-12-22 06:36:29

虽然不是 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?

十秒萌定你 2024-12-22 06:36:29

引用 WSDL 文件时,您应该执行以下操作:

  • 右键单击​​“服务引用”
  • 添加服务引用
  • 在消息/文本框中输入 WSDL 的本地路径并搜索它
  • 在同一窗口中有一个按钮“高级” ,点击它。
  • 选中指定“始终生成消息合同”的复选框

when referencing your WSDL file you should have done the following:

  • Right click on "Service Reference"
  • Add Service Reference
  • In the Message/Text box enter the local path of the WSDL and search for it
  • In the same window there is a button "Advanced", click on it.
  • Check the check box that specifies "Always generate message contracts”
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文