【发布时间】:2018-04-15 08:15:45
【问题描述】:
我正在尝试调用具有 Windows 身份验证的外部服务,它可以在我在 IIS 中运行的 Windows 开发机器上正常工作,但是一旦我将站点发布到 Azure,即使配置为相同的。我得到的错误是,
System.ServiceModel.Security.MessageSecurityException:
The HTTP request is unauthorized with client authentication scheme 'Negotiate'.
The authentication header received from the server was 'Negotiate'. --->
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
感觉就像在 Azure 中它甚至没有尝试进行身份验证。
服务的配置如下所示,
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Custom_Binding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="524288" receiveTimeout="00:20:00" sendTimeout="00:20:00">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.otherdomain.com/webServiceRequest" binding="basicHttpBinding" bindingConfiguration="Custom_Binding" contract="webServiceRequest_Port" name="webServiceRequest_Port" />
</client>
</system.serviceModel>
这是发出请求的 c# 代码,
var client = new webServiceRequest_PortClient();
client.ClientCredentials.UserName.UserName = "domain\Username";
client.ClientCredentials.UserName.Password = "Password";
var response = await client.PerformServiceAsync(method, request);
/维克托
【问题讨论】: