如何将 WSDL URL 从内部机器名称更改为公共? [英] How to change WSDL URL from internal machine name to public?

查看:21
本文介绍了如何将 WSDL URL 从内部机器名称更改为公共?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个部署到 Azure 的简单服务.可通过以下方式访问:

I have a simple service that I deployed to Azure. It is accessible via:

http://xxxxxxxxxxxxxxxxxxxxxxx.cloudapp.net/MyTestService.svc

WSDL 的 URL 使用内部机器名称而不是公共 DNS:

The URL to the WSDL uses the internal machine name instead of a public DNS:

svcutil.exe http://rd001520d328923a/MyTestService.svc?wsdl

显然,使用此方法无法从机器外部访问 WSDL.

Obviously, the WSDL is not accessible from outside the machine with this.

如果您在 IIS 中运行它,或者如果您知道服务的 url,我知道一些可以更改的内容.例如,更改 配置以指定 httpGetUrl 属性,但这将不起作用,因为我必须包含绝对 URL.使用相对 URL,它仍然使用内部机器名称.真正的问题是 WSDL 包含带有机器名称的 URL 引用,因此使其无用.

I am aware of a few things that can be changed if you are running this in IIS, or if you do know the url of the service. For example changing the <serviceMetadata> config to specify the httpGetUrl property, but this will not work as I would have to include the absolute URL. Using a relative URL, it still uses the internal machine name. The real issue is that the WSDL includes URL references with the machine name, therefore rendering it useless.

有两种不合标准的解决方法:

There are two substandard workarounds:

  • 有人建议我可以获取 WSDL,对其进行编辑以修复 URL,然后上传它以便可以从不同的 URL 访问它.

  • It has been suggested that I could grab the WSDL, edit it to fix the URLs and then upload it so it is accessible from a different URL.

我发现 2010 年初的修补程序可用,但必须有更好的方法.

I found a hotfix from early 2010 was available, but there's got to be a better way.

如何解决使用面向公众的 DNS 而不是机器名称的问题?

How can this be solved to have the public facing DNS used instead of the machine name?

推荐答案

好的.我一直在看这个近一个星期.我终于找到了答案,因为它不容易获得我希望它被索引并为其他人节省时间.

Ok. I have been looking at this for almost a week. I finally found the answer, since it is not easily available I hope this gets indexed and save the time for others.

基本上,这种整体行为是 WCF 3.0/3.5 的一个已知问题,他们为此发布了修补程序.您可以在此处找到更多信息:FIX:WCF WSDL 文档中的 URI 是指无法访问的内部实例而不是负载平衡器...

Basically this overall behavior as a known issue with WCF 3.0/3.5, for which they released a hotfix. You can find out more here: FIX: URIs in a WCF WSDL document refer to inaccessible internal instances instead of to the load balancer...

我在研究过程中遇到过几次这个问题,但从未想过第二个想法,主要是因为我不知道如何将修补程序部署到 Azure 中.

I had come across this a few times during my research but never gave it a 2nd thought, mostly because I had no idea how I would deploy a hotfix into Azure.

幸运的是,MSDN 论坛的一位 Microsoft 版主指出,此问题已在 .net 4.0 中修复.这意味着上面知识库文章中推荐的修复"仍然适用,但不必应用任何修补程序.那么解决方案是什么?很简单,在配置文件中添加以下内容:

Fortunately, a Microsoft moderator at the MSDN forums pointed out that this had been fixed in .net 4.0. What this meant was that the "fix" recommended in the KB article above, still applied, with the exception that no hotfix had to be applied. So what is the solution? Simple, add the following to the config file:

<serviceBehaviors>
   <behavior name="<name>">
     <!-- Other options would go here -->
     <useRequestHeadersForMetadataAddress>
       <defaultPorts> <!-- Use your own port numbers -->
          <add scheme="http" port="81" />
          <add scheme="https" port="444" />
        </defaultPorts>
      </useRequestHeadersForMetadataAddress>
   </behavior>
</serviceBehaviors>

就是这样.如果现在已经更清楚地解决了这个问题,这将是一个更简单的搜索.可能是我看的不够仔细.

And that was it. This would have been a much simpler search if it had been clearer that this issue had now been fixed. Perhaps I didnt look hard enough.

这篇关于如何将 WSDL URL 从内部机器名称更改为公共?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆