2012-06-07 64 views
5

HEJ家伙,客户端点配置“*”在1个端点,WCF没有被发现,单

我试图访问托管的虚拟机上的Web服务(Windows 7)中,从我的Ubuntu主机使用单声道。

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

当我尝试使用系统连接到使用 的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(); 
    } 
} 
} 

我得到一个错误:

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 

我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> 

有没有人做这个用Linux工作?

回答

7

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

您在这里看到的错误意味着WCF找不到端点配置节。

的详细的技术原因问题

您收到此,因为Visual Studio和单声道具有参考配置部分的不同,不兼容的方式。

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

相反,Visual Studio中发出

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

ConfigurationName是一样的,在<endpoint ... contract="...">元素,这是WCF如何找到端点配置。

单声道,因为我们不支持配置文件的生成呢,我们发出

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

没有ConfigurationName参数,默认的是接口的全名。

如何解决您的问题

为了得到这个工作,你需要编辑app.config文件,并在<endpoint ... contract="...">元素中使用你的服务合同接口的全名。

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

否则,调查所产生的Reference.cs,搜索与[ServiceContractAttribute]和C#的命名空间是在界面

0

单声道WCF是DOTNET WCF的局部implemetation,因此少数特征和结合不受支持:

也有文章说,这

组件没有计划,以支持

WSHttpBinding and its dependencies TransactionFlow ReliableSession

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

+0

谢谢,问题实际上是那个老,我不再寻找解决方案。但感谢你的帮助! – Sebastian