如何更改我的 wsdl 的地址位置
我的 wsdl 在地址位置放置了错误的域,如何修复?
- <wsdl:service name="XWebService">
- <wsdl:port name="XServiceSoap" binding="tns:XWebServiceSoap">
<soap:address location="https://machine.wrongdomain.com.br/webservices/MapleStoryWebService.asmx" />
</wsdl:port>
- <wsdl:port name="XWebServiceSoap12" binding="tns:XWebServiceSoap12">
<soap12:address location="https://machine.wrongdomain.com.br/webservices/XWebService.asmx" />
</wsdl:port>
- <wsdl:port name="XWebServiceHttpGet" binding="tns:XWebServiceHttpGet">
<http:address location="https://machine.wrongdomain.com.br/webservices/MapleStoryWebService.asmx" />
</wsdl:port>
- <wsdl:port name="XWebServiceHttpPost" binding="tns:XWebServiceHttpPost">
<http:address location="https://machine.wrongdomain.com.br/webservices/XWebService.asmx" />
</wsdl:port>
</wsdl:service>
My wsdl put a wrong domain in address location, How to fix it?
- <wsdl:service name="XWebService">
- <wsdl:port name="XServiceSoap" binding="tns:XWebServiceSoap">
<soap:address location="https://machine.wrongdomain.com.br/webservices/MapleStoryWebService.asmx" />
</wsdl:port>
- <wsdl:port name="XWebServiceSoap12" binding="tns:XWebServiceSoap12">
<soap12:address location="https://machine.wrongdomain.com.br/webservices/XWebService.asmx" />
</wsdl:port>
- <wsdl:port name="XWebServiceHttpGet" binding="tns:XWebServiceHttpGet">
<http:address location="https://machine.wrongdomain.com.br/webservices/MapleStoryWebService.asmx" />
</wsdl:port>
- <wsdl:port name="XWebServiceHttpPost" binding="tns:XWebServiceHttpPost">
<http:address location="https://machine.wrongdomain.com.br/webservices/XWebService.asmx" />
</wsdl:port>
</wsdl:service>
The true domain is like https://machine.goodDomain.com.br
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
该地址取自用于访问 WSDL 的 URL。如果它与您想要实际提供服务的服务器不同,那么您可以通过创建一个扩展 SoapExtensionReflector 的类来更改它。以下是有关如何更改 URL 的示例文章:
http:// /blogs.msdn.com/kaevans/archive/2005/11/16/493496.aspx
The address is taken from the URL used to access the WSDL. If it's different than the server you want to actually serve from, then you could change it by creating a class that extends SoapExtensionReflector. Here's a sample article on how to change the URL:
http://blogs.msdn.com/kaevans/archive/2005/11/16/493496.aspx
另一种选择是使用 IIS URL 重写模块 (http://www.iis.net/ downloads/microsoft/url-rewrite)
首先 - 捕获 XWebService.asmx?WSDL 的输出并将其保存为 HTML 文件(例如 wsdl.htm)。
编辑此文件并将位置更改为备用地址
...从thishost.domain.com:
...到thathost.domain.com:
在 IIS 中 - 在网站/虚拟功能视图中找到 URL 重写图标。然后点击添加规则并选择入站规则 - 空白规则。
使用规则 - 对其进行适当命名并设置将接收 WSDL 请求的 Web 服务 URL 的模式匹配。对于正则表达式:
对于条件,将 {QUERY_STRING} 与 WSDL 匹配,将 {REQUEST_METHOD} 与 GET 匹配。
对于操作 - 将其设置为重写(因此这对客户端来说是透明的)并选择我们之前保存的文件(wsdl.htm)。
这还会向 web.config 的 system.webServer 部分添加一个新的 rewrite 部分
Another option is to use the IIS URL Rewrite module (http://www.iis.net/downloads/microsoft/url-rewrite)
First up - capture the output from XWebService.asmx?WSDL and save it as an HTML file (e.g. wsdl.htm).
Edit this file and change the location to the alternative address
... from thishost.domain.com:
...to thathost.domain.com:
In IIS - find the URL Rewrite icon in the website/virtual Feature View . Then click Add Rule(s) and choose Inbound Rule - Blank rule.
With the rule - name it appropriately and set the pattern match for the webservice URL that will receive the WSDL request. For RegEx:
For the conditions match {QUERY_STRING} to WSDL and {REQUEST_METHOD} to GET.
For the Action - set it to Rewrite (so this is transparent to the client) and choose the file that we saved it as earlier (wsdl.htm).
This also adds a new rewrite section to the system.webServer section of the web.config
为什么不直接手动将 WSDL 文件中的地址编辑为应有的地址呢?
如果 WSDL 是由其他工具生成的,请告诉我们它是如何生成的,也许我们可以提供帮助。否则,没有法律禁止修改生成的文件以满足您的需要。如果原始用户环境的 WSDL 的问题只是 URL 错误,那么直接修改 URL 是完全合法的。
Why not just manually edit the address in the WSDL file to what it should be?
If the WSDL is generated by some other tool, then let us know how it is being generated and perhaps we can help. Otherwise, there is no law against modifying the generated file to suit your needs. If all that is wrong with the WSDL for the original users's environment is that the URL is wrong then it is perfectly legitimate to modify the URL directly.
最初的反应是正确的。 WSDL 中的默认 URL 取决于用于访问 WSDL 的 URL。
我的团队过去处理更改服务 URL 的方式(例如,从开发环境过渡到测试或生产环境)是使用 wsdl.exe 为 Web 服务生成代码代理(代理实际上是通过创建web 或服务引用,但默认情况下不会显示在 Visual Studio 中),您可以编辑生成的代理类,以从 (??) 任何您想要存储它的位置(数据库、配置文件等)读取服务的 URL。
The initial response is correct. The default URL in the WSDL is dependent upon the URL used to access the WSDL.
The way my team handled changing service URLs in the past (for instance, transitioning from a development to a testing or production environment) is to use wsdl.exe to generate a code proxy for your web service (a proxy is actually created by making a web or service reference as well, but is not displayed in Visual Studio by default), you can edit the generated proxy class to read the service's URL from (??) wherever you want to store it - database, config file etc.
解决方案很少,我将从简单到准确进行排序。 :)
Url
属性,就像在这种情况下一样:明显的缺点:很可能您将无法使用生成的 html 正确测试服务(我的意思是生成的表单对于网络方法)。
wsdlHelpGenerator
。我没有测试这个解决方案,但乍一看,如果您基于原始的 DefaultWsdlHelpGenerator.aspx 创建自己的解决方案,它看起来就足够简单了(您可以在 C:\Windows\Microsoft.aspx 中找到它)。 NET\Framework* 文件夹,在我的例子中是 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\DefaultWsdlHelpGenerator.aspx)。
创建一个处理程序(下面的示例将把 http 更改为 https):
在 web.config 中注册它:
缺点:无法控制 HttpPost/HttpGet 协议。
创建2个类,流装饰器:
和模块:
然后在web.config中注册模块:
请注意,上面的注册是针对集成模式的,对于经典模式,您需要在
system.web
中注册它。因此,在我们的遗留项目中,我使用了 3+4 方法,但如果我想再次这样做,我会尝试使用#2 方法。 :)
There are few solution, I will sort them from simplicity to accuracy. :)
Url
property on a client side, like in that case:Obvious drawback: most probably you will not able to test the service properly using generated html (I mean generated forms for web methods).
wsdlHelpGenerator
.I didn't test this solution, but at a glance it looks simply enough if you create your own based on original DefaultWsdlHelpGenerator.aspx (you can find it in C:\Windows\Microsoft.NET\Framework* folders, in my case it was C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\DefaultWsdlHelpGenerator.aspx).
soapExtensionReflectorTypes
. It will allow you to do anything with your HttpSoap protocol addresses.Create a handler (sample below will change http to https):
Register it in web.config:
A drawback: no control over HttpPost/HttpGet protocols.
Create 2 classes, stream decorator:
and the module:
Then register the module in web.config:
Please note, the registration above is for integration mode, for classic one you need to register it inside
system.web
.So, in our legacy project I used 3+4 approach, but if I'd want to do that again, I will try to use #2 approach instead. :)