Consume a Web Service that requires WS-Security from ASP.NET 4.5 Application

故事扮演 提交于 2019-12-03 03:31:26
TrevorBrooks

There is general information on all types of security and bindings here: http://msdn.microsoft.com/en-us/library/system.servicemodel.wshttpbinding.aspx

But you need to configure WS-Security in your web.config file as outlined here: http://msdn.microsoft.com/en-us/library/ms734663.aspx

For example, instead of <basicHttpBinding> you might use something like:

    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_ICalculator" />
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator"
            contract="ServiceReference1.ICalculator" name="WSHttpBinding_ICalculator">
            <identity>
                <userPrincipalName value="migree@redmond.corp.microsoft.com" />
            </identity>
        </endpoint>
    </client>

Here's a nice little tutorial on the subject as well: http://msdn.microsoft.com/en-us/library/ff648431.aspx

Hope this helps!

You can use custom binding like this:

<customBinding>
    <binding name="WSHttpBinding_TereService">
      <security authenticationMode="CertificateOverTransport" 
                defaultAlgorithmSuite="Basic128Rsa15" 
                enableUnsecuredResponse="true">
      </security>
      <textMessageEncoding messageVersion="Soap11WSAddressing10"/>
      <httpsTransport/>
    </binding>
</customBinding>

And setting your httpsTransport options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!