我们必须连接到第三方SOAP服务,我们正在使用WCF这样做。该服务是使用Apache AXIS开发的,我们无法控制它,也没有影响它改变它的工作方式。 我们看到的问题是它希望使用Web服务安全性格式化请求,因此我们正在进行所有正确的签名等。但是,第三方的响应并不安全。如果我们嗅探电线,我们会看到响应很好(虽然没有任何时间戳,签名等)。 基础.NET组件将此视为错误,因为它将其视为安全问题,因此我们实际上并未收到SOAP响应。有没有办法配置WCF框架来发送安全请求,但不期望响应中的安全字段?看看OASIS规范,它似乎没有强制要求回应必须是安全的。
有关信息,这是我们看到的例外情况:
我们收到的例外是:
System.ServiceModel.Security.MessageSecurityException was caught
Message="Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security."
Source="mscorlib"
StackTrace:
Server stack trace:
at System.ServiceModel.Security.TransportSecurityProtocol.VerifyIncomingMessageCore(Message& message, TimeSpan timeout)
at System.ServiceModel.Security.TransportSecurityProtocol.VerifyIncomingMessage(Message& message, TimeSpan timeout)
at System.ServiceModel.Security.SecurityProtocol.VerifyIncomingMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
顺便说一下,我看过很多帖子都说如果你把时间戳留下来,那么就不会有安全字段了。这不是一个选项 - 我们正在与之通信的服务强制要求时间戳。
答案 0 :(得分:3)
Microsoft现在提供了此功能的修补程序。
答案 1 :(得分:2)
有趣的是你应该问这个问题。一年前我问微软如何做到这一点。当时,使用.NET 3.0,这是不可能的。不确定3.5世界是否有所改变。但是,不,没有物理方法可以为请求添加安全性并将响应留空。
在我以前的雇主中,我们使用了一个模型,该模型需要使用请求证书的WS-Security标头,但响应是不安全的。
您可以使用ASMX Web服务和WSE执行此操作,但不能使用WCF v3.0。
答案 2 :(得分:2)
很有可能你无法独自完成配置。我不得不与Axxis进行一些集成工作(我们的结尾是WSE3 - WCF的祖先),我不得不编写一些代码并将其粘贴到WSE3的管道中,以便在将Axxis传递给WSE3之前对其进行按摩。好消息是将这些处理程序添加到管道中是相当简单的,一旦在处理程序中,您只需获取SoapMessage的实例,并且可以使用它执行任何操作(例如,删除时间戳)