Asp .net 2.0 Unable to Connect to Remote Server

Discussion in 'ASP .Net Web Services' started by haroldbk, Jul 6, 2006.

  1. haroldbk

    haroldbk Guest

    I have a small Asp .net 2.0 application with a web reference to a
    Webservice.
    Running locally works fine, but when I run it from the Web Server the
    exception Unable to Connect to Remote Server is returned.

    Tried 2 different Web Services - both locally on from the Web server.
    This is a code snippet:
    try

    {

    net.webservicex.www.CurrencyConvertor cc = new
    net.webservicex.www.CurrencyConvertor();

    cc.Url = "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL";

    net.webservicex.www.Currency dollar = net.webservicex.www.Currency.USD;

    net.webservicex.www.Currency shekel = net.webservicex.www.Currency.ILS;

    string rate = cc.ConversionRate(dollar, shekel).ToString();

    Label4.Text = rate;

    }

    catch (Exception ex)

    {

    Label4.Text = ex.Message.ToString();

    }



    Any ideas?

    Thanks,

    Harold
     
    haroldbk, Jul 6, 2006
    #1
    1. Advertising

  2. haroldbk

    Dale Guest

    When you set the URL property, you should probably leave off the ?WSDL. To
    be more sure of what you should set the URL to, check the WSDL file for the
    soap:address element.

    Generally, for a .net web service, this is the asmx address but for other
    web service providers, the WSDL address is used for setting the web reference
    but when setting the URL you will use a completely different address - that
    specified in the soap:address element.

    HTH

    Dale
    --
    Dale Preston
    MCAD C#
    MCSE, MCDBA


    "haroldbk" wrote:

    > I have a small Asp .net 2.0 application with a web reference to a
    > Webservice.
    > Running locally works fine, but when I run it from the Web Server the
    > exception Unable to Connect to Remote Server is returned.
    >
    > Tried 2 different Web Services - both locally on from the Web server.
    > This is a code snippet:
    > try
    >
    > {
    >
    > net.webservicex.www.CurrencyConvertor cc = new
    > net.webservicex.www.CurrencyConvertor();
    >
    > cc.Url = "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL";
    >
    > net.webservicex.www.Currency dollar = net.webservicex.www.Currency.USD;
    >
    > net.webservicex.www.Currency shekel = net.webservicex.www.Currency.ILS;
    >
    > string rate = cc.ConversionRate(dollar, shekel).ToString();
    >
    > Label4.Text = rate;
    >
    > }
    >
    > catch (Exception ex)
    >
    > {
    >
    > Label4.Text = ex.Message.ToString();
    >
    > }
    >
    >
    >
    > Any ideas?
    >
    > Thanks,
    >
    > Harold
    >
    >
    >
     
    Dale, Jul 8, 2006
    #2
    1. Advertising

  3. haroldbk

    haroldbk Guest

    I found the answer.
    I had to add the proxy server to the Web.config file.

    Harold
    "Dale" <> wrote in message
    news:D...
    > When you set the URL property, you should probably leave off the ?WSDL.
    > To
    > be more sure of what you should set the URL to, check the WSDL file for
    > the
    > soap:address element.
    >
    > Generally, for a .net web service, this is the asmx address but for other
    > web service providers, the WSDL address is used for setting the web
    > reference
    > but when setting the URL you will use a completely different address -
    > that
    > specified in the soap:address element.
    >
    > HTH
    >
    > Dale
    > --
    > Dale Preston
    > MCAD C#
    > MCSE, MCDBA
    >
    >
    > "haroldbk" wrote:
    >
    >> I have a small Asp .net 2.0 application with a web reference to a
    >> Webservice.
    >> Running locally works fine, but when I run it from the Web Server the
    >> exception Unable to Connect to Remote Server is returned.
    >>
    >> Tried 2 different Web Services - both locally on from the Web server.
    >> This is a code snippet:
    >> try
    >>
    >> {
    >>
    >> net.webservicex.www.CurrencyConvertor cc = new
    >> net.webservicex.www.CurrencyConvertor();
    >>
    >> cc.Url = "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL";
    >>
    >> net.webservicex.www.Currency dollar = net.webservicex.www.Currency.USD;
    >>
    >> net.webservicex.www.Currency shekel = net.webservicex.www.Currency.ILS;
    >>
    >> string rate = cc.ConversionRate(dollar, shekel).ToString();
    >>
    >> Label4.Text = rate;
    >>
    >> }
    >>
    >> catch (Exception ex)
    >>
    >> {
    >>
    >> Label4.Text = ex.Message.ToString();
    >>
    >> }
    >>
    >>
    >>
    >> Any ideas?
    >>
    >> Thanks,
    >>
    >> Harold
    >>
    >>
    >>
     
    haroldbk, Jul 21, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page