[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

andregiesing

9/1/2003 3:18:00 PM

Hello!

I've made a simple WebService, which connects to a Access Database
selects everything out of the table "KUNDE" and gives it as a DataSet
back.
Here is the Code:

[WebMethod]
public DataSet GetKunden()
{
OleDbConnection con;
OleDbDataAdapter da;
OleDbCommand cmd;

DataTable tbl = new DataTable("Kunde");
DataSet ds = new DataSet("dsKunde");

try
{
//*1* Verbindung herstellen
con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
+ "Password=;User ID=;Data Source=;");

//*2* Command-Objekt anlegen
cmd = new OleDbCommand("SELECT * FROM KUNDE", con);

//*3* DataAdapter anlegen und Tabelle füllen
da = new OleDbDataAdapter(cmd);
da.Fill(tbl);

//*4* Tabelle dem DataSet hinzufügen
ds.Tables.Add(tbl);

//*5* DataSet zurückgeben
return(ds);
}
catch(Exception ex)
{
return(null);
}
}

In my little mobile Client I just want to get the Data and it should
be displayed in a simple DataGrid.
This is the Code I've made:

private DataSet m_dsDaten = new DataSet();
private void btnDatenHolen_Click(object sender, System.EventArgs e)
{
WebReference.Service ws = new WebReference.Service();

try
{
//*1* Kundendaten laden
m_dsDaten = ws.GetKunden();

//*2* DataGrid an Tabelle binden
dgKunden.DataSource = m_dsDaten.Tables["KUNDE"];
}
catch (Exception ex)
{
MessageBox.Show("Fehler in btnDatenHolen_Click: \n\n" +
ex.ToString());
}
}

But when I want to display the Data in my little mobile application
(in a DataGrid), I get the following error:

"System.InvalidOperationException:Server found request content type to
be 'text/html; charset=utf-8' but expected 'text/xml'."

Any ideas why I get this error?
2 Answers

Somchai U.

9/2/2003 6:18:00 AM

0

The URL of web service may be incorrect (for example, it may point to
localhost).

Somchai

"André Giesing" <andregiesing@gmx.de> wrote in message
news:f945f95.0309010717.5ce04026@posting.google.com...
> Hello!
>
> I've made a simple WebService, which connects to a Access Database
> selects everything out of the table "KUNDE" and gives it as a DataSet
> back.
> Here is the Code:
>
> [WebMethod]
> public DataSet GetKunden()
> {
> OleDbConnection con;
> OleDbDataAdapter da;
> OleDbCommand cmd;
>
> DataTable tbl = new DataTable("Kunde");
> DataSet ds = new DataSet("dsKunde");
>
> try
> {
> //*1* Verbindung herstellen
> con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
> + "Password=;User ID=;Data Source=;");
>
> //*2* Command-Objekt anlegen
> cmd = new OleDbCommand("SELECT * FROM KUNDE", con);
>
> //*3* DataAdapter anlegen und Tabelle füllen
> da = new OleDbDataAdapter(cmd);
> da.Fill(tbl);
>
> //*4* Tabelle dem DataSet hinzufügen
> ds.Tables.Add(tbl);
>
> //*5* DataSet zurückgeben
> return(ds);
> }
> catch(Exception ex)
> {
> return(null);
> }
> }
>
> In my little mobile Client I just want to get the Data and it should
> be displayed in a simple DataGrid.
> This is the Code I've made:
>
> private DataSet m_dsDaten = new DataSet();
> private void btnDatenHolen_Click(object sender, System.EventArgs e)
> {
> WebReference.Service ws = new WebReference.Service();
>
> try
> {
> //*1* Kundendaten laden
> m_dsDaten = ws.GetKunden();
>
> //*2* DataGrid an Tabelle binden
> dgKunden.DataSource = m_dsDaten.Tables["KUNDE"];
> }
> catch (Exception ex)
> {
> MessageBox.Show("Fehler in btnDatenHolen_Click: \n\n" +
> ex.ToString());
> }
> }
>
> But when I want to display the Data in my little mobile application
> (in a DataGrid), I get the following error:
>
> "System.InvalidOperationException:Server found request content type to
> be 'text/html; charset=utf-8' but expected 'text/xml'."
>
> Any ideas why I get this error?


Christian Weyer

9/2/2003 9:35:00 AM

0

I would suppose that you have a permission problem. Because the server responds with an HTML document ... try tcpTrace (or a similar tool) to see the exact SOAP message traveling between service and client (or try to take a look at the inner exception on the client).
Perhaps you have to enable anonymous access to your service (or supply the needed credentials in your client app).

Cheers,
--
Christian Weyer
Microsoft .NET & Service Oriented Architectures

[Microsoft Regional Director, Germany]
http://www.regionaldir...

* XML Web Services: http://www.xmlwebse...
* Weblog: http://weblogs.asp.n...




> Hello!
>
> I've made a simple WebService, which connects to a Access Database
> selects everything out of the table "KUNDE" and gives it as a DataSet
> back.
> Here is the Code:
>
> [WebMethod]
> public DataSet GetKunden()
> {
> OleDbConnection con;
> OleDbDataAdapter da;
> OleDbCommand cmd;
>
> DataTable tbl = new DataTable("Kunde");
> DataSet ds = new DataSet("dsKunde");
>
> try
> {
> //*1* Verbindung herstellen
> con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
> + "Password=;User ID=;Data Source=;");
>
> //*2* Command-Objekt anlegen
> cmd = new OleDbCommand("SELECT * FROM KUNDE", con);
>
> //*3* DataAdapter anlegen und Tabelle füllen
> da = new OleDbDataAdapter(cmd);
> da.Fill(tbl);
>
> //*4* Tabelle dem DataSet hinzufügen
> ds.Tables.Add(tbl);
>
> //*5* DataSet zurückgeben
> return(ds);
> }
> catch(Exception ex)
> {
> return(null);
> }
> }
>
> In my little mobile Client I just want to get the Data and it should
> be displayed in a simple DataGrid.
> This is the Code I've made:
>
> private DataSet m_dsDaten = new DataSet();
> private void btnDatenHolen_Click(object sender, System.EventArgs e)
> {
> WebReference.Service ws = new WebReference.Service();
>
> try
> {
> //*1* Kundendaten laden
> m_dsDaten = ws.GetKunden();
>
> //*2* DataGrid an Tabelle binden
> dgKunden.DataSource = m_dsDaten.Tables["KUNDE"];
> }
> catch (Exception ex)
> {
> MessageBox.Show("Fehler in btnDatenHolen_Click: \n\n" +
> ex.ToString());
> }
> }
>
> But when I want to display the Data in my little mobile application
> (in a DataGrid), I get the following error:
>
> "System.InvalidOperationException:Server found request content type to
> be 'text/html; charset=utf-8' but expected 'text/xml'."
>
> Any ideas why I get this error?