如何使用HTTPS设置WCF以使用Oracle Web服务?

时间:2014-02-04 12:52:41

标签: c# wcf web-services soap https

我目前正在使用WCF通过以下配置连接到我们的Java Web服务:

<bindings>
    <basicHttpBinding>
        <binding name="WebServicePortBindingHttp" maxReceivedMessageSize="500000">
            <security mode="TransportCredentialOnly">
                <transport clientCredentialType="Basic" proxyCredentialType="None" realm="" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>
<client>
    <endpoint address="http://host:port/url" binding="basicHttpBinding" bindingConfiguration="WebServicePortBindingHttp" contract="Namespace.WSPort" name="WebServicePort" />
</client>

这是使用普通的HTTP。即便如此,在我使用method suggested in this answer手动添加WSSE标头之前,服务器也不会授权我。一旦我开始这样做,我就能毫无困难地使用Web服务。

但是,在某些环境中,我的C#客户端必须连接的服务器使用HTTPS而不是HTTP。为此,上面给出的配置不起作用。首先,我必须将安全模式从TransportCredentialOnly更改为Transport,如下所示:

<binding name="WebServicePortBindingHttp" maxReceivedMessageSize="500000">
    <security mode="Transport">
        <transport clientCredentialType="Basic" proxyCredentialType="None" realm="" />
    </security>
</binding>

我在这些设置上尝试了很多变化,但所有发生的情况都是请求超时。当我使用Wireshark跟踪通信时,我可以看到服务器实际上正在响应,但我无法解释其响应,因为文本显示为乱码(我猜因为它是加密的)。

这是我导入WSDL时由Visual Studio自动创建的绑定配置:

<customBinding>
    <binding name="HTTPSoapBinding">
        <textMessageEncoding messageVersion="Soap11" />
        <httpsTransport />
    </binding>
</customBinding>

但这仍然不会改变行为。看起来微软和Oracle技术不仅仅是互操作。

请告知。

1 个答案:

答案 0 :(得分:0)

我是个白痴。还有其他事情导致超时!这种配置实际上有效:

<binding name="WebServicePortBindingHttp" maxReceivedMessageSize="500000">
    <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
    </security>
</binding>

奇怪的是,既然我已经确定了我超时的原因,那么网络服务似乎只接受clientCredentialType的任何值(到目前为止我已尝试过NoneBasicWindows,所有这些都有效。任何人都可以解释一下吗?

如果我把这个问题浪费在任何人的时间,我道歉。

相关问题