我被告知wsHttpBinding不支持仍需要使用旧版SOAP的旧客户端.我想在同一个WCF服务应用程序中添加一个BasicHttpBinding端点,以便客户端可以使用任一端点,具体取决于它们正在运行的技术.我对每个人使用的地址感到困惑.默认的wsHttpBinding没有设置地址.BasicHttpBinding端点的地址应该是什么?不应该是wsHttpBinding的地址(对于我的例子)http://localhost/WcfService1/Service1.svc?
mar*_*c_s 17
这里有两件事你需要考虑:
如果您在IIS(或WAS作为IIS7的一部分)中托管,则无法设置基址 - 您的服务的基址将是MyService.svc文件所在的虚拟目录.但是,您仍然可以设置相对地址
如果你是自托管的,你通常会在你的配置中添加基地址,这样你就可以不必一直拼出整个地址(但你可以 - 如果你愿意的话).
因此,如果你的MyService.svc内部有一个MyApp在你的localhost机器上调用的虚拟目录,然后使用这个配置:
<service name="MyService" behaviorConfiguration="Default">
<endpoint
address="wsHttp"
binding="wsHttpBinding"
contract="IMyService" />
<endpoint
address="basic"
binding="basicHttpBinding"
contract="IMyService" />
</service>
Run Code Online (Sandbox Code Playgroud)
那么你的"旧式"basicHttp服务将在以下地址到达:
http://localhost/MyApp/MyService.svc/basic
Run Code Online (Sandbox Code Playgroud)
并且您的新wsHttp驱动服务将在以下位置访问:
http://localhost/MyApp/MyService.svc/wsHttp
Run Code Online (Sandbox Code Playgroud)
您可以将.../MyApp/MyService.svc您喜欢的相关地址(后面的任何内容)命名为- 只需确保它们彼此不同即可.
在IIS中托管 - > .svc文件的位置(虚拟目录)将成为您的基本地址.
如果您在控制台应用程序或Windows NT服务中自行托管您的服务,您可以自己设置基本地址:
<services>
<service name="MyService" behaviorConfiguration="Default">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8185/Services/" />
</baseAddresses>
</host>
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
现在在这种情况下,您的"旧式"basicHttp服务将在以下位置访问:
http://localhost:8185/Services/basic
Run Code Online (Sandbox Code Playgroud)
并且您的新wsHttp驱动服务将在以下位置访问:
http://localhost:8185/Services/wsHttp
Run Code Online (Sandbox Code Playgroud)
您可以为每个传输定义基址,例如,一个用于http://,一个用于net.tcp://,依此类推.
当然,如果您真的必须,您还可以在<endpoint>元素内为每个服务端点定义完整的地址- 这为您提供了全面的灵活性(但仅适用于自托管方案).
渣
| 归档时间: |
|
| 查看次数: |
20535 次 |
| 最近记录: |