2014-02-25 59 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(); 
}