6

やあみんな、

Monoを使用してUbuntuホストから仮想マシン(Windows 7)でホストされているWebサービスにアクセスしようとしています。

wdslファイルをインポートして、サービス参照を生成できます。Webサービスに正しくアクセスしている他の動作中のクライアントからApp.configをコピーしました。

Systemを使用してWebサービスに接続しようとすると;

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を使用してこれを機能させた人はいますか?

4

2 に答える 2

9

MonoのWSDLインポートツールはまだ自動構成生成をサポートしていません。でエンドポイントを手動で構成する必要がありますapp.config

ここに表示されているエラーは、WCFがエンドポイント構成セクションを見つけられないことを意味します。

問題の詳細な技術的理由

Visual StudioとMonoには、構成セクションを参照するための異なる互換性のない方法があるため、これが発生します。

Visual Studioでサービス参照を追加すると、に対応するエントリが自動的に作成および更新されますapp.config。生成された「コントラクト名」<endpoint ... contract="contract name">は、必ずしも生成されたデータコントラクトクラスの完全修飾名であるとは限りませんReference.cs

代わりに、VisualStudioは

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

これは要素ConfigurationNameの場合と同じであり、 WCFがエンドポイント構成を見つける方法です。<endpoint ... contract="...">

Monoでは、設定ファイルの生成をまだサポートしていないため、

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

引数がないConfigurationName場合、デフォルトはそのインターフェイスの完全修飾名です。

問題を解決する方法

これを機能させるには、ファイルを編集し、要素app.configでサービスコントラクトインターフェイスの完全修飾名を使用する必要があります。<endpoint ... contract="...">

あなたの場合、に変更contract="ServiceReference1.IService1"するcontract="TestServer.IService1"必要があります。

それ以外の場合は、生成されたものを調べて、Reference.csとのインターフェイスと、[ServiceContractAttribute]それが含まれているC#名前空間を検索します。

于 2012-11-27T02:12:47.513 に答える
0

モノラルWCFはドットネットWCFの部分的な実装であるため、サポートされていない機能とバインディングはほとんどありません。

という記事もあります

サポートする予定のないコンポーネント

WSHttpBindingとその依存関係TransactionFlowReliableSession

参照してください: http ://www.mono-project.com/WCF_Development

于 2013-06-04T11:17:40.450 に答える