Friday, July 10, 2009

ESB Error: The remote server returned an error: (401) Unauthorized

Error: On ESB.Portal/Default.aspx page.


The remote server returned an error: (401) Unauthorized.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.

Source Error:

Line 287: {

Line 288: client = PortalHelper.GetExceptionService();

Line 289: List settings = client.GetUserSettings(context.User.Identity.Name);

Line 290:

Line 291: context.Session.Clear();


Source File: c:\Program Files (x86)\Microsoft BizTalk ESB Toolkit 2.0\ESBSource\Source\Samples\Management Portal\ESB.Portal\Code\PortalHelper.cs Line: 289

Stack Trace:

[WebException: The remote server returned an error: (401) Unauthorized.]

System.Net.HttpWebRequest.GetResponse() +1126

System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +81

[MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'NTLM'.]


Fix:

Change the security in the ESB.Portal web.config.

In the web.config change the security mode for the webBam webHttpBinding to match the correct security for your portal. For more information review: http://msdn.microsoft.com/en-us/library/ms731362.aspx.

To get mine to work I changed:

<webHttpBinding>

<binding name="webBam" maxBufferPoolSize="5000000" maxReceivedMessageSize="5000000">

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

<security mode="TransportCredentialOnly">

<transport clientCredentialType="Windows" />

security>

binding>

webHttpBinding>

To:

<webHttpBinding>

<binding name="webBam" maxBufferPoolSize="5000000" maxReceivedMessageSize="5000000">

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

<security mode="TransportCredentialOnly">

<transport clientCredentialType="Ntlm" />

security>

binding>

webHttpBinding>



3 comments:

Aboorva Raja said...

It is not working for me;(

jahuso said...

Me neither

Anonymous said...

The post here worked for me:

http://www.codeproject.com/Questions/675316/The-remote-server-returned-an-error-Unauthoriz