locked
Web Service works locally, not remotely

    Question

  • All is ASP.NET 2.0, C#

    I have a web service that works exactly as expected when on the host machine, invoked in a web browser. When I try  to consume it from my client application, it fails, and fails oddly.

    When the service gets called from the application, I get a SQL Exception that for the parameterized query I don't provide a value for the parameter '@SITE'.  In the code I clearly set this parameter.  When I consume the service from my client I always provide a default value, so I know that a value is provided.  When I run it from a web browser I type in the two parameters & they clearly are accepted and processed correctly.

    Any insight would be greatly appreciated.

     

    Thanks,
    Phil

    The first few lines of the web service are:

    [WebMethod]

    public System.Xml.XmlDocument To_PDA_ProductCategories(string Group, string Site )

    {

    AppSettingsReader ASR = new AppSettingsReader();

    string connstr = ASR.GetValue("UrWayConnectionString", typeof(string)).ToString();

    SqlConnection conn = new SqlConnection( connstr );

    conn.Open();

    string sql = "Select * from Major_Category where Major_Category > 0 ";

    sql+= " and [Group] = @GRP and Site = @SITE ";

    sql += " order by Major_Category";

    SqlCommand cmd = new SqlCommand( sql, conn );

    cmd.Parameters.AddWithValue("@GRP", Group);

    cmd.Parameters.AddWithValue("@SITE", Site);

    XmlDocument xdoc = new XmlDocument();

    XmlDeclaration xdec = xdoc.CreateXmlDeclaration("1.0","text/html","yes");

    xdoc.AppendChild( xdec);

    XmlElement xroot = xdoc.CreateElement("Ur_Way_MajorCategory_Download" );

    xdoc.AppendChild(xroot);

    SqlDataReader rdr = cmd.ExecuteReader();

    ...

    When this

    Thursday, June 08, 2006 7:01 PM

All replies

  • Hello Phil. Well obviously (assuming they are both on the same server/application that your application is passing null as Site. I would probably start off by debugging your client application and see what value is being passed. If that fails I would debug your web service either with a debugger or with a logging/tracing mechanism and see waht is actually being passed.
    Thursday, June 08, 2006 7:38 PM
    Moderator