2014-02-25 60 views
10

我试图从CRM插件内连接到MS CRM部署服务(即,我无法使用app.config配置文件)。请求中的SOAP错误操作标头错误。为什么?

问题是用源代码替换'配置魔术'真的很难。

虽然我使用下面的配置文件(在控制台应用程序进行本地测试):

<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头和语句配置将WCF魔法使一切工作?

+0

[RST/SCT约为安全对话(HTTP: //docs.oasis-open.org/ws-sx/ws-secureconversation/200512/ws-secureconversation-1.3-os.html#_Toc162064066)。我猜你正在面临提供证书或令牌的挑战。 –

+0

如果您只是尝试访问您通常放置在配置文件中的设置,为什么不在CRM中创建新的ConfigSettings实体并从中读取设置? – Daryl

+0

我没有直接访问CRM安装... – shytikov

回答

0

您可以自定义服务接口类的SOAP动作,

[ServiceContract] 
    public interface IMyService 
    { 
    [OperationContract(
     Action = "MySoapAction" ] 
     Message ServiceFunction(Message input); 
    } 
1

我想你应该使用类似下面的配置

[ServiceContract(Name = "DeploymentService", 
    Namespace = "http://schemas.microsoft.com/xrm/2011/Contracts/Services/")] 
public interface IDeploymentService 
{ 
    [OperationContract(Action="uri://<your service URI>/Retrieve")] 
    void Retrieve(); 
}