WCF代理中实现的WS-Security [英] implementing Ws-security within WCF proxy

查看:136
本文介绍了WCF代理中实现的WS-Security的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经进口的轴基于WSDL到VS 2008项目作为服务引用。

I have imported an axis based wsdl into a VS 2008 project as a service reference.

我需要能够通过安全的详细信息,如用户名/密码,现时值来调用基于轴的服务。

I need to be able to pass security details such as username/password and nonce values to call the axis based service.

我看着这样做是为了WSE,这是我了解世界恨(没有问题存在)

I have looked into doing it for wse, which i understand the world hates (no issues there)

我有WCF的经验非常少,但工作如何调用物理端点现在,由于这样,但不知道如何成立的SOAPHeaders如下所示的模式:

I have very little experience of WCF, but have worked how to physically call the endpoint now, thanks to SO, but have no idea how to set up the SoapHeaders as the schema below shows:

<S:Envelope 
  xmlns:S="http://www.w3.org/2001/12/soap-envelope"
  xmlns:ws="http://schemas.xmlsoap.org/ws/2002/04/secext">
    <S:Header>
        <ws:Security>
            <ws:UsernameToken>
                <ws:Username>aarons</ws:Username>
                <ws:Password>snoraa</ws:Password>
            </ws:UsernameToken>
        </wsse:Security>
        •••
    </S:Header>
    •••
</S:Envelope>

任何帮助非常AP preciated

Any help much appreciated

谢谢,马克

推荐答案

为了调用这些样的服务,你会一般使用 basicHttpBinding的(这是SOAP 1.1,而不WS- *实现)或再的wsHttpBinding (SOAP 1.2,与WS- *实现)。

In order to call these kind of services, you will typically use either basicHttpBinding (that's SOAP 1.1 without WS-* implementations) or then wsHttpBinding (SOAP 1.2, with WS-* implementations).

主要的问题将越来越所有安全参数的权利。我有一个类似的网络服务(基于Java的),我需要调用 - 这里是我的设置和code:

The main issue will be getting all the security parameters right. I have a similar web service (Java-based) that I need to call - here's my settings and code:

app./web.config

<system.serviceModel>
   <bindings>
      <basicHttpBinding>
         <binding name="SoapWithAuth" useDefaultWebProxy="false">
            <security mode="TransportCredentialOnly">
              <transport clientCredentialType="Basic" proxyCredentialType="None" realm="" />
            </security>
         </binding>
      </basicHttpBinding>
   </bindings>
   <client>
    <endpoint name="SoapWithAuth"
                  address="http://yourserver:port/YourService"
                  binding="basicHttpBinding" 
                  bindingConfiguration="SoapWithAuth"
                  contract="IYourService" />
   </client>
</system.serviceModel>

,然后在客户端的code调用服务的时候,你需要code这个片断:

and then in your client's code when calling the service, you need this snippet of code:

IYourServiceClient client = new IYourServiceClient();

client.ClientCredentials.UserName.UserName = "username";
client.ClientCredentials.UserName.Password = "top-secret"; 

这是否帮助呢?

这篇关于WCF代理中实现的WS-Security的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆