WCF VSTO客户端无法找到默认的端点win2k8部署时,客户端、WCF、VSTO

2023-09-04 06:22:01 作者:扶苏

我创建和Win2008R2终端服务器上部署WCF客户端(从VSTO Word中加载项启动)。 当excution的WCF代理的默认构造函数的 InvalidOperationException异常被抛出,说明为合同默认的端点无法找到。

I created and deployed a WCF client (launched from a VSTO Word Addin) on a Win2008R2 Terminal Server. When excution the default constructor of the WCF proxy an InvalidOperationException is thrown, stating that the default endpoint for the contract cannot be found.

在部署到Win7的X64机器同样WCF客户端只使用相同的.dll.config运行正常

The same WCF client when deployed to a Win7 x64 machine just runs fine using the same .dll.config

我试图创建内部PowerShell的一个实例,并收到同样的错误。

I tried to create an instance inside PowerShell and receive the same error.

如果在PowerShell中创建一个端点奉献我可以EXCUTE服务方式:

If creating a dedicate endpoint in PowerShell I can excute a service method:

$binding = New-Object System.ServiceModel.BasicHttpBinding
$endpoint = New-Object System.ServiceModel.EndPointAddress("http://myserver:7777/CompanyService.svc")
$client = New-Object MyClient.CompanyServiceReference.CompanyServiceClient($binding, $endpoint)
$v = $client.Version()

服务的Web.config(部分)

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="NoHttpSecurity" sendTimeout="00:03:00">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <services>
        <service name="CompanyService">
            <endpoint address="http://myserver:7777/mex" contract="IMetadataExchange" binding="mexHttpBinding" />
            <endpoint name="Version" address="http://myserver:7777/Version" contract="MyService.ICompanyService" binding="basicHttpBinding" bindingConfiguration="NoHttpSecurity" />
            <endpoint name="CompanyList" address="http://myserver:7777/CompanyList" contract="MyService.ICompanyService" binding="basicHttpBinding" bindingConfiguration="NoHttpSecurity" />
        </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

MyClient.dll.config(部分)

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_ICompanyService" closeTimeout="00:01:00">
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://myserver:7777/CompanyService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICompanyService"
         contract="CompanyServiceReference.ICompanyService" name="BasicHttpBinding_ICompanyService" />
    </client>
</system.serviceModel>

更新

我固定这个复制我Client.config到Office程序文件夹,并将其重命名为WINWORD.EXE.config。

I "fixed" this by copying my Client.config to the Office Program Folder and renaming it to WINWORD.EXE.config.

推荐答案

可以编程方式创建一个终结点?

Can you create an endpoint programmatically?

MyProxy proxy = new MyProxy (new BasicHttpBinding(), new EndpointAddress("http://server/Service.svc"));

如果工作正常,那么很可能它的是的配置问题。

If this works, then very probably it is a configuration issue.