使用WS-Addressing请求ASMX服务



我们有ASMXweb服务。我知道,它已经过时了,但我们必须保留它。所以,我有一个客户端应用程序,它将请求(带有WS-Addressing标头)发送到该服务的方法:

someASMX.someSoapClient client = new someASMX.someSoapClient();
using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
{
    OperationContext.Current.OutgoingMessageHeaders.ReplyTo = new EndpointAddress("https://address2answer");
    OperationContext.Current.OutgoingMessageHeaders.MessageId = new System.Xml.UniqueId(Guid.NewGuid());
    client.someMethod("1", "test");
}

但请求失败,出现以下异常:

Addressing Version 'AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)' does not support adding WS-Addressing headers

那么ASMX web服务甚至支持WS-Addressing吗?如果他们这样做了,我应该怎么做才能让它接受带有WS-Addressing标头的请求?

我在客户端的app.config中有以下绑定:

<basicHttpBinding>
  <binding name="someSoap">
    <security mode="Transport" />
  </binding>
</basicHttpBinding>
<endpoint address="https://someserver:443/some.asmx"
    binding="basicHttpBinding" bindingConfiguration="someSoap"
    contract="someNS.someSoap" name="someSoap" />

我怀疑它必须与绑定有关,但这是在Visual Studio中添加Service Reference时自动生成的东西——为什么当时是这样生成的?也许我需要更改ASMX服务方面的某些内容?

糟糕的是,我没有对ASMX做足够的研究——它不支持wsHttpBinding。所以我们应该去掉它,创建一个带有wsHttpBinding端点的WCF服务。

最新更新