如何通过 http 传输为回调 Web 服务配置 WCF

How do I configure WCF for a callback web service over http transport

我有一个 Java 异步网络服务,我认为它与大多数网络服务的工作方式不同。

Client: Send Request
Server: Send synchronous reply (acknowledge message)
Some time later
Server: Send asynchronous reply (data message)

我导入了 WSDL。我使用 wsDuelHttpBinding 设置端点。这没有用。然后我尝试了自定义绑定

<customBinding>
  <binding name="CustomBinding">
    <compositeDuplex clientBaseAddress="http://10.0.0.15:5555/"/>
    <oneWay packetRoutable="true" />
     <customTextMessageEncoding messageVersion="Soap11WSAddressing10" mediaType="text/xml" />
    <httpTransport />
  </binding>
</customBinding>

我修改了 CustomTextMessageEncoding 的 Microsoft 示例,这通过欺骗服务不理解的 WS 地址 headers 帮助我解决了一些问题。这些 headers 是客户端堆栈中的某些内容所必需的。

当前的问题是服务器发送的确认消息抛出以下异常。

A response was received from a one-way send over the underlying IRequestChannel. Make sure the remote endpoint has a compatible binding at its endpoint (one that contains OneWayBindingElement).

<oneWay/> 频道的替代方案是什么? 服务器代码不在我的控制范围内。

我可以让它工作的方法是在客户端同时拥有 WCF 服务器和 WCF 客户端。

首先我从服务上下载了WSDL,做了两份。我编辑了一个 WSDL,因此它只有来自服务的请求以及我收到的 'ACK' 回复,我删除了所有其他 <wsdl:operation/> 元素。由此我创建了一个 WCF 客户端。我编辑了另一个 WSDL,因此它只有异步回复操作,并由此创建了一个 WCF 服务。

客户端的 WCF 客户端部分执行以下操作

Client: Send Request
Server: Send synchronous reply (acknowledge message)

客户端的 WCF 服务器部分处理这个

Some time later
Server: Send asynchronous reply (data message)

客户端和服务的绑定现在只是 basicHttpsBinding。