所有,
我对IIS上的WCF有点新,但以前做过一些ASMX Web服务.我的WCF服务已启动并正在运行,但Web服务为我生成的帮助页面具有默认名称,即页面显示:
您已创建了一项服务.
要测试此服务,您需要创建一个客户端并使用它来调用该服务.您可以使用命令行中的svcutil.exe工具执行此操作,语法如下:
svcutil.exe http:// localhost:53456/ServicesHost.svc?wsdl
在标准的ASMX站点中,我将使用方法/类属性为Web服务提供名称和命名空间.当我点击链接时,WSDL有:
<wsdl:definitions name="SearchServices" targetNamespace="http://tempuri.org/"
Run Code Online (Sandbox Code Playgroud)
即不是我的界面中的WCF服务合同名称和命名空间.我假设MEX正在使用某种默认设置,但我想将它们更改为正确的名称.我怎样才能做到这一点?
Nix*_*Nix 37
将此添加到您的服务合同中
[ServiceContract(Namespace = "http://some.com/service/", Name = "ServiceName")]
Run Code Online (Sandbox Code Playgroud)
将此添加到您的服务实现中
[ServiceBehavior(Namespace = "http://some.com/service/")]
Run Code Online (Sandbox Code Playgroud)
将其添加到您的web.config中
<endpoint binding="basicHttpBinding" bindingNamespace="http://myservice.com"....
Run Code Online (Sandbox Code Playgroud)
实际上,它应该放在ServiceBehavior上:
[ServiceBehavior(Namespace = "http://some.com/service/", Name = "ServiceName"]
Run Code Online (Sandbox Code Playgroud)
然后将更改WSDL名称.
| 归档时间: |
|
| 查看次数: |
30056 次 |
| 最近记录: |