Reflecting a Web Service

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?cg==?=

    Reflecting a Web Service

    Does anyone know how I can hit a generic web service and pull back all
    exposed methods and properties?
  • John Saunders [MVP]

    #2
    Re: Reflecting a Web Service

    "r" <r@discussions. microsoft.comwr ote in message
    news:EE8217EC-8C92-47A4-AD38-82BC6D2B1EE7@mi crosoft.com...
    Does anyone know how I can hit a generic web service and pull back all
    exposed methods and properties?
    Web services don't have methods and properties. They have a WSDL, which may
    point to one or more other WSDL or schema files.

    Also, web services don't have properties. Only methods.

    --
    --------------------------------------------------------------------------------
    John Saunders | MVP – Windows Server System – Connected System Developer

    Comment

    • =?Utf-8?B?cg==?=

      #3
      Re: Reflecting a Web Service

      What I want to do is build a WinForms wizard that allows users to connect to
      a web service and reflect through each of the webmethods bringing back each
      webmethod parameter and it's type.

      Sorry, I wan't clear about "properties ", but I've seen web services which
      contain public class or struct objects, I'd also like to pull methods,
      properties, etc. for those objects, if possible.

      Is there a way for me to use reflection to get this information? If not and
      I need to parse the .WSDL, how do I get the raw XML for the WSDL
      programmaticall y?

      Comment

      • John Saunders [MVP]

        #4
        Re: Reflecting a Web Service

        "r" <r@discussions. microsoft.comwr ote in message
        news:38946815-FA96-4031-9728-212C893927FA@mi crosoft.com...
        What I want to do is build a WinForms wizard that allows users to connect
        to
        a web service and reflect through each of the webmethods bringing back
        each
        webmethod parameter and it's type.
        >
        Sorry, I wan't clear about "properties ", but I've seen web services which
        contain public class or struct objects, I'd also like to pull methods,
        properties, etc. for those objects, if possible.
        >
        Is there a way for me to use reflection to get this information? If not
        and
        I need to parse the .WSDL, how do I get the raw XML for the WSDL
        programmaticall y?
        You're going to have a lot of fun with this. ;-)

        If you're talking about a .ASMX web service in .NET, it will return you its
        WSDL when you send a request to http://localhost/YourService.asmx?WSDL. This
        assumes that it's not configured to ignore such requests.

        You should use the System.Web.Serv ices.Descriptio n.ServiceDescri ption class
        (see
        http://msdn2.microsoft.com/en-us/lib...cription.aspx).
        This has a static Read method that you can pass the above URL to, and it
        will read in the WSDL. It then creates an object model of the WSDL that you
        can navigate through.
        --
        --------------------------------------------------------------------------------
        John Saunders | MVP – Windows Server System – Connected System Developer

        Comment

        • =?Utf-8?B?cg==?=

          #5
          Re: Reflecting a Web Service

          This is exactly what I needed ( I think ;) ) I was already passing in the
          the ?wsdl, but I couldn't get the raw xml, so the ServiceDescript ion class
          looks like the missing piece.

          Thanks!

          "John Saunders [MVP]" wrote:
          "r" <r@discussions. microsoft.comwr ote in message
          news:38946815-FA96-4031-9728-212C893927FA@mi crosoft.com...
          What I want to do is build a WinForms wizard that allows users to connect
          to
          a web service and reflect through each of the webmethods bringing back
          each
          webmethod parameter and it's type.

          Sorry, I wan't clear about "properties ", but I've seen web services which
          contain public class or struct objects, I'd also like to pull methods,
          properties, etc. for those objects, if possible.

          Is there a way for me to use reflection to get this information? If not
          and
          I need to parse the .WSDL, how do I get the raw XML for the WSDL
          programmaticall y?
          >
          You're going to have a lot of fun with this. ;-)
          >
          If you're talking about a .ASMX web service in .NET, it will return you its
          WSDL when you send a request to http://localhost/YourService.asmx?WSDL. This
          assumes that it's not configured to ignore such requests.
          >
          You should use the System.Web.Serv ices.Descriptio n.ServiceDescri ption class
          (see
          http://msdn2.microsoft.com/en-us/lib...cription.aspx).
          This has a static Read method that you can pass the above URL to, and it
          will read in the WSDL. It then creates an object model of the WSDL that you
          can navigate through.
          --
          --------------------------------------------------------------------------------
          John Saunders | MVP – Windows Server System – Connected System Developer
          >
          >

          Comment

          • Jeremy

            #6
            Re: Reflecting a Web Service

            Parsing the wsdl is a lot of work. I know that VS 2005 comes with a utility
            wsdl.exe which if given a url to a web service it will build code (proxy
            classes, etc) to invoke the web service. If you really want to do this
            project, using this as a starting point. Build an app that can query a web
            service wsdl and build proxy class code, then compile the code into a class
            and once compiled use reflection to iterate through methods, parameter types
            etc. wsdl.exe should show you how to query a web service and build proxy
            class code. The reset is easy.

            "r" <r@discussions. microsoft.comwr ote in message
            news:38946815-FA96-4031-9728-212C893927FA@mi crosoft.com...
            What I want to do is build a WinForms wizard that allows users to connect
            to
            a web service and reflect through each of the webmethods bringing back
            each
            webmethod parameter and it's type.
            >
            Sorry, I wan't clear about "properties ", but I've seen web services which
            contain public class or struct objects, I'd also like to pull methods,
            properties, etc. for those objects, if possible.
            >
            Is there a way for me to use reflection to get this information? If not
            and
            I need to parse the .WSDL, how do I get the raw XML for the WSDL
            programmaticall y?

            Comment

            Working...