在此MSDN article 中描述的自託管服務中,有兩個服務。在自託管中的兩個WCF服務之間的通信服務器
現在我想打另一個。一個做一些數據庫相關的東西,另一個提供一些工作。我想在其他服務中使用數據庫功能。
我嘗試添加服務引用這裏提到:Stackoverflow with similar question 但我得到的消息:「有錯誤,從下載地址元數據」, 因此添加一個服務引用是不可能的。
自己的服務正在運行並正在運行,因爲我已經在客戶端應用程序中使用它們。
這是我想要使用的服務的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>
這裏是從我的selfhosting服務從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>
-update-
我可以用一個瀏覽器窗口中看到
http://localhost:8000
我的服務
也許有一些其他方式來使用我的服務即我是否應該使用可以使用svcutil
生成的代理 ?
也許有更好的方法。添加服務參考似乎不工作 ,我不知道爲什麼。
你可以發佈代碼,你從客戶服務調用服務器服務? – Alex 2013-03-01 10:27:39
我沒有代碼,因爲這是我想要實現的 – 2013-03-01 10:59:43