[英]WCF Service multiple endpoint configuration
我有WCF服务:
https://myservice/service.svc
https://myservice/service.svc?wsdl
以下是WCF应用程序的web.config的相关部分(如果需要更多信息,请告诉我):
<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>
我希望我的客户能够通过以下链接访问该服务,但是这些链接不起作用:(或者可能是我的语法对于下面的链接是错误的,请告诉我是这样)
https://myservice/service.svc/ClientA
https://myservice/service.svc/ClientB
https://myservice/service.svc/ClientC
以下链接有效,但我不认为这是由于我的配置所致,好像我在最后一个正斜杠之后写了任何东西一样……。
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 !!!)
请让我知道如何实现这一目标。 我不想为所有客户创建单独的服务。
如果可行,我想在端点定义中为所有客户端使用不同的contract =“ MyService.IService”,因为在服务中公开的每个客户端的方法都会有所不同。
我还想问一下,我能否指定要使用哪个连接字符串,取决于通过哪个端点客户端访问服务?
最后:我不要:
https://myservice/service.svc
https://myservice/service.svc?wsdl
链接是可访问的,我希望客户仅使用其指定的链接...
这是完全有可能的,还是我应该为每个客户创建单独的服务...?
谢谢。
我认为它需要在配置文件中进行一些设置。
看到这个链接,
http://keyvan.io/host-wcf-service-and-asp-net-application-on-same-virtual-directory
这可能会帮助您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.