proxy error when consuming web service

Discussion in 'ASP .Net Web Services' started by J Ames, Jul 17, 2006.

  1. J Ames

    J Ames Guest

    I'm confused on this one. I work behind our company firewall. I created a
    web service that accesses an external web site, using the WebProxy class,
    and when I test the web service in the browser, it works perfectly. It
    passes the correct credentials and returns data as expected. However, when
    I attempt to consume the web service in an ASP.NET project, it fails. I'm
    getting a http error (bad gateway), so I think it's failing at the proxy.
    I'm not sure why it would do that since it sets the proxy credentials in the
    service and works on a browser http request.

    Is there some other step I need to take?

    Thanks,
    J
     
    J Ames, Jul 17, 2006
    #1
    1. Advertising

  2. J Ames

    Guest

    If you're consuming a web service on your local machine then a web
    proxy does not need to be set.

    J Ames wrote:
    > I'm confused on this one. I work behind our company firewall. I created a
    > web service that accesses an external web site, using the WebProxy class,
    > and when I test the web service in the browser, it works perfectly. It
    > passes the correct credentials and returns data as expected. However, when
    > I attempt to consume the web service in an ASP.NET project, it fails. I'm
    > getting a http error (bad gateway), so I think it's failing at the proxy.
    > I'm not sure why it would do that since it sets the proxy credentials in the
    > service and works on a browser http request.
    >
    > Is there some other step I need to take?
    >
    > Thanks,
    > J
     
    , Jul 17, 2006
    #2
    1. Advertising

  3. J Ames

    Guest

    My bad, I did not read your question carefully.
    So you've already done something like the following.

    'Assume RemoteWebService is a remote web service proxy class.
    Dim remoteWebService As New RemoteWebService

    'WebProxy to get request past company firewall
    Dim wp As New WebProxy("http://webproxy.example.com", 80)
    'Assign a user credentials to wp
    wp.Credentials = New NetworkCredentials("myusername", "mypassword",
    "mydomain")

    remoteWebService.Proxy = pr

    'Call a webmethod on the remote web service
    Dim myResults As String = remoteWebService.GetSomeResults()

    Andy

    wrote:
    > If you're consuming a web service on your local machine then a web
    > proxy does not need to be set.
    >
    > J Ames wrote:
    > > I'm confused on this one. I work behind our company firewall. I created a
    > > web service that accesses an external web site, using the WebProxy class,
    > > and when I test the web service in the browser, it works perfectly. It
    > > passes the correct credentials and returns data as expected. However, when
    > > I attempt to consume the web service in an ASP.NET project, it fails. I'm
    > > getting a http error (bad gateway), so I think it's failing at the proxy.
    > > I'm not sure why it would do that since it sets the proxy credentials in the
    > > service and works on a browser http request.
    > >
    > > Is there some other step I need to take?
    > >
    > > Thanks,
    > > J
     
    , Jul 17, 2006
    #3
  4. J Ames

    J Ames Guest

    What is the reference to "pr"?

    Actually, I *didn't* pass anything to the proxy property of the service
    object in my client app. I set all that up in the web service itself
    directly. So when I do an http test in the browser of the service it uses
    the credentials and returns data successfully. It's when I create a client
    app to consume that service that the proxy seems to fail. Are you saying I
    need to set the proxy property *again* in the client web app?

    J

    <> wrote in message
    news:...
    > My bad, I did not read your question carefully.
    > So you've already done something like the following.
    >
    > 'Assume RemoteWebService is a remote web service proxy class.
    > Dim remoteWebService As New RemoteWebService
    >
    > 'WebProxy to get request past company firewall
    > Dim wp As New WebProxy("http://webproxy.example.com", 80)
    > 'Assign a user credentials to wp
    > wp.Credentials = New NetworkCredentials("myusername", "mypassword",
    > "mydomain")
    >
    > remoteWebService.Proxy = pr
    >
    > 'Call a webmethod on the remote web service
    > Dim myResults As String = remoteWebService.GetSomeResults()
    >
    > Andy
    >
    > wrote:
    >> If you're consuming a web service on your local machine then a web
    >> proxy does not need to be set.
    >>
    >> J Ames wrote:
    >> > I'm confused on this one. I work behind our company firewall. I
    >> > created a
    >> > web service that accesses an external web site, using the WebProxy
    >> > class,
    >> > and when I test the web service in the browser, it works perfectly. It
    >> > passes the correct credentials and returns data as expected. However,
    >> > when
    >> > I attempt to consume the web service in an ASP.NET project, it fails.
    >> > I'm
    >> > getting a http error (bad gateway), so I think it's failing at the
    >> > proxy.
    >> > I'm not sure why it would do that since it sets the proxy credentials
    >> > in the
    >> > service and works on a browser http request.
    >> >
    >> > Is there some other step I need to take?
    >> >
    >> > Thanks,
    >> > J

    >
     
    J Ames, Jul 17, 2006
    #4
  5. J Ames

    Guest

    I meant.
    > > remoteWebService.Proxy = wp

    pr was an instance of WebProxy used in our production code.

    Andy

    J Ames wrote:
    > What is the reference to "pr"?
    >
    > Actually, I *didn't* pass anything to the proxy property of the service
    > object in my client app. I set all that up in the web service itself
    > directly. So when I do an http test in the browser of the service it uses
    > the credentials and returns data successfully. It's when I create a client
    > app to consume that service that the proxy seems to fail. Are you saying I
    > need to set the proxy property *again* in the client web app?
    >
    > J
    >
    > <> wrote in message
    > news:...
    > > My bad, I did not read your question carefully.
    > > So you've already done something like the following.
    > >
    > > 'Assume RemoteWebService is a remote web service proxy class.
    > > Dim remoteWebService As New RemoteWebService
    > >
    > > 'WebProxy to get request past company firewall
    > > Dim wp As New WebProxy("http://webproxy.example.com", 80)
    > > 'Assign a user credentials to wp
    > > wp.Credentials = New NetworkCredentials("myusername", "mypassword",
    > > "mydomain")
    > >
    > > remoteWebService.Proxy = pr
    > >
    > > 'Call a webmethod on the remote web service
    > > Dim myResults As String = remoteWebService.GetSomeResults()
    > >
    > > Andy
    > >
    > > wrote:
    > >> If you're consuming a web service on your local machine then a web
    > >> proxy does not need to be set.
    > >>
    > >> J Ames wrote:
    > >> > I'm confused on this one. I work behind our company firewall. I
    > >> > created a
    > >> > web service that accesses an external web site, using the WebProxy
    > >> > class,
    > >> > and when I test the web service in the browser, it works perfectly. It
    > >> > passes the correct credentials and returns data as expected. However,
    > >> > when
    > >> > I attempt to consume the web service in an ASP.NET project, it fails.
    > >> > I'm
    > >> > getting a http error (bad gateway), so I think it's failing at the
    > >> > proxy.
    > >> > I'm not sure why it would do that since it sets the proxy credentials
    > >> > in the
    > >> > service and works on a browser http request.
    > >> >
    > >> > Is there some other step I need to take?
    > >> >
    > >> > Thanks,
    > >> > J

    > >
     
    , Jul 17, 2006
    #5
  6. J Ames

    J Ames Guest

    So I need to set the proxy in the web service object in my client app? Not
    sure I understand why it's necessary since the service itself is behind the
    firewall.

    <> wrote in message
    news:...
    >I meant.
    >> > remoteWebService.Proxy = wp

    > pr was an instance of WebProxy used in our production code.
    >
    > Andy
    >
    > J Ames wrote:
    >> What is the reference to "pr"?
    >>
    >> Actually, I *didn't* pass anything to the proxy property of the service
    >> object in my client app. I set all that up in the web service itself
    >> directly. So when I do an http test in the browser of the service it
    >> uses
    >> the credentials and returns data successfully. It's when I create a
    >> client
    >> app to consume that service that the proxy seems to fail. Are you saying
    >> I
    >> need to set the proxy property *again* in the client web app?
    >>
    >> J
    >>
    >> <> wrote in message
    >> news:...
    >> > My bad, I did not read your question carefully.
    >> > So you've already done something like the following.
    >> >
    >> > 'Assume RemoteWebService is a remote web service proxy class.
    >> > Dim remoteWebService As New RemoteWebService
    >> >
    >> > 'WebProxy to get request past company firewall
    >> > Dim wp As New WebProxy("http://webproxy.example.com", 80)
    >> > 'Assign a user credentials to wp
    >> > wp.Credentials = New NetworkCredentials("myusername", "mypassword",
    >> > "mydomain")
    >> >
    >> > remoteWebService.Proxy = pr
    >> >
    >> > 'Call a webmethod on the remote web service
    >> > Dim myResults As String = remoteWebService.GetSomeResults()
    >> >
    >> > Andy
    >> >
    >> > wrote:
    >> >> If you're consuming a web service on your local machine then a web
    >> >> proxy does not need to be set.
    >> >>
    >> >> J Ames wrote:
    >> >> > I'm confused on this one. I work behind our company firewall. I
    >> >> > created a
    >> >> > web service that accesses an external web site, using the WebProxy
    >> >> > class,
    >> >> > and when I test the web service in the browser, it works perfectly.
    >> >> > It
    >> >> > passes the correct credentials and returns data as expected.
    >> >> > However,
    >> >> > when
    >> >> > I attempt to consume the web service in an ASP.NET project, it
    >> >> > fails.
    >> >> > I'm
    >> >> > getting a http error (bad gateway), so I think it's failing at the
    >> >> > proxy.
    >> >> > I'm not sure why it would do that since it sets the proxy
    >> >> > credentials
    >> >> > in the
    >> >> > service and works on a browser http request.
    >> >> >
    >> >> > Is there some other step I need to take?
    >> >> >
    >> >> > Thanks,
    >> >> > J
    >> >

    >
     
    J Ames, Jul 18, 2006
    #6
  7. J Ames

    J Ames Guest

    I'm still getting the same error. Would it help to see the service code
    itself? I'm pasting it below in case someone can decipher. Thanks.

    using System;
    using System.IO;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Web.Services;
    using System.Net;
    using System.Web;


    /// <summary>
    /// Summary description for StockServices.
    /// </summary>
    [WebService (Namespace="http://enterprise.intranet.com")]
    public class StockServices : System.Web.Services.WebService
    {
    WebProxy myProxy;

    public StockServices()
    {
    InitializeComponent();
    }

    #region Component Designer generated code

    //Required by the Web Services Designer
    private IContainer components = null;

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if(disposing && components != null)
    {
    components.Dispose();
    }
    base.Dispose(disposing); }

    #endregion

    [WebMethod]
    public string GetQuote(string ticker)
    {
    string stockURL, page, retval;
    try
    {
    stockURL = GetURL(ticker);
    page = GetPageContent(stockURL);
    retval = ParsePage(page);
    }
    catch (ArgumentOutOfRangeException)
    {
    retval = "Invalid Ticker!";
    }
    catch (Exception)
    {
    retval = "Unknown Error";
    }

    return retval;
    }

    [WebMethod]
    public DataSet GetQuotes(string tickers)
    {
    char[] splitter = {' '};
    string[] _tickers = tickers.Trim().Split(splitter);
    Int32 i, ticks;

    ticks = _tickers.Length;

    DataSet ds = new DataSet();
    DataTable dt = new DataTable("StockData");
    DataColumn dc;

    dc = dt.Columns.Add("Ticker",System.Type.GetType("System.String"));
    dc = dt.Columns.Add("Price",System.Type.GetType("System.String"));

    for (i = 0; i < ticks; i++)
    {
    DataRow dr = dt.NewRow();
    dr["Ticker"] = _tickers.ToUpper();
    dr["Price"] = GetQuote(_tickers);
    dt.Rows.Add(dr);
    }

    ds.Tables.Add(dt);
    return ds;
    }

    public void SetProxy()
    {
    myProxy = new WebProxy("000.000.000.000", 80);
    myProxy.Credentials = new NetworkCredential("sysid", "syspw");
    }

    private string GetURL(string ticker)
    {
    StringBuilder url = new StringBuilder();

    url.Append("http://finance.yahoo.com/q/ecn?s=");
    url.Append(ticker);

    return url.ToString();
    }

    private string ParsePage(string page)
    {
    Int32 i;

    i = page.IndexOf("Last Trade:");
    page = page.Substring(i);

    i = page.IndexOf("&lt;b>");
    page = page.Substring(i);

    i = page.IndexOf("&lt;/b>");
    page = page.Substring(0,i);

    page = Regex.Replace(page,"&lt;b>","");
    return page;
    }
    public string GetPageContent(string url)
    {
    WebRequest wreq;
    WebResponse wres;
    StreamReader sr;
    String content;

    wreq = (HttpWebRequest)WebRequest.Create(url);
    SetProxy();
    wreq.Proxy = myProxy;
    wreq.Credentials = myProxy.Credentials;

    // make the HTTP call
    wres = (HttpWebResponse)wreq.GetResponse();
    sr = new StreamReader(wres.GetResponseStream());
    content = sr.ReadToEnd();
    sr.Close();

    return content;
    }
    }




    <> wrote in message
    news:...
    >I meant.
    >> > remoteWebService.Proxy = wp

    > pr was an instance of WebProxy used in our production code.
    >
    > Andy
    >
    > J Ames wrote:
    >> What is the reference to "pr"?
    >>
    >> Actually, I *didn't* pass anything to the proxy property of the service
    >> object in my client app. I set all that up in the web service itself
    >> directly. So when I do an http test in the browser of the service it
    >> uses
    >> the credentials and returns data successfully. It's when I create a
    >> client
    >> app to consume that service that the proxy seems to fail. Are you saying
    >> I
    >> need to set the proxy property *again* in the client web app?
    >>
    >> J
    >>
    >> <> wrote in message
    >> news:...
    >> > My bad, I did not read your question carefully.
    >> > So you've already done something like the following.
    >> >
    >> > 'Assume RemoteWebService is a remote web service proxy class.
    >> > Dim remoteWebService As New RemoteWebService
    >> >
    >> > 'WebProxy to get request past company firewall
    >> > Dim wp As New WebProxy("http://webproxy.example.com", 80)
    >> > 'Assign a user credentials to wp
    >> > wp.Credentials = New NetworkCredentials("myusername", "mypassword",
    >> > "mydomain")
    >> >
    >> > remoteWebService.Proxy = pr
    >> >
    >> > 'Call a webmethod on the remote web service
    >> > Dim myResults As String = remoteWebService.GetSomeResults()
    >> >
    >> > Andy
    >> >
    >> > wrote:
    >> >> If you're consuming a web service on your local machine then a web
    >> >> proxy does not need to be set.
    >> >>
    >> >> J Ames wrote:
    >> >> > I'm confused on this one. I work behind our company firewall. I
    >> >> > created a
    >> >> > web service that accesses an external web site, using the WebProxy
    >> >> > class,
    >> >> > and when I test the web service in the browser, it works perfectly.
    >> >> > It
    >> >> > passes the correct credentials and returns data as expected.
    >> >> > However,
    >> >> > when
    >> >> > I attempt to consume the web service in an ASP.NET project, it
    >> >> > fails.
    >> >> > I'm
    >> >> > getting a http error (bad gateway), so I think it's failing at the
    >> >> > proxy.
    >> >> > I'm not sure why it would do that since it sets the proxy
    >> >> > credentials
    >> >> > in the
    >> >> > service and works on a browser http request.
    >> >> >
    >> >> > Is there some other step I need to take?
    >> >> >
    >> >> > Thanks,
    >> >> > J
    >> >

    >
     
    J Ames, Jul 18, 2006
    #7
  8. J Ames

    Guest

    Let me get this correct.
    Do you have a solution with a web service and another project/web
    application that consumes the web service?

    If that is the case then you can create a web reference within Visual
    Studio in the client project/application to the local web service.
    The name of the default web reference to a local web service would be
    called localhost (although you call call it whatever you want) and you
    can call your local web method directly using this reference.

    Thus to call the GetQuote() method in your web service is a simple as:
    localhost ws = new localhost();

    String quote = ws.GetQuote("GOOG");

    When consuming a web service locally there should be no need to use a
    WebProxy unless you have a very unusual setup.

    Andy

    J Ames wrote:
    > I'm still getting the same error. Would it help to see the service code
    > itself? I'm pasting it below in case someone can decipher. Thanks.
    >
    > using System;
    > using System.IO;
    > using System.ComponentModel;
    > using System.Data;
    > using System.Data.SqlClient;
    > using System.Text;
    > using System.Text.RegularExpressions;
    > using System.Web.Services;
    > using System.Net;
    > using System.Web;
    >
    >
    > /// <summary>
    > /// Summary description for StockServices.
    > /// </summary>
    > [WebService (Namespace="http://enterprise.intranet.com")]
    > public class StockServices : System.Web.Services.WebService
    > {
    > WebProxy myProxy;
    >
    > public StockServices()
    > {
    > InitializeComponent();
    > }
    >
    > #region Component Designer generated code
    >
    > //Required by the Web Services Designer
    > private IContainer components = null;
    >
    > /// <summary>
    > /// Required method for Designer support - do not modify
    > /// the contents of this method with the code editor.
    > /// </summary>
    > private void InitializeComponent()
    > {
    > }
    >
    > /// <summary>
    > /// Clean up any resources being used.
    > /// </summary>
    > protected override void Dispose( bool disposing )
    > {
    > if(disposing && components != null)
    > {
    > components.Dispose();
    > }
    > base.Dispose(disposing); }
    >
    > #endregion
    >
    > [WebMethod]
    > public string GetQuote(string ticker)
    > {
    > string stockURL, page, retval;
    > try
    > {
    > stockURL = GetURL(ticker);
    > page = GetPageContent(stockURL);
    > retval = ParsePage(page);
    > }
    > catch (ArgumentOutOfRangeException)
    > {
    > retval = "Invalid Ticker!";
    > }
    > catch (Exception)
    > {
    > retval = "Unknown Error";
    > }
    >
    > return retval;
    > }
    >
    > [WebMethod]
    > public DataSet GetQuotes(string tickers)
    > {
    > char[] splitter = {' '};
    > string[] _tickers = tickers.Trim().Split(splitter);
    > Int32 i, ticks;
    >
    > ticks = _tickers.Length;
    >
    > DataSet ds = new DataSet();
    > DataTable dt = new DataTable("StockData");
    > DataColumn dc;
    >
    > dc = dt.Columns.Add("Ticker",System.Type.GetType("System.String"));
    > dc = dt.Columns.Add("Price",System.Type.GetType("System.String"));
    >
    > for (i = 0; i < ticks; i++)
    > {
    > DataRow dr = dt.NewRow();
    > dr["Ticker"] = _tickers.ToUpper();
    > dr["Price"] = GetQuote(_tickers);
    > dt.Rows.Add(dr);
    > }
    >
    > ds.Tables.Add(dt);
    > return ds;
    > }
    >
    > public void SetProxy()
    > {
    > myProxy = new WebProxy("000.000.000.000", 80);
    > myProxy.Credentials = new NetworkCredential("sysid", "syspw");
    > }
    >
    > private string GetURL(string ticker)
    > {
    > StringBuilder url = new StringBuilder();
    >
    > url.Append("http://finance.yahoo.com/q/ecn?s=");
    > url.Append(ticker);
    >
    > return url.ToString();
    > }
    >
    > private string ParsePage(string page)
    > {
    > Int32 i;
    >
    > i = page.IndexOf("Last Trade:");
    > page = page.Substring(i);
    >
    > i = page.IndexOf("&lt;b>");
    > page = page.Substring(i);
    >
    > i = page.IndexOf("&lt;/b>");
    > page = page.Substring(0,i);
    >
    > page = Regex.Replace(page,"&lt;b>","");
    > return page;
    > }
    > public string GetPageContent(string url)
    > {
    > WebRequest wreq;
    > WebResponse wres;
    > StreamReader sr;
    > String content;
    >
    > wreq = (HttpWebRequest)WebRequest.Create(url);
    > SetProxy();
    > wreq.Proxy = myProxy;
    > wreq.Credentials = myProxy.Credentials;
    >
    > // make the HTTP call
    > wres = (HttpWebResponse)wreq.GetResponse();
    > sr = new StreamReader(wres.GetResponseStream());
    > content = sr.ReadToEnd();
    > sr.Close();
    >
    > return content;
    > }
    > }
    >
    >
    >
    >
    > <> wrote in message
    > news:...
    > >I meant.
    > >> > remoteWebService.Proxy = wp

    > > pr was an instance of WebProxy used in our production code.
    > >
    > > Andy
    > >
    > > J Ames wrote:
    > >> What is the reference to "pr"?
    > >>
    > >> Actually, I *didn't* pass anything to the proxy property of the service
    > >> object in my client app. I set all that up in the web service itself
    > >> directly. So when I do an http test in the browser of the service it
    > >> uses
    > >> the credentials and returns data successfully. It's when I create a
    > >> client
    > >> app to consume that service that the proxy seems to fail. Are you saying
    > >> I
    > >> need to set the proxy property *again* in the client web app?
    > >>
    > >> J
    > >>
    > >> <> wrote in message
    > >> news:...
    > >> > My bad, I did not read your question carefully.
    > >> > So you've already done something like the following.
    > >> >
    > >> > 'Assume RemoteWebService is a remote web service proxy class.
    > >> > Dim remoteWebService As New RemoteWebService
    > >> >
    > >> > 'WebProxy to get request past company firewall
    > >> > Dim wp As New WebProxy("http://webproxy.example.com", 80)
    > >> > 'Assign a user credentials to wp
    > >> > wp.Credentials = New NetworkCredentials("myusername", "mypassword",
    > >> > "mydomain")
    > >> >
    > >> > remoteWebService.Proxy = pr
    > >> >
    > >> > 'Call a webmethod on the remote web service
    > >> > Dim myResults As String = remoteWebService.GetSomeResults()
    > >> >
    > >> > Andy
    > >> >
    > >> > wrote:
    > >> >> If you're consuming a web service on your local machine then a web
    > >> >> proxy does not need to be set.
    > >> >>
    > >> >> J Ames wrote:
    > >> >> > I'm confused on this one. I work behind our company firewall. I
    > >> >> > created a
    > >> >> > web service that accesses an external web site, using the WebProxy
    > >> >> > class,
    > >> >> > and when I test the web service in the browser, it works perfectly.
    > >> >> > It
    > >> >> > passes the correct credentials and returns data as expected.
    > >> >> > However,
    > >> >> > when
    > >> >> > I attempt to consume the web service in an ASP.NET project, it
    > >> >> > fails.
    > >> >> > I'm
    > >> >> > getting a http error (bad gateway), so I think it's failing at the
    > >> >> > proxy.
    > >> >> > I'm not sure why it would do that since it sets the proxy
    > >> >> > credentials
    > >> >> > in the
    > >> >> > service and works on a browser http request.
    > >> >> >
    > >> >> > Is there some other step I need to take?
    > >> >> >
    > >> >> > Thanks,
    > >> >> > J
    > >> >

    > >
     
    , Jul 18, 2006
    #8
  9. J Ames

    Guest

    I see what you're trying to do. You're using a local web service to
    scrape the html from an external web site. It looks likes your
    webservice should work as written.

    To debug, try the following.
    Can you get to any breakpoints in the webservice when you call the
    webservice from the browser? Yes means local webservice is reachable.
    Can you get to any breakpoints in the webservice when you call the
    webservice from your web application? Yes means you've created the web
    reference to webservice correctly. Can you get past the point in the
    code after sending the request to the external website in
    GetPageContent()?

    Andy
     
    , Jul 19, 2006
    #9
  10. J Ames

    J Ames Guest

    returns http 404

    This still doesn't work. The web service is reachable IF you test it
    directly in the browser. If I reference it from a local asp.net page that
    runs on on a web server on my laptop, it also works fine. If I create a
    *new* asp.net project on the same box as the web service and try to consume
    it, it returns a 404 error. I've checked the web.config and the URL is
    correct. It's not pointing to localhost.

    <> wrote in message
    news:...
    >I see what you're trying to do. You're using a local web service to
    > scrape the html from an external web site. It looks likes your
    > webservice should work as written.
    >
    > To debug, try the following.
    > Can you get to any breakpoints in the webservice when you call the
    > webservice from the browser? Yes means local webservice is reachable.
    > Can you get to any breakpoints in the webservice when you call the
    > webservice from your web application? Yes means you've created the web
    > reference to webservice correctly. Can you get past the point in the
    > code after sending the request to the external website in
    > GetPageContent()?
    >
    > Andy
    >
     
    J Ames, Jul 20, 2006
    #10
  11. J Ames

    Guest

    Re: returns http 404

    It should be much easier to consume the web service locally than from a
    remote web app (laptop).

    I suspect you are probably not creating the web reference properly.
    The 404 error usually indicates that your request reached the correct
    server but IIS could not find the resource requested.

    Could you reach any breakpoints in the web service when calling it from
    a local web app as I asked about previously?

    J Ames wrote:
    > This still doesn't work. The web service is reachable IF you test it
    > directly in the browser. If I reference it from a local asp.net page that
    > runs on on a web server on my laptop, it also works fine. If I create a
    > *new* asp.net project on the same box as the web service and try to consume
    > it, it returns a 404 error. I've checked the web.config and the URL is
    > correct. It's not pointing to localhost.
    >
    > <> wrote in message
    > news:...
    > >I see what you're trying to do. You're using a local web service to
    > > scrape the html from an external web site. It looks likes your
    > > webservice should work as written.
    > >
    > > To debug, try the following.
    > > Can you get to any breakpoints in the webservice when you call the
    > > webservice from the browser? Yes means local webservice is reachable.
    > > Can you get to any breakpoints in the webservice when you call the
    > > webservice from your web application? Yes means you've created the web
    > > reference to webservice correctly. Can you get past the point in the
    > > code after sending the request to the external website in
    > > GetPageContent()?
    > >
    > > Andy
    > >
     
    , Jul 20, 2006
    #11
  12. J Ames

    J Ames Guest

    Re: returns http 404

    Yes, I can step thru it in debug mode but as soon as it attempts to call the
    very first method it fails with the error.

    If there's some other way to create the reference please let me know. I've
    tried it in two separate ways:

    (1) using the Add Web Reference option, and then typing in the URL of the
    WSDL in the field provided. It then allows me to name the reference and add
    it to the project...which creates the service.wsdl and the discomap file.

    (2) saving the WSDL as a file, using the VS.NET SDK wsdl.exe utility to
    manually create a proxy class, then compiling that class into a class
    library DLL and then importing that into my project and then creating a
    reference to it.

    If there's another way please let me know.

    Thanks

    <> wrote in message
    news:...
    > It should be much easier to consume the web service locally than from a
    > remote web app (laptop).
    >
    > I suspect you are probably not creating the web reference properly.
    > The 404 error usually indicates that your request reached the correct
    > server but IIS could not find the resource requested.
    >
    > Could you reach any breakpoints in the web service when calling it from
    > a local web app as I asked about previously?
    >
    > J Ames wrote:
    >> This still doesn't work. The web service is reachable IF you test it
    >> directly in the browser. If I reference it from a local asp.net page
    >> that
    >> runs on on a web server on my laptop, it also works fine. If I create a
    >> *new* asp.net project on the same box as the web service and try to
    >> consume
    >> it, it returns a 404 error. I've checked the web.config and the URL is
    >> correct. It's not pointing to localhost.
    >>
    >> <> wrote in message
    >> news:...
    >> >I see what you're trying to do. You're using a local web service to
    >> > scrape the html from an external web site. It looks likes your
    >> > webservice should work as written.
    >> >
    >> > To debug, try the following.
    >> > Can you get to any breakpoints in the webservice when you call the
    >> > webservice from the browser? Yes means local webservice is reachable.
    >> > Can you get to any breakpoints in the webservice when you call the
    >> > webservice from your web application? Yes means you've created the web
    >> > reference to webservice correctly. Can you get past the point in the
    >> > code after sending the request to the external website in
    >> > GetPageContent()?
    >> >
    >> > Andy
    >> >

    >
     
    J Ames, Jul 20, 2006
    #12
  13. J Ames

    Guest

    Re: returns http 404

    Those are also the 2 way I know to create the web reference.
    If you are already stepping into the web service then the reference was
    created and is being called correctly.

    So we move on. When you refer to "very first method it fails with the
    error" where exactly do you mean?

    Is it before or after this call below?
    wres = (HttpWebResponse)wreq.GetResponse();

    J Ames wrote:
    > Yes, I can step thru it in debug mode but as soon as it attempts to call the
    > very first method it fails with the error.
    >
    > If there's some other way to create the reference please let me know. I've
    > tried it in two separate ways:
    >
    > (1) using the Add Web Reference option, and then typing in the URL of the
    > WSDL in the field provided. It then allows me to name the reference and add
    > it to the project...which creates the service.wsdl and the discomap file.
    >
    > (2) saving the WSDL as a file, using the VS.NET SDK wsdl.exe utility to
    > manually create a proxy class, then compiling that class into a class
    > library DLL and then importing that into my project and then creating a
    > reference to it.
    >
    > If there's another way please let me know.
    >
    > Thanks
    >
    > <> wrote in message
    > news:...
    > > It should be much easier to consume the web service locally than from a
    > > remote web app (laptop).
    > >
    > > I suspect you are probably not creating the web reference properly.
    > > The 404 error usually indicates that your request reached the correct
    > > server but IIS could not find the resource requested.
    > >
    > > Could you reach any breakpoints in the web service when calling it from
    > > a local web app as I asked about previously?
    > >
    > > J Ames wrote:
    > >> This still doesn't work. The web service is reachable IF you test it
    > >> directly in the browser. If I reference it from a local asp.net page
    > >> that
    > >> runs on on a web server on my laptop, it also works fine. If I create a
    > >> *new* asp.net project on the same box as the web service and try to
    > >> consume
    > >> it, it returns a 404 error. I've checked the web.config and the URL is
    > >> correct. It's not pointing to localhost.
    > >>
    > >> <> wrote in message
    > >> news:...
    > >> >I see what you're trying to do. You're using a local web service to
    > >> > scrape the html from an external web site. It looks likes your
    > >> > webservice should work as written.
    > >> >
    > >> > To debug, try the following.
    > >> > Can you get to any breakpoints in the webservice when you call the
    > >> > webservice from the browser? Yes means local webservice is reachable.
    > >> > Can you get to any breakpoints in the webservice when you call the
    > >> > webservice from your web application? Yes means you've created the web
    > >> > reference to webservice correctly. Can you get past the point in the
    > >> > code after sending the request to the external website in
    > >> > GetPageContent()?
    > >> >
    > >> > Andy
    > >> >

    > >
     
    , Jul 21, 2006
    #13
    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.
Similar Threads
  1. J Ames
    Replies:
    0
    Views:
    308
    J Ames
    Jul 17, 2006
  2. DNB
    Replies:
    1
    Views:
    258
  3. dgleeson422111

    Consuming local web service - ok, remote web service -problem?

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    907
    dgleeson422111
    Jan 26, 2010
  4. Curt K
    Replies:
    3
    Views:
    462
    John Saunders [MVP]
    Jun 15, 2007
  5. DNB
    Replies:
    1
    Views:
    310
    John Saunders [MVP]
    Jan 20, 2008
Loading...

Share This Page