このMSDNの記事 で説明されているセルフホスティングサービスには、2つのサービスがあります。
今、私は他から一方を呼び出したいと思います。1つはデータベース関連のものを実行し、もう1つはいくつかの作業を提供します。他のサービスでデータベース機能を利用したい。
ここで説明したようにサービス参照を追加しようとしました:同様の質問のStackoverflow ですが、「アドレスからのメタデータのダウンロード中にエラーが発生しました」というメッセージが表示されるため、サービス参照を追加できません。
私はすでにクライアントアプリケーションからサービスを使用しているので、サービス自体は実行され、機能しています。
これは私が使用したいサービスのweb.configです。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
そして、これが私のセルフホスティングサービスのApp.configの一部です
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<!-- omitted lots of blocks -->
<services>
<service name="MyProject.WorkService.GeneralWorkService" behaviorConfiguration="SimpleServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/"/>
</baseAddresses>
</host>
<endpoint address="traceability" binding="basicHttpBinding" name="WorkService" contract="MyProject.Service2.Contracts.IService2"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
<service name="MyProject.DatabaseService.GeneralDatabaseService" behaviorConfiguration="SimpleServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/"/>
</baseAddresses>
</host>
<endpoint address="gateway" binding="basicHttpBinding" name="DatabaseService" contract="MyProject.DatabaseService.Contracts.IDatabaseService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<client>
<endpoint name="Service2EP" address="http://localhost/someWork" binding="basicHttpBinding" contract="MyProject.Service2.IService2">
</endpoint>
<endpoint name="DatabaseServiceEP" address="http://localhost/gateway" binding="basicHttpBinding" contract="MyProject.DatabaseService.IDatabaseService">
</endpoint>
</client>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
-アップデート-
ブラウザウィンドウを使用して、サービスを表示できます
http://localhost:8000
おそらく、私のサービスを使用する他の方法があります。で生成できるプロキシを使用する必要がありますsvcutil
か?
おそらくもっと良い方法があります。サービス参照の追加は機能しないようで、理由はわかりません。