Web services
ASP.NET
2
Posts
2
Posters
0
Views
1
Watching
-
How do I read elements from WSDL and crat a dropdown list of all methods that are availbel for that perticular Web service.
-
How do I read elements from WSDL and crat a dropdown list of all methods that are availbel for that perticular Web service.
This brute forces it, sample Web Service method scan ASPX page (no real error checking, but you get the picture):
<%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.Xml" %> <html> <head> <title>Web Service Methods</title> <style type="text/css"> body { font: 9pt sans-serif; } input { font: 9pt monospace; } </style> </head> <body> <form name="frmMain" action="webmethods.aspx" runat="server"> <h2>Web Method Scanner</h2> Please enter the URL of the Web Service:<br/> <asp:TextBox id="txtURL" runat="server" width="300"/><br/> <asp:Button id="btnScan" text="Scan" runat="server" OnClick="Scan_OnClick"/><p/> <hr size="1"/> <h3><asp:Label id="lblUrl" runat="server"/></h3> Methods:<br/> <asp:ListBox id="lstMethods" runat="server" width="400" size="10" visible="false"/><p/> <asp:Label id="lblMeths" runat="server"/><p/> <asp:Label id="lblError" runat="server" ForeColor="DarkRed"/> </form> </body> <script language="C#" runat="server"> void ScanService(string url) { lstMethods.Items.Clear(); lblMeths.Text = string.Empty; WebResponse response = null; try { WebRequest req = WebRequest.Create(url); response = req.GetResponse(); XmlDocument doc = new XmlDocument(); using (Stream rs = response.GetResponseStream()) doc.Load(rs); foreach (XmlNode node in doc.DocumentElement.ChildNodes) { if ("portType" == node.Name) foreach (XmlNode op in node.ChildNodes) lstMethods.Items.Add(op.Attributes["name"].Value); } } catch (Exception e) { lblError.Text = e.ToString(); } finally { if (response != null) response.Close(); } } void Scan_OnClick(object sender, EventArgs e) { lblError.Text = string.Empty;