在1个端点,WCF,Mono中找不到客户端端点配置“*”

时间:2022-05-13 16:51:26

Hej guys,

i'm trying to access a webservice hosted on a virtual machine (Windows 7) from my Ubuntu Host using Mono.

我正在尝试使用Mono从我的Ubuntu主机访问托管在虚拟机(Windows 7)上的Web服务。

I can import the wdsl file and generate the service reference. I copied the App.config from an other working client accessing the webservice correctly.

我可以导入wdsl文件并生成服务引用。我从正确访问webservice的其他工作客户端复制了App.config。

When i try to connect to the webservice using using System;

当我尝试使用System连接到webservice时;

namespace MonoTest
{
class MainClass
{
    public static void Main (string[] args)
    {
        Console.WriteLine ("Hello World!");
        TestServer.Service1Client client = new TestServer.Service1Client("Test");
        Console.WriteLine(client.GetData(12));
        Console.ReadLine();
    }
}
}

I get an error:

我收到一个错误:

System.InvalidOperationException: Client endpoint configuration 'Test' was not found in 1 endpoints.
  at System.ServiceModel.ChannelFactory.ApplyConfiguration (System.String endpointConfig) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.ChannelFactory.InitializeEndpoint (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.ChannelFactory`1[MonoTest.TestServer.IService1]..ctor (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.ClientBase`1[MonoTest.TestServer.IService1].Initialize (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.ClientBase`1[MonoTest.TestServer.IService1]..ctor (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.ClientBase`1[MonoTest.TestServer.IService1]..ctor (System.String endpointConfigurationName) [0x00000] in <filename unknown>:0 
  at MonoTest.TestServer.Service1Client..ctor (System.String endpointConfigurationName) [0x00000] in <filename unknown>:0 
  at MonoTest.MainClass.Main (System.String[] args) [0x0000a] in /home/***/WebserviceTest/MonoTest/MonoTest/Main.cs:11 

My App.config file looks like the following:

我的App.config文件如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IService1" />
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint name="Test"
                address="http://192.168.178.34:8732/Design_Time_Addresses/TestServer/Service1/"
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
                contract="ServiceReference1.IService1" >
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

Has anyone made this working using Linux?

有没有人使用Linux工作?

2 个解决方案

#1


8  

Mono's WSDL import tool does not support automatic configuration generation yet, you need to manually configure your endpoints in your app.config.

Mono的WSDL导入工具尚不支持自动配置生成,您需要在app.config中手动配置端点。

The error that you're seeing here means that WCF can't find the endpoint configuration section.

您在此处看到的错误意味着WCF无法找到端点配置部分。

The detailed, technical reason for the problem

问题的详细,技术原因

You are getting this because Visual Studio and Mono have a different, incompatible way of referencing the configuration section.

你得到这个是因为Visual Studio和Mono有一种不同的,不兼容的方式来引用配置部分。

When adding a Service Reference in Visual Studio, it automatically creates and updates the corresponding entries in your app.config. The "contract name" that's in the generated <endpoint ... contract="contract name"> is not necessarily the fully qualified name of the data contract class in the generated Reference.cs.

在Visual Studio中添加服务引用时,它会自动创建并更新app.config中的相应条目。生成的 中的“合同名称”不一定是生成的Reference.cs中数据合同类的完全限定名称。

Instead, Visual Studio emits

相反,Visual Studio会发出

    [ServiceContractAttribute(ConfigurationName="contract name")]
    public interface YourContract {
            ....
    }

The ConfigurationName is the same as in the <endpoint ... contract="..."> element, that's how WCF finds the endpoint configuration.

ConfigurationName与 元素中的相同,这就是WCF查找端点配置的方式。

In Mono, since we don't support config file generation yet, we emit

在Mono中,由于我们还不支持配置文件生成,我们会发出

    [ServiceContractAttribute]
    public interface YourContract {
            ....
    }

Without the ConfigurationName argument, the default is the fully qualified name of that interface.

如果没有ConfigurationName参数,则缺省值是该接口的完全限定名称。

How to fix your problem

如何解决您的问题

To get this to work, you need to edit your app.config file and use the fully qualified name of your service contract interface in the <endpoint ... contract="..."> element.

要使其正常工作,您需要编辑app.config文件并在 元素中使用服务合同接口的完全限定名称。

In your case, changing contract="ServiceReference1.IService1" into contract="TestServer.IService1" should do it.

在您的情况下,将contract =“ServiceReference1.IService1”更改为contract =“TestServer.IService1”应该这样做。

Otherwise, look into the generated Reference.cs, search for an interface with a [ServiceContractAttribute] and which C# namespace it is in.

否则,查看生成的Reference.cs,搜索具有[ServiceContractAttribute]的接口以及它所在的C#名称空间。

#2


0  

Mono WCF is partial implemetation of dotnet WCF, hence few feature and binding are unsupported :

Mono WCF是dotnet WCF的部分实现,因此不支持很少的功能和绑定:

There is also a article which says

还有一篇文章说

Components with no plan to support

没有计划支持的组件

WSHttpBinding and its dependencies TransactionFlow ReliableSession

WSHttpBinding及其依赖项TransactionFlow ReliableSession

Please see : http://www.mono-project.com/WCF_Development

请参阅:http://www.mono-project.com/WCF_Development

#1


8  

Mono's WSDL import tool does not support automatic configuration generation yet, you need to manually configure your endpoints in your app.config.

Mono的WSDL导入工具尚不支持自动配置生成,您需要在app.config中手动配置端点。

The error that you're seeing here means that WCF can't find the endpoint configuration section.

您在此处看到的错误意味着WCF无法找到端点配置部分。

The detailed, technical reason for the problem

问题的详细,技术原因

You are getting this because Visual Studio and Mono have a different, incompatible way of referencing the configuration section.

你得到这个是因为Visual Studio和Mono有一种不同的,不兼容的方式来引用配置部分。

When adding a Service Reference in Visual Studio, it automatically creates and updates the corresponding entries in your app.config. The "contract name" that's in the generated <endpoint ... contract="contract name"> is not necessarily the fully qualified name of the data contract class in the generated Reference.cs.

在Visual Studio中添加服务引用时,它会自动创建并更新app.config中的相应条目。生成的 中的“合同名称”不一定是生成的Reference.cs中数据合同类的完全限定名称。

Instead, Visual Studio emits

相反,Visual Studio会发出

    [ServiceContractAttribute(ConfigurationName="contract name")]
    public interface YourContract {
            ....
    }

The ConfigurationName is the same as in the <endpoint ... contract="..."> element, that's how WCF finds the endpoint configuration.

ConfigurationName与 元素中的相同,这就是WCF查找端点配置的方式。

In Mono, since we don't support config file generation yet, we emit

在Mono中,由于我们还不支持配置文件生成,我们会发出

    [ServiceContractAttribute]
    public interface YourContract {
            ....
    }

Without the ConfigurationName argument, the default is the fully qualified name of that interface.

如果没有ConfigurationName参数,则缺省值是该接口的完全限定名称。

How to fix your problem

如何解决您的问题

To get this to work, you need to edit your app.config file and use the fully qualified name of your service contract interface in the <endpoint ... contract="..."> element.

要使其正常工作,您需要编辑app.config文件并在 元素中使用服务合同接口的完全限定名称。

In your case, changing contract="ServiceReference1.IService1" into contract="TestServer.IService1" should do it.

在您的情况下,将contract =“ServiceReference1.IService1”更改为contract =“TestServer.IService1”应该这样做。

Otherwise, look into the generated Reference.cs, search for an interface with a [ServiceContractAttribute] and which C# namespace it is in.

否则,查看生成的Reference.cs,搜索具有[ServiceContractAttribute]的接口以及它所在的C#名称空间。

#2


0  

Mono WCF is partial implemetation of dotnet WCF, hence few feature and binding are unsupported :

Mono WCF是dotnet WCF的部分实现,因此不支持很少的功能和绑定:

There is also a article which says

还有一篇文章说

Components with no plan to support

没有计划支持的组件

WSHttpBinding and its dependencies TransactionFlow ReliableSession

WSHttpBinding及其依赖项TransactionFlow ReliableSession

Please see : http://www.mono-project.com/WCF_Development

请参阅:http://www.mono-project.com/WCF_Development