How to change the address location of my wsdl
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:X开发者_开发知识库WebServiceHttpGet">
<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
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
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:
- <wsdl:port name="XWebServiceHttpPost" binding="tns:XWebServiceHttpPost">
<http:address location="http://thishost.domain.com/XWebService.asmx" />
</wsdl:port>
...to thathost.domain.com:
- <wsdl:port name="XWebServiceHttpPost" binding="tns:XWebServiceHttpPost">
<http:address location="http://thathost.domain.com/XWebService.asmx" />
</wsdl:port>
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:
(.*)XWebservice.asmx
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
<system.webServer>
<rewrite>
<rules>
<rule name="WSDL Rewrite" stopProcessing="true">
<match url="(.*)XWebService.asmx" />
<conditions>
<add input="{QUERY_STRING}" pattern="WSDL" />
<add input="{REQUEST_METHOD}" pattern="GET" />
</conditions>
<action type="Rewrite" url="wsdl.htm" />
</rule>
</rules>
</rewrite>
</system.webServer>
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.
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.
精彩评论