7

クライアントのSAPWebサービスへの接続をテストするためのWindowsアプリケーションを作成しました。Webサービス呼び出しには、X509証明書のセキュリティが必要です。

インターネット上のさまざまな記事を読んだ後、X509証明書をWebサービス呼び出しに添付する3つの方法を思いつきました。残念ながら、これらの試みはすべて「401UnauthorizedAccess」を返します。ただし、IEのURLを介してWebサービスに接続できます。

誰かが私が間違っているかもしれないことについて何か推測がありますか?私はWSE3.0を使用しており、証明書を添付するために使用している3つの方法は次のとおりです。

証明書

X509Certificate2 oCert = GetSecurityCertificate(oCertificate);  
svc.ClientCertificates.Add(oCert);

トークン

X509SecurityToken oToken = GetSecurityToken(oCertificate);
svc.RequestSoapContext.Security.Tokens.Add(oToken);

ポリシー

SAPX509Assertion sapX509Assertion = new SAPX509Assertion(oCertificate, oStoreLocation, oStoreName, oFindType);  
svc.SetPolicy(sapX509Assertion.Policy());

GetSecurityToken()とGetSecuirtyCertificateは、どちらも証明書ストアを検索します。SAPX509Assertionはこれを行います:-

public SAPX509Assertion(String certSubject, StoreLocation oStoreLocation, StoreName oStoreName, X509FindType oFindType)  
{  
    ClientX509TokenProvider = new X509TokenProvider(oStoreLocation,
                                                     oStoreName, certSubject, oFindType);  
    ServiceX509TokenProvider = new X509TokenProvider(oStoreLocation,
                                                     oStoreName, certSubject, oFindType);  

    Protection.Request.EncryptBody = false;  
    Protection.Response.EncryptBody = false;  
} 

更新 OK、WCF呼び出しがあります。私はhttpsアドレスに接続していてhttpを期待していると文句を言ったのでEugarpsによって示されたBasicHttpBindingメソッドを使用できませんでした...それは理にかなっています。私が今持っているコードは次のとおりです:-

var binding = new WSHttpBinding();
binding.MaxReceivedMessageSize = int.MaxValue;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Mode = SecurityMode.Transport;

WCFConnection.CreateAbsenceWSlow.ZWSDHTM_GB_AMS_CREATEABS_lowClient client;
CreateAbsenceWSlow.ZfhhrGbbapiZgeeamsCreateabsResponse response;
CreateAbsenceWSlow.ZfhhrGbbapiZgeeamsCreateabs data;
//Assign address
var address = new EndpointAddress(sUrl);

//Create service client
client = new CreateAbsenceWSlow.ZWSDHTM_GB_AMS_CREATEABS_lowClient(binding, address);

//Assign credentials
client.ClientCredentials.UserName.UserName = sUserName;
client.ClientCredentials.UserName.Password = sPassword;

response = new CreateAbsenceWSlow.ZfhhrGbbapiZgeeamsCreateabsResponse();
data = new WCFConnection.CreateAbsenceWSlow.ZfhhrGbbapiZgeeamsCreateabs();

response = client.ZfhhrGbbapiZgeeamsCreateabs(data);

それでもSAPWebサービスへの接続に失敗しています。私が受け取っているエラーは、「HTTPリクエストはクライアント認証スキーム「ネゴシエート」で許可されていません」です。私も使ってみました

binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

同様のエラーが返されました。

誰かが私がどこで間違っているのかについてさらに提案やアイデアがありますか?

4

4 に答える 4

4

さて、これはすべて私自身の経験から来ているので、いくつかは間違っているかもしれませんが、これが私がプロセスを理解する方法です(私はドキュメントを受け取っておらず、私の会社はそれを始める前にSAPに電話した経験がありませんでした)。

SAP WS呼び出しは、WCF BasicHttpBindingでのみサポートされており、私が知る限り、プレーンテキストの資格情報のみを使用しています。これは、通信をプライベートにする必要がある場合(イントラネット外、またはイントラネット内の機密データ)、IPSecまたはHTTPSを使用することを意味します。SAPサーバーにはHTTPSが構成されていませんが、外部通信にはIPSecを使用したVPNを使用しています。注意すべき重要な点は、デフォルトでは、SAPGUIは通信をプライベートにしないことです。この状況では、以下に詳述する方法を使用することで、GUI7.1で機密データを検索しているビジネスユーザーよりも安全性が低下します。SAPサーバーに内部的に接続する方法は次のとおりです。

        //Create binding
        //Note, this is not secure but it's not up to us to decide. This should only ever be run within
        //the VPN or Intranet where IPSec is active. If SAP is ever directly from outside the network,
        //credentials and messages will not be private.
        var binding = new BasicHttpBinding();
        binding.MaxReceivedMessageSize = int.MaxValue;
        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
        binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

        //Assign address
        var address = new EndpointAddress(Host);

        //Create service client
        var client = new SAP_RFC_READ_TABLE.RFC_READ_TABLEPortTypeClient(binding, address);

        //Assign credentials
        client.ClientCredentials.UserName.UserName = User;
        client.ClientCredentials.UserName.Password = Password;

私が判断できた限りでは、メッセージレベルのセキュリティはサポートされておらず、basicHttpBinding(SOAP 1.1)以外のバインディングはサポートされていません。

私が言ったように、これはすべて経験によるものであり、トレーニングによるものではないので、誰かがコメントを通じて何かを追加できる場合は、そうしてください。

于 2010-09-15T15:47:54.397 に答える
2

同じ問題に直面しましたが、ここで解決策を見つけたようです: http ://ddkonline.blogspot.com/2009/08/calling-sap-pi-web-service-using-wcf.html 。

        CustomBinding binding = new CustomBinding();
        binding.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8));
        HttpsTransportBindingElement transport = new HttpsTransportBindingElement();
        transport.AuthenticationScheme = AuthenticationSchemes.Basic;
        //transport.ProxyAuthenticationScheme = AuthenticationSchemes.Basic;
        transport.Realm = "XISOAPApps";
        binding.Elements.Add(transport);
        var address = new EndpointAddress("https://foooo");
        ........ create client proxy class


        service.ClientCredentials.UserName.UserName = "<login>";
        service.ClientCredentials.UserName.Password = "<password>";

残念ながら、アプリケーションでWCFを使用できません。.NET2.0とWSE 3.0を使い続ける必要があります。誰かがそれに対する解決策を見つけることができた場合、私は負傷しますか?

于 2011-01-19T12:35:00.097 に答える
-1

この間ずっと、クライアントはついにSAPの終わりから問題に対処するための誰かを獲得しました。提供されたWSDLファイルが正しくなく、認証が間違って行われていたことが判明しました。新しいWSDLファイルを使用してコードを再実行しましたが、初めて機能しました。

于 2011-03-28T14:07:27.947 に答える
-2

証明書は、ユーザーストア内の有効なユーザーにマップされていますか?

于 2010-09-08T15:49:32.853 に答える