Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Web services

Web services

Scheduled Pinned Locked Moved ASP.NET
wcfquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chhayaparekh
    wrote on last edited by
    #1

    How do I read elements from WSDL and crat a dropdown list of all methods that are availbel for that perticular Web service.

    I 1 Reply Last reply
    0
    • C chhayaparekh

      How do I read elements from WSDL and crat a dropdown list of all methods that are availbel for that perticular Web service.

      I Offline
      I Offline
      ian mariano
      wrote on last edited by
      #2

      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;
      
      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups