在此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