2011-12-20 3 views
0

.NETから[Java] Webサービスを呼び出そうとすると、セキュリティ資格情報の問題が発生しています。資格情報が必要なWebサービスを呼び出す:エラー:セキュリティトークンが必要です

CWWSS5509E: A security token whose type is [http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken] is required. 

私は通過しようとしている資格情報を取得していますか?この時点で、私はWebサービスと接触してアクセスしたいだけです。私の例では、ServiceReference1は生成されたWebプロキシクラスです。

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 

    Dim myLocateProfileBySourceSystemId As New ServiceReference1.locateProfileBySourceSystemId 

    Dim myLocateProfileBySourceSystemIdRequestType As New ServiceReference1.LocateProfileBySourceSystemIdRequestType 

    myLocateProfileBySourceSystemIdRequestType.includeEmailAddress = True 

    myLocateProfileBySourceSystemId.locateProfileBySourceSystemId1 = myLocateProfileBySourceSystemIdRequestType 

    System.Net.ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf ValidateRemoteCertificate) 

    Dim myNetworkCredential As New System.Net.NetworkCredential 
    myNetworkCredential.UserName = "MyUsernameGoesHere" 
    myNetworkCredential.Password = "MyPasswordGoesHere" 

    Dim myWebProxy As New WebProxy() 
    myWebProxy.Credentials = myNetworkCredential 
    WebRequest.DefaultWebProxy.Credentials = myNetworkCredential 

    Dim myIndividualProfileSoapClient As New ServiceReference1.IndividualProfileSoapClient 
    Dim myLocateProfileBySourceSystemIdResponse As ServiceReference1.locateProfileBySourceSystemIdResponse = myIndividualProfileSoapClient.locateProfileBySourceSystemId(myLocateProfileBySourceSystemId) 

End Sub 

Private Shared Function ValidateRemoteCertificate(ByVal sender As Object, 
               ByVal certificate As X509Certificate, 
               ByVal chain As X509Chain, 
               ByVal policyErrors As SslPolicyErrors) As Boolean  
    ' allow any old dodgy certificate... 
    Return True 

End Function 

私のApp.Configの設定は何ですか?

  <security mode="Transport"> 
       <transport clientCredentialType="None" proxyCredentialType="None" 
        realm="" /> 
       <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
+0

あなたはタイプSystem.ServiceModel.Description.ClientCredentialsであるClientCrdedentialsプロパティを持つオブジェクトmyIndi​​vidualProfileSoapClientオブジェクト – mikey

+0

にプロパティとしての資格情報を追加することができるはずです。これにはパラメータのないコンストラクタがありますが、このオブジェクトのユーザ名とパスワードのプロパティは読み込み専用です。このオブジェクトを作成するにはどうすればいいですか? – ChadD

答えて

1
+1

ClientCredentials.UserName.UserNameとClientCredentials.UserName.Passwordは正しいでしょう –

+0

設定ファイル内の clientCredentialTypeはどうなりますか?私の掲示に示すように、それはNoneであるべきですか?基本?等? – ChadD

+0

@Velikaはい参照を追加したときにBasicがあなたのために生成されたセクションではありませんでしたか? –