9

WSDLで指定された認証要件を持たないサービスに認証ヘッダーを送信しようとしていWSDLます。

Web サービスの呼び出しに Auth ヘッダーを追加するにはどうすればよいですか?

私が取り組んできたコード:

using System;
using System.Web.Services.Protocols;

namespace TesteSoap
{           
    class MainClass
    {
        public static void Main (string[] args)
        {

            WSDLService Service = new WSDLService();
            /* How can I add authentication to the call of this webservice ? */
            Service.get();
            Console.WriteLine ("Hello World!");
        }
    }
}
4

1 に答える 1

20

この問題は他のリンクで質問されていますが、ユーザー/パスワードの質問を含む WSDL に関連する別の方法で質問されています。

リンク

それらは同じ質問ではありませんが、問題は関連しています。

Michaelis.MockService は、抽出された Web サービス ライブラリです。これを行う方法の例は、Mono プロジェクトの Web サイトへのリンクで確認できます。

Michaelis.MockService service = new Michaelis.MockService();

// Create the network credentials and assign
// them to the service credentials
NetworkCredential netCredential = new NetworkCredential("Inigo.Montoya", "Ykmfptd");
Uri uri = new Uri(service.Url);
ICredentials credentials = netCredential.GetCredential(uri, "Basic");
service.Credentials = credentials;

// Be sure to set PreAuthenticate to true or else
// authentication will not be sent.
service.PreAuthenticate = true;

// Make the web service call.
service.Method();
于 2011-02-10T15:56:18.827 に答える