Using a web service with Microsoft Dynamics CRM 2013 online plugin

坚强是说给别人听的谎言 提交于 2019-12-08 01:50:35

问题


I'm having an issue connecting to a web service for use in a MS Dynamics 2013 plugin (running in sandbox mode because its on the MS hosted online version, not the in house version)

The issue I'm facing is that i cannot seem to connect to a web service i need to use to achieve what I'm attempting to do.

I initially had the web service binding in the app.config, but i quickly learnt that the app.config is irrelevant in this case (?), so i moved on to creating the binding in the code. this is the code i came up with:

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();

When I deploy this to the dynamics server and trigger the code it throws this error:

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.

Obviously because its on Microsofts own hosting platform i am incapable of running it in a full trust enviroment, I do require it being BasicHttpSecurityMode.TransportWithMessageCredential because i need to supply a username/password to access the service.

Is there a workaround for this problem, or am i incapable of completing this task using a plugin?

来源:https://stackoverflow.com/questions/25886049/using-a-web-service-with-microsoft-dynamics-crm-2013-online-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!