加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 请求中的SOAP Action头错误.为什么?

发布时间:2020-12-15 06:43:28 所属栏目:百科 来源:网络整理
导读:我正在尝试从CRM插件中连接到MS CRM部署服务(即我没有能力使用app.config配置文件). 问题是使用源代码替换“配置魔术”真的很难. 当我使用以下配置文件(在控制台应用程序中本地测试)时: client endpoint address="http://server/XRMDeployment/2011/Deploym
我正在尝试从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="DOMAINDYNAMICS_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();
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读