简体   繁体   English

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

[英]Wrong SOAP Action header in request. Why?

I'm trying connecting to the MS CRM Deployment Service from within CRM plugin (ie I don't have ability to use app.config configuration file). 我正在尝试从CRM插件中连接到MS CRM部署服务(即我无法使用app.config配置文件)。

The issue is it's really difficult to replace 'configuration magic' with source code. 问题是用源代码替换“配置魔术”真的很困难。

While I'm using following configuration file (testing locally in console application): 我正在使用以下配置文件(在控制台应用程序中本地测试):

<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>

Everything is fine, but when I'm trying to replace configuration with code I'm facing with following. 一切都很好,但是当我试图用我正面对的代码替换配置时。 In resulting SOAP message instead of expected header: 在生成的SOAP消息而不是预期的标头中:

<a:Action s:mustUnderstand="1" u:Id="_4">http://schemas.microsoft.com/xrm/2011/Contracts/Services/IDeploymentService/Retrieve</a:Action>

I see something strange: 我看到一些奇怪的事:

<a:Action s:mustUnderstand="1" u:Id="_4">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</a:Action>

Does anybody knows how can I override Action Header and which statement in configuration turns WCF magic making everything work? 有谁知道如何覆盖Action Header以及配置中的哪个语句会使WCF魔术变得有效?

I think you should use something like following configuration 我认为你应该使用类似下面的配置

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

you can customize your soap action in the service interface class, 您可以在服务接口类中自定义soap操作,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM