【发布时间】:2011-09-19 11:53:33
【问题描述】:
我有 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
链接可以访问,我希望客户只使用他们指定的链接...
这完全有可能吗,还是我应该为每个客户创建单独的服务...?
谢谢。
【问题讨论】:
-
你试过没有“/”开头吗?
-
是的,刚刚尝试过,不起作用,资源管理器说找不到页面(与上次尝试相同)我尝试通过以下方式访问它:myservice/service.svc/ClientA ...(我在访问它时做错了什么,我的意思是我的链接有问题...)