I am trying to consume an SAP web service as a service reference in a C# window service. I keep getting this error:
System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm="SAP NetWeaver Application Server [SEQ/400]"'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
I am passing in a username and password in code thusly:
ws.ClientCredentials.UserName.UserName = psUserName;
ws.ClientCredentials.UserName.Password = psPassword;
and my serviceModel
app.config
section looks like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_MyWS">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="SAP NetWeaver Application Server [SEQ/400]"/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://myaddress/sap/somefunc" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_myWS" contract="myWS.ServiceName" name="basicHttpBinding_myWS" />
</client>
</system.serviceModel>
I have tried fiddling with the system.serviceModel
section but nothing Google suggests works. Does anyone have any suggestions as to why this does not work? The end point has been verified. Thanks!
From the error message, it is expecting clientCredentialType="Basic" but you passed clientCredentialType="None"