locked
create dynamic Web Service proxy using wsdl and consume RRS feed

  • Question

  • User195037119 posted

    I'm trying to create a client that can consume a web service given a path to it's wsdl file. I've been trying to use System.Web.Services.Discovery to resolve and retrieve the wsdl file. Does anyone know:

    a) if this is possible?

    b) how to parse the wsdl file to enumerate the available methods and what parameters are required for the methods?

    c) how to create a proxy in run-time (without using wsdl.exe)? 

     

    Thanks

     

    Friday, February 20, 2009 3:37 PM

Answers

  • User11528697 posted
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.6000.16809" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff>
    This is all doable. What you need to do is use WsdlImporter object from System.ServiceModel.Description. This will provide you all the classes that you need to do all the parsing. You may have to read up on WSDL spec as well to understand what all these terms means. You will still need WSDL file location. Append ?wsdl to ASMX file location to get WSDL file for that web service. Something like http://www.myws.com/foo.asmx?wsdl
     
    N
     
    <keyurshah01> wrote in message news:2960658@forums.asp.net...

     thanks for the replies, but I don't think I was clear. I have a dozen or so ASMX Web Services used within our organization, and I need to provide a test client, but I can't add a WebReference to the current project for each Web Service. So, I was hoping to be able to do the following:

    1) accept a url from the user (based on a choice from a list of web services)

    2) create a client object to the web service at runtime for the url provided. For example, when you add a web reference to the project, it creates a proxy that you can then use in your code. I don't want to have to do this manually, I would like to do this in code.

    3) from the proxy, read the list of methods available and their required input parameters

    4) prompt the user for input (i.e. the input required to call a method of their choice)

    5) call the web service

    And so, I'm having issues with #2 and #3

    Sorry I wasn't clear. Thanks for your help!!



    http://forums.asp.net/p/1387900/2960658.aspx#2960658

    </BODY></HTML>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 24, 2009 5:38 AM

All replies

  • User11528697 posted
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.6000.16809" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff>
    As long as your path to WSDL file is correct, discovery tool should be able to create proxy for you. See this link, it will give you a start in that direction.
     
     
    If you are using the tool from VS then you would not have to worry about any parsing. It does the job.
     
    What do you mean by creating proxy at run time? Do you mean u want to construct SOAP payloads yourself? It is all possible, depends on what you are trying to do.
     
    <keyurshah01> wrote in message news:2955781@forums.asp.net...

    I'm trying to create a client that can consume a web service given a path to it's wsdl file. I've been trying to use System.Web.Services.Discovery to resolve and retrieve the wsdl file. Does anyone know:

    a) if this is possible?

    b) how to parse the wsdl file to enumerate the available methods and what parameters are required for the methods?

    c) how to create a proxy in run-time (without using wsdl.exe)? 

     

    Thanks

     



    http://forums.asp.net/p/1387900/2955781.aspx#2955781

    </BODY></HTML>
    Saturday, February 21, 2009 6:42 AM
  • User-41017206 posted

    hi, 

    do following steps -

    Step 1

       Get wsdl file connected by app_Webreference.

       Example  http:/www.abc.come/test/test.wsdl
     
    step 2 

       give one reference name "wsTest".
     
    step 3

       Now u can access webserive like that

       wsTest.test ws = new wsTest.test();

    vinay

    Saturday, February 21, 2009 7:12 AM
  • User195037119 posted

     thanks for the replies, but I don't think I was clear. I have a dozen or so ASMX Web Services used within our organization, and I need to provide a test client, but I can't add a WebReference to the current project for each Web Service. So, I was hoping to be able to do the following:

    1) accept a url from the user (based on a choice from a list of web services)

    2) create a client object to the web service at runtime for the url provided. For example, when you add a web reference to the project, it creates a proxy that you can then use in your code. I don't want to have to do this manually, I would like to do this in code.

    3) from the proxy, read the list of methods available and their required input parameters

    4) prompt the user for input (i.e. the input required to call a method of their choice)

    5) call the web service

    And so, I'm having issues with #2 and #3

    Sorry I wasn't clear. Thanks for your help!!

    Monday, February 23, 2009 10:28 AM
  • User11528697 posted
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.6000.16809" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff>
    This is all doable. What you need to do is use WsdlImporter object from System.ServiceModel.Description. This will provide you all the classes that you need to do all the parsing. You may have to read up on WSDL spec as well to understand what all these terms means. You will still need WSDL file location. Append ?wsdl to ASMX file location to get WSDL file for that web service. Something like http://www.myws.com/foo.asmx?wsdl
     
    N
     
    <keyurshah01> wrote in message news:2960658@forums.asp.net...

     thanks for the replies, but I don't think I was clear. I have a dozen or so ASMX Web Services used within our organization, and I need to provide a test client, but I can't add a WebReference to the current project for each Web Service. So, I was hoping to be able to do the following:

    1) accept a url from the user (based on a choice from a list of web services)

    2) create a client object to the web service at runtime for the url provided. For example, when you add a web reference to the project, it creates a proxy that you can then use in your code. I don't want to have to do this manually, I would like to do this in code.

    3) from the proxy, read the list of methods available and their required input parameters

    4) prompt the user for input (i.e. the input required to call a method of their choice)

    5) call the web service

    And so, I'm having issues with #2 and #3

    Sorry I wasn't clear. Thanks for your help!!



    http://forums.asp.net/p/1387900/2960658.aspx#2960658

    </BODY></HTML>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 24, 2009 5:38 AM
  • User195037119 posted

     Thanks, I haven't got it fully working yet, but I think I'm on the right path!!

    Tuesday, February 24, 2009 10:57 AM