Web services 从Microsoft CRM插件调用soap web服务

Web services 从Microsoft CRM插件调用soap web服务,web-services,plugins,soap,dynamics-crm,Web Services,Plugins,Soap,Dynamics Crm,我有一个插件,在创建新联系人时调用基于soap的web服务。它是一个简单的soap web服务,在调用时显示欢迎消息 下面是app.config,其中包含所有配置要求 <?xml version="1.0"?> <configuration> <system.serviceModel> <bindings> <basicHttpBi

我有一个插件,在创建新联系人时调用基于soap的web服务。它是一个简单的soap web服务,在调用时显示欢迎消息

下面是app.config,其中包含所有配置要求

<?xml version="1.0"?>
        <configuration>
            <system.serviceModel>
                <bindings>
                    <basicHttpBinding>
                        <binding name="WelcomeBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                            <message clientCredentialType="UserName" algorithmSuite="Default"/>
                        </security>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://revesinc.com/WelcomeSeamService/Welcome" binding="basicHttpBinding" bindingConfiguration="WelcomeBinding" contract="ServiceReference1.Welcome" name="WelcomePort"/>
            </client>
        </system.serviceModel>
    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
在CRM中创建联系人时,服务器上不会显示任何内容。CRM方面也不例外。 有什么想法吗???
谢谢

首先,我想问你如何在服务器上显示内容?我不认为使用插件有任何方法可以做到这一点,但可能是我不对。在任何情况下,请显示您正在显示内容的部分代码。
你是说什么也没发生。首先,您应该检查插件是否正确注册。据我所知,您应该检查是否添加了实体联系人和消息创建步骤。此外,通常使用一些模板创建插件。在调用Web服务之前,您的代码部分可能有错误。
我想强调的另一个问题。您有一个包含程序集配置的配置文件。我认为对于插件程序集,最好不要在配置文件中存储任何配置,而是在代码中进行所有设置。

有几种不同的方法来检查插件是否被触发。首先,您不仅可以部署dll,还可以部署pdb文件,并使用调试器连接到IIS进程。如果未安装Visual Studio,则可以使用远程调试器。如果由于某种原因不可能,您可以在代码的开头抛出PluginExecutionException,以确保插件确实被调用。当您确定插件正常工作时,就可以开始使用Web服务进行测试工作了。

首先,我想问您如何在服务器上显示内容?我不认为使用插件有任何方法可以做到这一点,但可能是我不对。在任何情况下,请显示您正在显示内容的部分代码。
你是说什么也没发生。首先,您应该检查插件是否正确注册。据我所知,您应该检查是否添加了实体联系人和消息创建步骤。此外,通常使用一些模板创建插件。在调用Web服务之前,您的代码部分可能有错误。
我想强调的另一个问题。您有一个包含程序集配置的配置文件。我认为对于插件程序集,最好不要在配置文件中存储任何配置,而是在代码中进行所有设置。

有几种不同的方法来检查插件是否被触发。首先,您不仅可以部署dll,还可以部署pdb文件,并使用调试器连接到IIS进程。如果未安装Visual Studio,则可以使用远程调试器。如果由于某种原因不可能,您可以在代码的开头抛出PluginExecutionException,以确保插件确实被调用。当您确定插件正常工作时,就可以开始使用Web服务进行测试工作。

我假设您正在调用某个方法,该方法在这一行后面显示欢迎消息:

 WelcomeClient client = new WelcomeClient(myBinding,endPointAddress);
我建议您使用跟踪服务登录插件。将插件代码放入try-catch中,并在跟踪后抛出InvalidPluginExecutionException

在plugin Execute方法中,您的代码可能如下所示:

试一试 {

                    ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

                    BasicHttpBinding myBinding = new BasicHttpBinding();
                    myBinding.Name = "WelcomeBinding";
                    myBinding.Security.Mode = BasicHttpSecurityMode.None;
                    myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                    myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                    EndpointAddress endPointAddress = new EndpointAddress("http://revesinc.com/WelcomeSeamService/Welcome");
                    WelcomeClient client = new WelcomeClient(myBinding, endPointAddress);
                    client.ShowWelcomeMessage(); // Assuming this is your service method 
                    tracingService.Trace("All went well. service called.");
                    throw new InvalidPluginExecutionException("All went well. Exception just to show the traces on the form");

                }
                catch (Exception ex)
                {
                    tracingService.Trace("Error calling welcome service " + ex.Message);
                    throw new InvalidPluginExecutionException(ex.Message);
                }

如果您的插件注册正确,您将能够在用户操作(创建、更新等)上看到异常。您将从跟踪中知道服务调用是否成功。

我假设您正在调用某个方法,该方法在此行后显示欢迎消息:

 WelcomeClient client = new WelcomeClient(myBinding,endPointAddress);
我建议您使用跟踪服务登录插件。将插件代码放入try-catch,跟踪后抛出InvalidPluginExecutionException

在plugin Execute方法中,您的代码可能如下所示:

试一试 {

                    ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

                    BasicHttpBinding myBinding = new BasicHttpBinding();
                    myBinding.Name = "WelcomeBinding";
                    myBinding.Security.Mode = BasicHttpSecurityMode.None;
                    myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                    myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                    EndpointAddress endPointAddress = new EndpointAddress("http://revesinc.com/WelcomeSeamService/Welcome");
                    WelcomeClient client = new WelcomeClient(myBinding, endPointAddress);
                    client.ShowWelcomeMessage(); // Assuming this is your service method 
                    tracingService.Trace("All went well. service called.");
                    throw new InvalidPluginExecutionException("All went well. Exception just to show the traces on the form");

                }
                catch (Exception ex)
                {
                    tracingService.Trace("Error calling welcome service " + ex.Message);
                    throw new InvalidPluginExecutionException(ex.Message);
                }
如果您的插件注册正确,您将能够在用户操作(创建、更新等)上看到异常。您将从跟踪中知道服务调用是否成功