我有一个简单的服务,我部署到Azure.可通过以下方式访问:
http://xxxxxxxxxxxxxxxxxxxxxxx.cloudapp.net/MyTestService.svc
Run Code Online (Sandbox Code Playgroud)
WSDL的URL使用内部计算机名称而不是公共DNS:
svcutil.exe http://rd001520d328923a/MyTestService.svc?wsdl
Run Code Online (Sandbox Code Playgroud)
显然,无法从机器外部访问WSDL.
我知道如果你在IIS中运行它,或者你知道服务的url,可以改变一些事情.例如,更改<serviceMetadata>配置以指定httpGetUrl属性,但这不起作用,因为我必须包括绝对URL.使用相对URL,它仍然使用内部计算机名称.真正的问题是WSDL包含带有机器名的URL引用,因此使它无用.
有两个不合标准的解决方法:
有人建议我可以抓取WSDL,编辑它来修复URL,然后上传它,以便可以从不同的URL访问它.
我发现2010年初有一个修补程序可用,但必须有一个更好的方法.
如何解决公共面向DNS使用而不是机器名称?
我有一个可以通过http端点访问的WCF Web服务.现在,该服务应通过https与负载均衡器一起发布.客户端是通过svcutil.exe在.Net中创建的,但Java客户端也需要WSDL.
我的理解是:
从其他帖子我了解到负载均衡器问题可以通过以下行为配置来解决:
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<!-- Use your own port numbers -->
<add scheme="http" port="81" />
<add scheme="https" port="444" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
Run Code Online (Sandbox Code Playgroud)
使用这种解决方法,我得到解决,该服务帮助页面两个URL,但调用 的https://loadbalancer.com/example.svc页面使我访问http://loadbalancer.com/example.svc WSDL.当我用https替换http时,我可以加载wsdl,但它的所有内部链接都是http而不是https.
试图切换httpsGetEnabled ="true"会引发我很多与https相关的问题,我不知道这是否可以帮助我,因为我的服务器本身只知道http.
所以,我的问题是负载均衡URL的https.我可以告诉WCF它应该在WSDL元数据而不是http中显示https,我该怎么做?
以下是场景。
我们有 F5 负载均衡器,传入的请求作为 HTTP 进入 F5 负载均衡器,然后它们被重定向到 WCF 服务服务器作为 HTTP。
我已经尝试了几乎所有可能的配置组合,但它不断给出两个不同的错误。例如,根据一些建议,我尝试将安全模式更改为“传输”,然后错误更改为:“无法为具有权限 'xxx.xxx.xxx.xxx:XXXX' 的 SSL/TLS 建立安全通道.”
<system.serviceModel>
<services>
<service behaviorConfiguration="NameofServiceBehaviour" name="NameOfServices">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndPointBinding" name="wsHttpEndPoint" contract="Name.IContractName" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndPointBinding">
<security mode="None">
<!-- <transport clientCredentialType="Certificate" /> -->
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviourName">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<!-- <serviceCredentials>
<serviceCertificate findValue="CN=CertificateName" storeLocation="LocalMachine" />
</serviceCredentials> -->
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndPoint">
<security mode="None" /> …Run Code Online (Sandbox Code Playgroud)