locked
CRM Plugin to Call External Webservice RRS feed

  • Question

  • We are on CRM 2013 on premise and we're writing plugin to call external webservice. The webservice is using WSHttpBinding. Basically this plugin will be called during account creation in CRM, then pass information into the webservice.

    Here's my code:

    var binding = new WSHttpBinding(SecurityMode.None);
    //binding.Security.Mode = WSDualHttpSecurityMode.None;
    binding.MaxReceivedMessageSize = 2147483647;
    binding.MaxBufferPoolSize = 2147483647;
    binding.SendTimeout = TimeSpan.FromMinutes(3);
    binding.ReceiveTimeout = TimeSpan.FromMinutes(3);
    binding.OpenTimeout = TimeSpan.FromMinutes(3);
    binding.CloseTimeout = TimeSpan.FromMinutes(3);
    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
    binding.Security.Message.EstablishSecurityContext = false;
    binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
    //binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
    
    var address = new EndpointAddress(ea);
    
    ChannelFactory<IPropertyServiceChannel> factory = new ChannelFactory<IPropertyServiceChannel>(binding, address);
    IPropertyServiceChannel channel = factory.CreateChannel();
    
    using (var proxy = new PropertyServiceClient(binding, address))
    {
        var tid = new Tid { Dtid = "dMaster", Ptid = "pMain" };
    
        var newProp = new PropertySetup
        {                  
           //setup data
    
        };
    
        proxy.CreateProperty(newProp); //this or below isn't working...
        //channel.CreateProperty(newProp); //this is not working
        //channel.Close(); 

    However I keep getting error message: "The message could not be processed. This is most likely because the action 'http://tempuri.org/IPropertyService/CreateProperty' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding."

    I created a simple Console App to just connect to the webservice and it is connecting successfully. However I cannot seem to do so from CRM itself. The only thing is we are using Sandbox isolation mode when registering the plugin. Not sure if the webservice call would be working from Sandbox mode? For some reason I keep getting an error trying to register the plugin in 'None' isolation mode even though I'm already a deployment administrator.

    Any suggestion is greatly appreciated. TIA

    -tri

    Monday, January 26, 2015 11:44 PM

Answers

  • My account was finally able to register the plugin in none-sandbox mode. This fixed the problem.
    • Marked as answer by triangular Friday, February 6, 2015 7:20 PM
    Friday, February 6, 2015 7:20 PM

All replies

  • I just realized I posted this on the wrong forum, should have been on the development sub-forum one. Anyone kindly moves this thread? Thanks much.

    -tri

    Tuesday, January 27, 2015 2:26 AM
  • My account was finally able to register the plugin in none-sandbox mode. This fixed the problem.
    • Marked as answer by triangular Friday, February 6, 2015 7:20 PM
    Friday, February 6, 2015 7:20 PM