web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to consume a web service in CRM using plugin.

(0) ShareShare
ReportReport
Posted on by

How to consume a web service in CRM using plugin. It would be great if some one can point me to a simple program that consumes a simple web service.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    nghieppham Profile Picture
    4,755 on at

    Hi Aaronvm,

    Note that you should consider the version that you are using. If you are using CRM Online, your wcf should be hosted on Azure server.

    Please download this link for consuming wcf service sample code.msdn.microsoft.com/How-to-call-External-WCF-42c4490d

    Regards,

  • Community Member Profile Picture
    on at

    Hi    Pham Hong Nghiep,

    I am using the online version. I came across a similar code as shown in the link you provided but when i type it in visual Studio 2015 it gives an error saying

    "   'BasicHttpBinding' does not contain a definition for 'Name'  "

    It gives error at 'EndpointAddress' also.

    Do i have to add any specific reference?

  • Suggested answer
    nghieppham Profile Picture
    4,755 on at

    Hi Aaronvm,

    For CRM Online, register plug-in is Isolation mode. There are some limitation for Isolation mode.

    1. You cannot access external DLL (in this case, you can use ILMerge).

    2. External service: You cannot not access via IP, you have to use friendly name, and your service have to be verified, in this case, you have to host your service in Azure server for testing.

    Regards,

  • Suggested answer
    Community Member Profile Picture
    on at

    You create a custom workflow activity, as the SDK describes.

    In the project, create a service reference to the service that you want to consume.

    Now you will have to call the service without using web.config settings. You might, for instance, save the url to the service in a custom entity.

           public static void CallService(IOrganizationService organizationService)
            {
                var binding = new BasicHttpBinding
                {
                    Security = new BasicHttpSecurity
                    {
                        Mode = BasicHttpSecurityMode.TransportCredentialOnly,
                        Transport = new HttpTransportSecurity
                        {
                            ClientCredentialType = HttpClientCredentialType.Ntlm
                        }
                    }
                };
                Uri uri = GetServiceUrl(organizationService);  // GetServiceUrl queries to organizationService to get the Url from a record of your custom entity.
                var endpoint = new EndpointAddress(uri);
                using (var client = new MyServiceClient(binding, endpoint))
                {
                    // use the client
                }
            }

  • Community Member Profile Picture
    on at

    Just use Add service reference and put the service and discover then make proxy and use it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans