4

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.

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

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>

Any help much appreciated

Thanks, Mark

4

2 に答える 2

4

これらの種類のサービスを呼び出すには、通常、basicHttpBinding(WS-* 実装のない SOAP 1.1) またはwsHttpBinding(WS-* 実装のある SOAP 1.2) のいずれかを使用します。

主な問題は、すべてのセキュリティ パラメータを適切に設定することです。呼び出す必要がある同様の Web サービス (Java ベース) があります。設定とコードは次のとおりです。

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>

次に、クライアントのコードでサービスを呼び出すときに、次のコード スニペットが必要です。

IYourServiceClient client = new IYourServiceClient();

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

それはまったく役に立ちますか?

于 2010-05-31T18:51:33.063 に答える
0

WCF クライアント プロキシは、パスワード ダイジェスト オプションをサポートしていません。これを行う唯一の方法は、UsernameToken を自分で作成し、それをメッセージが送信される前に SOAP ヘッダーに挿入することです。

ここで説明されている同様の問題がありました。これは、同じ問題を解決するのに十分なはずです。

最終的には、ハッシュ アルゴリズムを自分でコーディングし、カスタム動作を使用して SOAP ヘッダーを変更するのではなく、UsernameToken に古い WSE3.0 ライブラリを使用することになりました。

于 2010-07-22T10:18:47.773 に答える