[英]Connecting legacy WSE client to WCF service… with no changes to client
我们有一个.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不匹配,因此无法在接收方处理带有操作'http://webservices.xyz.co.uk/xyz/DoTest'的消息。 这可能是由于合同不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配造成的。 检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如,消息,传输,无)。
很高兴收到任何输入
以上的一些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:// xyx / IService 。期望http:// xyz / productname 。 所以我将接口的名称更改为“ productname”,并且命名空间现在正确了。 然后,这产生了以下(新)错误:
将操作“ Authorise2”的请求消息主体反序列化时出错。 OperationFormatter遇到无效的消息正文。 预期会找到名称为“ Authorise2”且名称空间为“ http:// xzz”的节点类型“元素”。 找到名称为“ Authorise2”且名称空间为“ http:// xzz / productname”的节点类型“ Element”
该接口具有以下签名:
[ServiceContract(Namespace =“ http:// xyz”)]公共接口产品名{[OperationContract] AuthorizationDetails Authorise2(字符串用户名,字符串密码); }
那么如何添加'productname'扩展名呢? 更重要的是,我们如何摆脱它?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.