Вызов веб-службы, для которой требуются учетные данные: Ошибка: требуется токен безопасности - PullRequest
0 голосов
/ 20 декабря 2011

Когда я пытаюсь вызвать веб-службу [Java] из .NET, у меня возникает проблема с учетными данными безопасности.

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>
...