请求中的SOAP Action标头错误.为什么?

shy*_*kov 10 c# xml wcf soap dynamics-crm-2011

我正在尝试从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>
Run Code Online (Sandbox Code Playgroud)

一切都很好,但是当我试图用我正面对的代码替换配置时.在生成的SOAP消息而不是预期的标头中:

<a:Action s:mustUnderstand="1" u:Id="_4">http://schemas.microsoft.com/xrm/2011/Contracts/Services/IDeploymentService/Retrieve</a:Action>
Run Code Online (Sandbox Code Playgroud)

我看到一些奇怪的事:

<a:Action s:mustUnderstand="1" u:Id="_4">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</a:Action>
Run Code Online (Sandbox Code Playgroud)

有谁知道如何覆盖Action Header以及配置中的哪个语句会使WCF魔术变得有效?

小智 0

您可以在服务接口类中自定义您的肥皂操作,

    [ServiceContract]
    public interface IMyService
   {
     [OperationContract(
        Action = "MySoapAction" ]
      Message ServiceFunction(Message input);
   }
Run Code Online (Sandbox Code Playgroud)