【问题标题】:Connecting legacy WSE client to WCF service... with no changes to client将旧版 WSE 客户端连接到 WCF 服务...不更改客户端
【发布时间】:2011-09-08 20:34:06
【问题描述】:

我们有一个 .NET 2.0 Forms App 客户端,它使用 WSE 连接到 asmx Web 服务。

我们希望将服务升级到 WCF 并使用 VS 2010 和 .NET 4,但是我们无法强制现有(企业)客户更新他们的客户端软件/框架等,所以我们在升级服务的唯一方法是保持向后兼容性。

我们可以在客户端更新 app.config,但不能更新可执行文件,这意味着我们无法添加新的服务引用。

我们尝试将 WCF 服务配置为接受来自客户端应用程序的调用,而不对客户端进行更改,但未成功。我怀疑这甚至可以做到;当然,在客户端中添加一个新的引用会使其工作,但使用现有的引用并尝试用新服务“伪造”它是行不通的。

服务端的配置如下:

<bindings>
  <basicHttpBinding>
    <binding name="OnePointOneBinding" bypassProxyOnLocal="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServiceBehaviour" name="xyz.Services.xyzService">
    <endpoint binding="basicHttpBinding" bindingConfiguration="OnePointOneBinding"
      name="BasicBindingSvc" contract="xyz.Services.IxyzService" />
  </service>
</services>

我们得到的错误是:

由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action 'http://webservices.xyz.co.uk/xyz/DoTest' 的消息。这可能是因为合约不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。

很高兴收到任何意见

【问题讨论】:

  • 您没有显示 WSE 配置,因此您几乎不会得到任何帮助。

标签: wcf wse


【解决方案1】:

上述的一些 WSE 细节:

来自 wse3PolicyCache.config:

<policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy">
  <extensions>
    <extension name="usernameOverTransportSecurity" type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <extension name="requireActionHeader" type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </extensions>
  <policy name="usernameTokenSecurity">
    <usernameOverTransportSecurity />
    <requireActionHeader />
  </policy>
</policies>

来自客户端 app.config:

<microsoft.web.services3>
    <security>
        <!-- Specifies the time buffer used by WSE to determine when a SOAP message is valid. -->
        <timeToleranceInSeconds value="7200" />
        <!-- Defines the default number of seconds that a SOAP message is valid after its creation. -->
        <defaultTtlInSeconds value="300" />
    </security>
    <policy fileName="wse3policyCache.config" />
</microsoft.web.services3>

我想不出还有什么相关的......

编辑:

所以我做了一些挖掘,发现 WCF 服务的 WSDL 包含接口的名称(我将其命名为“IService”)被附加到命名空间中,使其成为http://x.y.x/IService,当客户端期待http://x.y.z/productname。所以我将接口的名称更改为“productname”,命名空间现在是正确的。这然后给出了以下(新)错误:

反序列化操作“Authorise2”的请求消息正文时出错。 OperationFormatter 遇到无效的消息正文。 预计会找到名称为“Authorise2”和命名空间“http://x.z.z”的节点类型“元素”。 找到名称为“Authorise2”和命名空间“http://x.z.z/productname”的节点类型“元素”

接口有如下签名:

[ServiceContract(Namespace = "http://x.y.z")] 公共接口产品名称 { [运营合同] AuthorisationDetails Authorise2(字符串用户名,字符串密码); }

那么如何添加“产品名称”扩展?更重要的是,我们怎样才能摆脱它?

【讨论】:

  • 所以我进行了一些挖掘,发现 WCF 服务的 WSDL 包含附加到命名空间的接口名称(我将其命名为“IService”),使其成为x.y.x/IService,当客户期待x.y.z/productname
猜你喜欢
  • 2010-11-17
  • 2011-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-06
  • 2019-10-27
相关资源
最近更新 更多