使用 WCF (https) 时 WSDL 超链接中的 URL 错误
我的 WCF 服务使用 HTTPS 运行,它显示信息页面,但“要测试此服务,...使用以下语法:”下面的 URL 是:
svcutil.exe https://servername.group.service .com/MyService.svc?wsdl
(服务器的完整地址)
而不是正确的 URL https://my.service.com/MyService.svc?wsdl(分配的主机头),如何让它显示正确的 URL(<服务的 URL> + ?wsdl< /代码>)?
<services>
<service name="MyService" behaviorConfiguration="MyServer.MyServiceBehavior">
<endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBigStrings" contract="IMyService">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyService.MyServiceBehavior">
<serviceCredentials>
<serviceCertificate findValue="my.service.com" x509FindType="FindBySubjectName"/>
</serviceCredentials>
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBigStrings">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
<readerQuotas maxStringContentLength="1048576" />
</binding>
</basicHttpBinding>
</bindings>
我已经尝试将
更改为
但它只是说:“URI https:// 的注册已存在my.service.com/MyService.svc"
I got my WCF Service running with HTTPS, It shows the Infopage, but the URL below "To test this service, ... with the following syntax:" is:
svcutil.exe https://servername.group.service.com/MyService.svc?wsdl
(full address of the server)
Instead of the correct URL https://my.service.com/MyService.svc?wsdl (assigned hostheader), how can I get it to show the right URL (<URL of the Service> + ?wsdl
)?
<services>
<service name="MyService" behaviorConfiguration="MyServer.MyServiceBehavior">
<endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBigStrings" contract="IMyService">
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyService.MyServiceBehavior">
<serviceCredentials>
<serviceCertificate findValue="my.service.com" x509FindType="FindBySubjectName"/>
</serviceCredentials>
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBigStrings">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
<readerQuotas maxStringContentLength="1048576" />
</binding>
</basicHttpBinding>
</bindings>
I already tried to change <serviceMetadata httpsGetEnabled="true"/>
into <serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://my.service.com/MyService.svc"/>
but it just says: "A registration already exists for URI https://my.service.com/MyService.svc"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您指定已设置主机标头。是设置为 SSL 还是只是 Http。请记住,IIS UI 没有用于设置 SSL 主机标头的字段。对于更高版本的 IIS,您需要使用管理脚本 (IIS 6.0) 或 netsh.exe。
You specified that you've set Host Header. Is it set for SSL or just Http. Remember, IIS UI doesn't have fields to set Host-header for SSL. you'd need to use admin scripts (IIS 6.0) or netsh.exe for later version of IIS.
您可以在以下 StackOverflow 链接 - 我要尝试的第一件事(他们给出了一些涉及更多的不同场景)是在服务端点定义上设置监听 URI。当我在应用程序中正确获取 WSDL 地址时遇到问题,我可以对其进行设置来纠正它。在这种情况下,我只是试图修复该方案(我们在 BIGIP 后面,它正在终止 SSL,因此该方案需要是 https,即使服务器端的 WCF 认为它正在获取 http)。
我相信这会为您修复 WSDL
You can find some background on this at the following StackOverflow link - the first thing I would try (they give several different scenarios that are a little more involved) would be to set the Listen URI on the Service Endpoint definition. When I had problems getting the WSDL address right in my app I was able to set that to correct it. In that case I was simply trying to fix the scheme (we were behind a BIGIP and it was terminating SSL so the scheme needed to be https even though WCF on the server side thought it was getting http).
I believe that will fix the WSDL for you