[英]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.