我正在尝试从CRM插件中连接到MS CRM部署服务(即我没有能力使用app.config配置文件).
问题是使用源代码替换“配置魔术”真的很难.
当我使用以下配置文件(在控制台应用程序中本地测试)时:
<client> <endpoint address="http://server/XRMDeployment/2011/Deployment.svc" binding="customBinding" bindingConfiguration="CustomBinding_IDeploymentService" contract="DeploymentService.IDeploymentService" name="CustomBinding_IDeploymentService"> <identity> <userPrincipalName value="DOMAIN\DYNAMICS_CRM" /> </identity> </endpoint> ... </client>
一切都很好,但是当我试图用我所面对的代码来替换配置.在生成的SOAP消息中,而不是预期的标题:
<a:Action s:mustUnderstand="1" u:Id="_4">http://schemas.microsoft.com/xrm/2011/Contracts/Services/IDeploymentService/Retrieve</a:Action>
我看到一些奇怪的东西
<a:Action s:mustUnderstand="1" u:Id="_4">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</a:Action>
有人知道如何覆盖Action Header,配置中的哪个语句会使WCF的魔法使一切正常工作?
解决方法
我想你应该使用如下配置
[ServiceContract(Name = "DeploymentService",Namespace = "http://schemas.microsoft.com/xrm/2011/Contracts/Services/")] public interface IDeploymentService { [OperationContract(Action="uri://<your service URI>/Retrieve")] void Retrieve(); }