Calling WCF service, exposed on Azure Service Bus, directly in a sandboxed plugin RRS feed

  • Question

  • Hello Devs,

    Is there any way to call a WCF service, exposed to a Azure Service Bus Relay, directly in a sandboxed plugin code? That is without using provided Service Endpoint entity. Basically, I don't want to pass over full data context (IPluginExecutionContext) to the WCF service that is not CRM aware.

    I googled for calling a WCF service in a sandboxed plugin and found that it is possible. However, when I am trying to access a service bus relay hosted service, it is ending up with error:

    The type initializer for 'Microsoft.ServiceBus.RelayEnvironment' threw an exception

    with an inner exception message:

    Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

    Below is my sample plugin code:

    string serviceNamespace = "myNameSpace";
    string issuerName = "RootManageSharedAccessKey";
    string issuerKey = "myKey";
    string servicePath = "Student/GetInfo";
    var cf = new ChannelFactory<IStudentInfo>(
    	new WS2007HttpRelayBinding(),
    	new EndpointAddress(ServiceBusEnvironment.CreateServiceUri(Uri.UriSchemeHttps, serviceNamespace, servicePath)));
    cf.Endpoint.Behaviors.Add(new TransportClientEndpointBehavior
    	TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(issuerName, issuerKey)
    	//TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerKey)
    var ch = cf.CreateChannel();

    I am using CRM Online for this testing purpose.

    blog: <a href="http://technologynotesforyou.wordpress.com">http://technologynotesforyou.wordpress.com</a> | skype: ali.net.pk

    Tuesday, May 10, 2016 3:16 PM

All replies

  • I think your only option is to use the Service Endpoint. The sandbox allows you to make anonymous web service calls, but does not permit access to the types you need for any authenticated calls

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

    Tuesday, May 10, 2016 9:08 PM