[英]How to get the binding address from a WSDL file
我生成了给定WSDL URL的代理类。
我需要让最终用户将服务的URL更改为其特定的URL,如下所示:
ServiceProxy.Url = [URL set by end-user];
问题在于此URL不应指向WSDL,它应该是在WSDL中找到的绑定地址(wsdl:service-> wsdl:port-> wsdl:address)(这是SAP Web服务,我了解这就是为什么我必须使用绑定地址)。
我正在考虑使用XDocument类来获取该值,但是我想知道WCF或Web服务中是否有任何“内置”功能来获取绑定地址。 谢谢。
我在VB.NET中做了一个小功能(很抱歉!),它基于Parse Complex WSDL Parameter Information中的代码。 希望能帮助到你。
Public Function GetURLFromWSDL(ByVal wsdl As String) As String
Dim request As HttpWebRequest = WebRequest.Create(wsdl)
request.ContentType = "text/xml;charset=""utf-8"""
request.Method = "GET"
request.Accept = "text/xml"
Using response As WebResponse = request.GetResponse()
Using stream As Stream = response.GetResponseStream()
Dim service As ServiceDescription = ServiceDescription.Read(stream)
Dim binding As SoapAddressBinding = service.Services(0).Ports(0).Extensions(0)
Return binding.Location
End Using
End Using
End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.