C# 通过Microsoft Dynamics CRM 2013在线插件使用web服务
我在连接用于MS Dynamics 2013插件的web服务时遇到问题(在沙盒模式下运行,因为它在MS托管的在线版本上,而不是内部版本上) 我面临的问题是,我似乎无法连接到我需要使用的web服务,以实现我正在尝试的目标 我最初在app.config中有web服务绑定,但我很快就知道app.config在本例中是不相关的(?),所以我继续在代码中创建绑定。 这是我想出的代码:C# 通过Microsoft Dynamics CRM 2013在线插件使用web服务,c#,wcf,service,crm,microsoft-dynamics,C#,Wcf,Service,Crm,Microsoft Dynamics,我在连接用于MS Dynamics 2013插件的web服务时遇到问题(在沙盒模式下运行,因为它在MS托管的在线版本上,而不是内部版本上) 我面临的问题是,我似乎无法连接到我需要使用的web服务,以实现我正在尝试的目标 我最初在app.config中有web服务绑定,但我很快就知道app.config在本例中是不相关的(?),所以我继续在代码中创建绑定。 这是我想出的代码: BasicHttpBinding myBinding = new BasicHttpBinding(); myBindin
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();
当我将其部署到dynamics服务器并触发代码时,它会抛出以下错误:
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.
显然,因为它是在微软自己的托管平台上,我无法在完全信任的环境中运行它,所以我确实要求它是basichtpsecuritymode.TransportWithMessageCredential
,因为我需要提供用户名/密码来访问该服务
这个问题有解决办法吗,或者我不能用插件完成这个任务吗