N
Nastero
Hi All,
I'm trying to learn how to access data in a database via a webservice
and I'm experiencing a little bit of trouble at the moment.
Being a relative noobie to the entire .NET environment and languages,
I'm having difficulty pinpointing what the issue is and how I might go
about fixing it.
Also, when I actually did get it to return the XML String, this was the
return value :
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://localhost/CatfishService/"><dsPlayerList
xmlns="http://www.tempuri.org/dsPlayerList.xsd" /></string>
How do I change the xmlns from "http://www.tempuri.org" to localhost
(or whatever URL is applicable at the time)?
I'll include the code at the end of the message for your review. I
only ask that, if you see the problem and know the answer, you relay
your advice in small words
.
====================== My Service Code ======================
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
namespace CatfishService
{
/// <summary>
/// Summary description for Service1.
/// </summary>
///
[WebService(Description="This is a Service Designed to Manage the
Catfish DB",Namespace="http://localhost/CatfishService/")]
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
//CODEGEN: This call is required by the ASP.NET Web Services
Designer
InitializeComponent();
}
private SqlConnection SQLConnCatfishDB;
private SqlDataAdapter sdaManageRoster;
private SqlCommand sicAddToRoster;
private SqlCommand scGetPlayerList;
private CatfishService.dsPlayerList dsPlayerList;
[WebMethod()]
[return: XmlElement Namespace="http://localhost/CatfishService/",
ElementName="PlayerList")]
public string GetPlayerList(int player_id, int is_active)
{
//SQLConnCatfishDB.Open(); (I commented this out because it
would not process anything after it, it would just open up a
webpage to nowhere).
sdaManageRoster.SelectCommand.Prepare();
sdaManageRoster.SelectCommand.Parameters["@player_id"].Value =
player_id;
sdaManageRoster.SelectCommand.Parameters["@is_active"].Value =
is_active;
//sdaManageRoster.Fill(dsPlayerList); (I commented this out
for the same reason above, not really certain why it does this).
return dsPlayerList.GetXml();
}
Thank in advance.
Cheers,
Daniel Hobert
I'm trying to learn how to access data in a database via a webservice
and I'm experiencing a little bit of trouble at the moment.
Being a relative noobie to the entire .NET environment and languages,
I'm having difficulty pinpointing what the issue is and how I might go
about fixing it.
Also, when I actually did get it to return the XML String, this was the
return value :
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://localhost/CatfishService/"><dsPlayerList
xmlns="http://www.tempuri.org/dsPlayerList.xsd" /></string>
How do I change the xmlns from "http://www.tempuri.org" to localhost
(or whatever URL is applicable at the time)?
I'll include the code at the end of the message for your review. I
only ask that, if you see the problem and know the answer, you relay
your advice in small words
====================== My Service Code ======================
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
namespace CatfishService
{
/// <summary>
/// Summary description for Service1.
/// </summary>
///
[WebService(Description="This is a Service Designed to Manage the
Catfish DB",Namespace="http://localhost/CatfishService/")]
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
//CODEGEN: This call is required by the ASP.NET Web Services
Designer
InitializeComponent();
}
private SqlConnection SQLConnCatfishDB;
private SqlDataAdapter sdaManageRoster;
private SqlCommand sicAddToRoster;
private SqlCommand scGetPlayerList;
private CatfishService.dsPlayerList dsPlayerList;
[WebMethod()]
[return: XmlElement Namespace="http://localhost/CatfishService/",
ElementName="PlayerList")]
public string GetPlayerList(int player_id, int is_active)
{
//SQLConnCatfishDB.Open(); (I commented this out because it
would not process anything after it, it would just open up a
webpage to nowhere).
sdaManageRoster.SelectCommand.Prepare();
sdaManageRoster.SelectCommand.Parameters["@player_id"].Value =
player_id;
sdaManageRoster.SelectCommand.Parameters["@is_active"].Value =
is_active;
//sdaManageRoster.Fill(dsPlayerList); (I commented this out
for the same reason above, not really certain why it does this).
return dsPlayerList.GetXml();
}
Thank in advance.
Cheers,
Daniel Hobert