Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用于调用外部Web服务的CRM插件_C#_Web Services_Dynamics Crm 2013 - Fatal编程技术网

C# 用于调用外部Web服务的CRM插件

C# 用于调用外部Web服务的CRM插件,c#,web-services,dynamics-crm-2013,C#,Web Services,Dynamics Crm 2013,我们使用的是CRM 2013内部部署,我们正在编写调用外部Web服务的插件。Web服务正在使用WSHttpBinding。基本上,这个插件将在CRM中创建帐户时调用,然后将信息传递到Web服务 这是我的密码: var binding = new WSHttpBinding(SecurityMode.None); //binding.Security.Mode = WSDualHttpSecurityMode.None; binding.MaxReceivedMessageSize = 21474

我们使用的是CRM 2013内部部署,我们正在编写调用外部Web服务的插件。Web服务正在使用WSHttpBinding。基本上,这个插件将在CRM中创建帐户时调用,然后将信息传递到Web服务

这是我的密码:

var binding = new WSHttpBinding(SecurityMode.None);
//binding.Security.Mode = WSDualHttpSecurityMode.None;
binding.MaxReceivedMessageSize = 2147483647;
binding.MaxBufferPoolSize = 2147483647;
binding.SendTimeout = TimeSpan.FromMinutes(3);
binding.ReceiveTimeout = TimeSpan.FromMinutes(3);
binding.OpenTimeout = TimeSpan.FromMinutes(3);
binding.CloseTimeout = TimeSpan.FromMinutes(3);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Message.EstablishSecurityContext = false;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
//binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

var address = new EndpointAddress(ea);

ChannelFactory<IPropertyServiceChannel> factory = new ChannelFactory<IPropertyServiceChannel>(binding, address);
IPropertyServiceChannel channel = factory.CreateChannel();

using (var proxy = new PropertyServiceClient(binding, address))
{
    var tid = new Tid { Dtid = "dMaster", Ptid = "pMain" };

    var newProp = new PropertySetup
    {                  
       //setup data

    };

    proxy.CreateProperty(newProp); //this or below isn't working...
    //channel.CreateProperty(newProp); //this is not working
    //channel.Close(); 
var binding=newwshttpbinding(SecurityMode.None);
//binding.Security.Mode=WSDualHttpSecurityMode.None;
binding.MaxReceivedMessageSize=2147483647;
binding.MaxBufferPoolSize=2147483647;
binding.SendTimeout=TimeSpan.FromMinutes(3);
binding.ReceiveTimeout=TimeSpan.FromMinutes(3);
binding.OpenTimeout=TimeSpan.frommins(3);
binding.CloseTimeout=TimeSpan.FromMinutes(3);
binding.Security.Transport.ClientCredentialType=HttpClientCredentialType.None;
binding.Security.Message.EstablishSecurityContext=false;
binding.Security.Transport.ProxyCredentialType=HttpProxyCredentialType.None;
//binding.Security.Message.ClientCredentialType=BasicHttpMessageCredentialType.UserName;
var地址=新端点地址(ea);
ChannelFactory工厂=新的ChannelFactory(绑定,地址);
IPropertyServiceChannel=factory.CreateChannel();
使用(var proxy=newpropertyserviceclient(绑定,地址))
{
var tid=new tid{Dtid=“dMaster”,Ptid=“pMain”};
var newProp=新属性设置
{                  
//设置数据
};
proxy.CreateProperty(newProp);//此项或以下项不起作用。。。
//channel.CreateProperty(newProp);//这不起作用
//channel.Close();
但是,我不断收到错误消息: “无法处理消息。这很可能是因为操作“”不正确,或者是因为消息包含无效或过期的安全上下文令牌,或者是因为绑定之间不匹配。如果服务由于不活动而中止通道,则安全上下文令牌将无效。要防止服务中止,请执行以下操作。”取消空闲会话会过早地增加服务端点绑定上的接收超时。”


非常感谢您的任何建议。TIA

愚蠢的问题,您能访问服务吗?通过控制台应用程序,您能使用您的服务手动创建实体吗?身份验证工作正常吗?您在prem上,因此用户可能通过kerberos登录并赢得身份验证。您有IFD吗?是的,我们有FD.我创建了一个简单的控制台应用程序,只连接到Web服务,它正在成功连接。但我似乎无法从CRM本身执行此操作。唯一的问题是,我们在注册插件时使用的是沙盒隔离模式。不确定Web服务调用是否在沙盒模式下工作?出于某种原因,我一直在尝试出错g即使我已经是部署管理员,也要在“无”隔离模式下注册插件。感谢它在Prem上,因为部署管理员不应该抱怨在“无”隔离模式下注册。从您的错误中,我将探索身份验证和ADF。以及应用程序池权限。似乎当您发送请求时,我nstead验证用户试图使用crm令牌,并因此而生气。