Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Dynamics CRM 4.0 Web Reference HTTP status 401: Unauthorized.

$
0
0

Hello

I am using Web References for doing some Dynamics CRM 4.0 related development. All the functionality is working perfectly as expected on my development system when program ran through Visual Studio (2012).

But when the application is deployed on a remote server I get following error:

18/12/2015 12:35:01[ERROR]:Error Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at EFCRM4Zenith.CrmSdk.CrmService.Execute(Request Request) in d:\MyApp\Web References\CrmSdk\Reference.cs:line 148

CRM is accessible on the remote server machine where I have deployed the application, however all the Web-reference were generated on the development machine(not sure if it is relevant info).

The code where authorization is setup is as follows:

               CrmAuthenticationToken token = new CrmAuthenticationToken();
                token.OrganizationName = organizationName;

                // Use the enumeration in enums.cs for the authentication type.
                token.AuthenticationType = AuthenticationType.AD;

                // Set up the CrmService Web service.
                CrmService crmService = new CrmService();
                if (crmServiceUrl != String.Empty) crmService.Url = crmServiceUrl;
                crmService.UseDefaultCredentials = true;
                crmService.CrmAuthenticationTokenValue = token;

                WhoAmIRequest who = new WhoAmIRequest();
                WhoAmIResponse owner = (WhoAmIResponse)crmService.Execute(who);
                WhoAmIResponse whoResp = (WhoAmIResponse)crmService.Execute(who);


I get error when following line is executed:

 WhoAmIResponse whoResp = (WhoAmIResponse)crmService.Execute(who);


What can be the possible reason of this error and how I can fix it? As same code is working perfectly on the development machine.


Regards


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>