2011-12-20 2 views
0

.NET에서 [Java] 웹 서비스를 호출하려고하면 보안 자격 증명 문제 인 것처럼 보입니다.자격 증명이 필요한 웹 서비스 호출 : 오류 : 보안 토큰이 필요합니다.

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. 

내가 전달하려고하는 자격 증명을 선택하고 있습니까? 이 시점에서 웹 서비스에 접속하여 액세스 권한을 얻고 싶습니다. 예제에서 ServiceReference1은 생성 된 웹 프록시 클래스입니다.

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

당신은 myIndividualProfileSoapClient 객체 – mikey

+0

이 객체에 속성으로 자격 증명을 추가 할 수 있어야 타입 System.ServiceModel.Description.ClientCredentials의 인 ClientCrdedentials 속성이 있습니다. 매개 변수없는 생성자가 있지만이 객체의 사용자 이름 및 비밀번호 속성은 읽기 전용입니다. 이 객체는 어떻게 만듭니 까? – ChadD

답변

1
+1

ClientCredentials.UserName.UserName 및 ClientCredentials.UserName.Password가 정확합니다. –

+0

구성 파일의 clientCredentialType은 어떻습니까? 내 게시글에서 알 수 있듯이 '없음'이어야합니까? 기본? 기타? – ChadD

+0

@Velika 예 참조를 추가 할 때 기본 섹션이 생성되지 않았습니다? –