error calling asmx from plugin RRS feed

  • Question

  • Hello, I'm trying to call an asmx web service through a plugin.  I know asmx is old school but that's the web service that's been provided to me. Anyway, I need to programatically call the web service from the plugin.  My code is currently returning the following error:

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

    Here's the code I'm using to try to call the asmx from the plugin:

            private void Execute()
                string svcUrl = "http://mycompany.com/services/external-service.asmx";
                var svcClient = new mycompany.services.SwiVulnWriterSoapClient(Binding, new EndpointAddress(svcUrl));
                svcClient.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;

            private WSHttpBinding GetBinding()
                return new WSHttpBinding
                    Security = new WSHttpSecurity
                        Mode = SecurityMode.Message,
                        Transport = new HttpTransportSecurity
                            ClientCredentialType = HttpClientCredentialType.Windows
                    MaxReceivedMessageSize = 5242880

    Can you recommend steps to resolve or troubleshoot this error?

    Monday, March 3, 2014 11:45 PM

All replies

  • firstly try to open your web service in ie from your crm database server.

    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Tuesday, March 4, 2014 4:15 AM
  • Hi,

    Please go through this link.


    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful" Thank you, DT

    Tuesday, March 4, 2014 1:38 PM
  • One thing to check - is your code running in the sandbox or not ? If it's running in the snadbox, you won't be able to pass credentials

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Tuesday, March 4, 2014 6:22 PM