使用带有Microsoft Dynamics CRM 2013联机插件的Web服务

我在连接到用于MS Dynamics 2013插件的Web服务时遇到问题(在沙箱模式下运行,因为它在MS托管的在线版本上,而不是内部版本)

我面临的问题是,我似乎无法连接到我需要用来实现我正在尝试做的事情的Web服务。

我最初在app.config中有了web服务绑定,但我很快就知道app.config在这种情况下是无关紧要的(?),所以我继续在代码中创建绑定。 这是我提出的代码:

BasicHttpBinding myBinding = new BasicHttpBinding(); myBinding.Name = "BasicHttpBinding_IClientSearch"; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; myBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; myBinding.MaxBufferSize = 524288; myBinding.MaxBufferPoolSize = 524288; myBinding.MaxReceivedMessageSize = 524288; myBinding.ReaderQuotas.MaxDepth = 32; myBinding.ReaderQuotas.MaxArrayLength = 524288; myBinding.ReaderQuotas.MaxStringContentLength = 524288; myBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential; EndpointAddress endPointAddress = new EndpointAddress(EndPointURL); ClientSearchService.ClientSearchClient myClient = new ClientSearchService.ClientSearchClient(myBinding, endPointAddress); myClient.Open(); 

当我将其部署到动态服务器并触发代码时,它会抛出此错误:

 The Binding with name BasicHttpBinding_IClientSearch failed validation because it contains a BindingElement with type System.ServiceModel.Channels.TransportSecurityBindingElement which is not supported in partial trust. Consider using BasicHttpBinding or WSHttpBinding, or hosting your application in a full-trust environment. 

显然因为它在微软自己的托管平台上我无法在完全信任的环境中运行它,我确实要求它是BasicHttpSecurityMode.TransportWithMessageCredential因为我需要提供用户名/密码来访问该服务。

是否有解决此问题的方法,或者我无法使用插件完成此任务?