WCF服务的多个端点配置 [英] WCF Service multiple endpoint configuration
问题描述
我有一个WCF服务:
https://myservice/service.svc
https://myservice/service.svc?wsdl
下面给出我的WCF应用程序的Web.config的相关章节(让我知道如果你需要更多):
Given below are the related section of my WCF Application's web.config (let me know if you need more):
<bindings>
<basicHttpBinding>
<binding name="basicHttp">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyService.ServiceBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="SqlMembershipProvider"/>
</serviceCredentials>
<serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"></serviceThrottling>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.Service">
<endpoint address="/ClientA" binding="basicHttpBinding" bindingConfiguration="basicHttp" name="basicHttpEndpoint" contract="MyService.IService"></endpoint>
<endpoint address="/ClientB" binding="basicHttpBinding" bindingConfiguration="basicHttp" name="basicHttpEndpoint" contract="MyService.IService"></endpoint>
<endpoint address="/ClientC" binding="basicHttpBinding" bindingConfiguration="basicHttp" name="basicHttpEndpoint" contract="MyService.IService"></endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
我希望我的客户能够通过下面的链接访问该服务,但该链接不工作(或者可能是我的语法是错误的下面的链接,让我知道,如果是这样的话)
I want my clients be able to access the service through the following links, but the links don't work: (or may be my syntax is wrong for the links below, let me know if that is the case)
https://myservice/service.svc/ClientA
https://myservice/service.svc/ClientB
https://myservice/service.svc/ClientC
以下链接工作,但我不认为这是由于我的配置,好像我写的最后向前后,任何削减它仍然有效....
following links work, but i don't think this is due to my configuration, as if i write anything after the last forward slash it still works ....
https://myservice/service.svc?wsdl/ClientA
https://myservice/service.svc?wsdl/ClientB
https://myservice/service.svc?wsdl/ClientC
https://myservice/service.svc?wsdl/asfgvafgfgf ... (this works too !!!)
请让我知道如何实现这一目标。我不希望创建的所有客户端单独的服务。
Please let me know how to achieve this. I don't want to create separate service for all clients.
如果这个工程,我想在所有客户端的端点定义使用不同的合同=MyService.IService,作为方法,可用于服务公开的每个客户会有所不同。
if this works, i want to use different contract="MyService.IService" in the endpoint definition for all clients, as the methods for each clients exposed in service would differ.
我也想问问,我会能够指定要使用的连接字符串,这取决于通过其端点客户端访问服务?
i also want to ask, would i be able to specify which connection string to use, depending on via which endpoint client is accessing the service?
和最后:我不想要的:
https://myservice/service.svc
https://myservice/service.svc?wsdl
链接可以访问,我想客户端只使用自己指定的链接...
links to be accessible, i want the clients to use only their specified links ...
是,在所有可能的,或者我应该为每个客户创建单独的服务...?
is that at all possible, or should i create separate services for each client ... ?
感谢。
推荐答案
我觉得它需要在配置文件中的一些设置。
I think it require some setting in config file.
请参阅此链接,
的http://keyvan.io/host-wcf-service-and-asp-net-application-on-same-virtual-directory
这可能会帮助你。
这篇关于WCF服务的多个端点配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!