0
votes

We're trying to get data from an external web service using VB.Net.

We added a Service Reference, provinding the correct WSDL.

Our code for getting data is:

    Dim MyClient As New ExtConn.GetConnectorSoapClient()

    MyClient.ClientCredentials.UserName.UserName = "AOL\12345.abcde"
    MyClient.ClientCredentials.UserName.Password = "pass123"

    Dim MyReq As New ExtConn.GetDataRequest
    Dim MyResponse As New ExtConn.GetDataResponse

    Dim MyCred As New System.ServiceModel.Description.ClientCredentials()

    Dim MyReqBody As New ExtConn.GetDataRequestBody("Environment123", "AOL\12345.abcde", "pass123", "12345.abcde", "GetData", "")

    MyReq.Body = MyReqBody

    MyResponse = MyClient.ExtConn_GetConnectorSoap_GetData(MyReq)

    MsgBox(MyResponse.Body.GetDataResult)

Our app.config is:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>

    <bindings>
        <basicHttpsBinding>
            <binding name="GetConnectorSoap">
              <security mode="Transport"  >
                <transport clientCredentialType="Ntlm" realm="" />
                <message clientCredentialType="UserName"  />
              </security>
            </binding>

        </basicHttpsBinding>
    </bindings>
    <client>
        <endpoint address="https://ota.externalservice.nl/ourservices/getconnector.asmx"
            binding="basicHttpsBinding" bindingConfiguration="GetConnectorSoap"
            contract="ExtConn.GetConnectorSoap" name="GetConnectorSoap" />
    </client>
</system.serviceModel>
</configuration>

The respons is:

The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'Negotiate,Kerberos,NTLM'.

My questions are: what are we doing wrong? If NTLM is accepted as authentication mode, why do we get this error?

1

1 Answers

-1
votes

You could try to add it as an web reference (Add service reference > Advanced.. > Add Web reference)

GetConnector connector = new GetConnector();
connector.Credentials = new NetworkCredential("username", "password", "domain");
string response = connector.GetData();