Sending file as a parameter

  • Thread starter Thread starter Arda Coskun
  • Start date Start date
A

Arda Coskun

Hi,

I want to send an XML file as a parameter to a web service, I used
FileStream class but couldn't achive a result.

Any help would be appriciated,

Kind Regards,
 
Define a method that accepts XmlDocument and use it to send the xml file up.
XmlDocument can be loaded directly from a file
 
Thanks Mr. Feinman, but I couldn't achieve the result.

Here is the inside of my Web Service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

//Read highscores from XML

XmlTextReader myReader1 = new XmlTextReader(myXMLScores.Value);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();


while (!myReader1.LocalName.Equals("Player"))

{


string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

....

However, I cannot call it from an instance of my web service;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(@"\Storage\windows\Start Menu\PacSim\HighScores.xml");

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

It says XmlException Error.

Kind Regards,

Alex Feinman said:
Define a method that accepts XmlDocument and use it to send the xml file up.
XmlDocument can be loaded directly from a file
 
What are the details of the XmlException?


--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
Thanks Mr. Feinman, but I couldn't achieve the result.

Here is the inside of my Web Service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

//Read highscores from XML

XmlTextReader myReader1 = new XmlTextReader(myXMLScores.Value);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();


while (!myReader1.LocalName.Equals("Player"))

{


string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

...

However, I cannot call it from an instance of my web service;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(@"\Storage\windows\Start Menu\PacSim\HighScores.xml");

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

It says XmlException Error.

Kind Regards,
 
Here you are;

PacSim.exe
XmlException

Application :: Run + 0xf
GameForm :: Main + 0xa

Thanks,

Alex Feinman said:
What are the details of the XmlException?


--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
Thanks Mr. Feinman, but I couldn't achieve the result.

Here is the inside of my Web Service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

//Read highscores from XML

XmlTextReader myReader1 = new XmlTextReader(myXMLScores.Value);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();


while (!myReader1.LocalName.Equals("Player"))

{


string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

...

However, I cannot call it from an instance of my web service;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(@"\Storage\windows\Start Menu\PacSim\HighScores.xml");

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

It says XmlException Error.

Kind Regards,

Alex Feinman said:
Define a method that accepts XmlDocument and use it to send the xml
file
up.
XmlDocument can be loaded directly from a file

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi,

I want to send an XML file as a parameter to a web service, I used
FileStream class but couldn't achive a result.

Any help would be appriciated,

Kind Regards,
 
I have changed some part of code as;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlTextReader myR = new XmlTextReader(GameForm.gamePath + "HighScores.xml");

XmlDocument myDoc = new XmlDocument();

myDoc.Load(myR);

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

didn't change inside of web service.

I started to get an error like this,

SoapException
System.Web.Services.Protocol
Sercer was unable to read request.

System.InvalidOperationException.
There is an error in XML document (1,246).

The XML declaration is unexpected. Line 1, position 260. at
System.Xml.XmlTextReader

....

How can I solve this? Thanks.

Arda Coskun said:
Here you are;

PacSim.exe
XmlException

Application :: Run + 0xf
GameForm :: Main + 0xa

Thanks,

Alex Feinman said:
What are the details of the XmlException?


--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
Thanks Mr. Feinman, but I couldn't achieve the result.

Here is the inside of my Web Service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

//Read highscores from XML

XmlTextReader myReader1 = new XmlTextReader(myXMLScores.Value);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();


while (!myReader1.LocalName.Equals("Player"))

{


string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

...

However, I cannot call it from an instance of my web service;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(@"\Storage\windows\Start Menu\PacSim\HighScores.xml");

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

It says XmlException Error.

Kind Regards,

Define a method that accepts XmlDocument and use it to send the xml file
up.
XmlDocument can be loaded directly from a file

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi,

I want to send an XML file as a parameter to a web service, I used
FileStream class but couldn't achive a result.

Any help would be appriciated,

Kind Regards,
 
Mr. Feinman,

I want make this;

For instance I have a on web service function A(File myFile). I want to send
the file abc.xml to A function and want to read the content of abc.xml from
inside of A function with XmlTextReader(File). How can I do this?

Kind Regards,

Arda Coskun said:
I have changed some part of code as;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlTextReader myR = new XmlTextReader(GameForm.gamePath + "HighScores.xml");

XmlDocument myDoc = new XmlDocument();

myDoc.Load(myR);

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

didn't change inside of web service.

I started to get an error like this,

SoapException
System.Web.Services.Protocol
Sercer was unable to read request.

System.InvalidOperationException.
There is an error in XML document (1,246).

The XML declaration is unexpected. Line 1, position 260. at
System.Xml.XmlTextReader

...

How can I solve this? Thanks.

Arda Coskun said:
Here you are;

PacSim.exe
XmlException

Application :: Run + 0xf
GameForm :: Main + 0xa

Thanks,

Alex Feinman said:
What are the details of the XmlException?


--
Alex Feinman
---
Visit http://www.opennetcf.org
Thanks Mr. Feinman, but I couldn't achieve the result.

Here is the inside of my Web Service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

//Read highscores from XML

XmlTextReader myReader1 = new XmlTextReader(myXMLScores.Value);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();


while (!myReader1.LocalName.Equals("Player"))

{


string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

...

However, I cannot call it from an instance of my web service;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(@"\Storage\windows\Start Menu\PacSim\HighScores.xml");

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

It says XmlException Error.

Kind Regards,

Define a method that accepts XmlDocument and use it to send the xml file
up.
XmlDocument can be loaded directly from a file

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi,

I want to send an XML file as a parameter to a web service, I used
FileStream class but couldn't achive a result.

Any help would be appriciated,

Kind Regards,
 
When data travel from the device to the web service:

Web Service:

[WebMethod]
public bool SubmitScores(XmlDocument scores)
{
//... do some validation or whatnot
scores.Save(Server.MapPath("Scores"));
return true;
}

Device:

private void SubmitScores()
{
XmlDocument scores = new XmlDocument();
scores.Load(myAppPath + \\scores.xml);
MyWebService svc = new MyWebService();
svc.SubmitScores(scores);
}


When data travel from the web service to the device:

Web Service:

[WebMethod]
public XmlDocument GetHighScores()
{
XmlDocument scores = new XmlDocument();
scores.Load(Server.MapPath("Scores"));
return scores;
}

Device:

private XmlDocument GetHighScores()
{
MyWebService svc = new MyWebService();
return svc.GetHighScores();
}

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
Mr. Feinman,

I want make this;

For instance I have a on web service function A(File myFile). I want to
send
the file abc.xml to A function and want to read the content of abc.xml
from
inside of A function with XmlTextReader(File). How can I do this?

Kind Regards,

Arda Coskun said:
I have changed some part of code as;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlTextReader myR = new XmlTextReader(GameForm.gamePath + "HighScores.xml");

XmlDocument myDoc = new XmlDocument();

myDoc.Load(myR);

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

didn't change inside of web service.

I started to get an error like this,

SoapException
System.Web.Services.Protocol
Sercer was unable to read request.

System.InvalidOperationException.
There is an error in XML document (1,246).

The XML declaration is unexpected. Line 1, position 260. at
System.Xml.XmlTextReader

...

How can I solve this? Thanks.

Arda Coskun said:
Here you are;

PacSim.exe
XmlException

Application :: Run + 0xf
GameForm :: Main + 0xa

Thanks,

What are the details of the XmlException?


--
Alex Feinman
---
Visit http://www.opennetcf.org
Thanks Mr. Feinman, but I couldn't achieve the result.

Here is the inside of my Web Service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

//Read highscores from XML

XmlTextReader myReader1 = new XmlTextReader(myXMLScores.Value);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();


while (!myReader1.LocalName.Equals("Player"))

{


string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

...

However, I cannot call it from an instance of my web service;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(@"\Storage\windows\Start
Menu\PacSim\HighScores.xml");

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

It says XmlException Error.

Kind Regards,

Define a method that accepts XmlDocument and use it to send the
xml
file
up.
XmlDocument can be loaded directly from a file

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi,

I want to send an XML file as a parameter to a web service, I used
FileStream class but couldn't achive a result.

Any help would be appriciated,

Kind Regards,
 
Hi Mr. Feinman,

Thanks for you help but I have a problem about the XML that was created at
web service. Here is the XML
http://www.bilgiciftligi.com/PacSim/highscoresold.xml
XML seems normal but when you try to click the minus signs (tree view) it
does not shrink to next minus sign. I mean when you click <Player>, it does
not shrink to closing tag </Player>. Therefore, I cannot read the file.

What can I do?

Kind Regards,


Alex Feinman said:
When data travel from the device to the web service:

Web Service:

[WebMethod]
public bool SubmitScores(XmlDocument scores)
{
//... do some validation or whatnot
scores.Save(Server.MapPath("Scores"));
return true;
}

Device:

private void SubmitScores()
{
XmlDocument scores = new XmlDocument();
scores.Load(myAppPath + \\scores.xml);
MyWebService svc = new MyWebService();
svc.SubmitScores(scores);
}


When data travel from the web service to the device:

Web Service:

[WebMethod]
public XmlDocument GetHighScores()
{
XmlDocument scores = new XmlDocument();
scores.Load(Server.MapPath("Scores"));
return scores;
}

Device:

private XmlDocument GetHighScores()
{
MyWebService svc = new MyWebService();
return svc.GetHighScores();
}

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
Mr. Feinman,

I want make this;

For instance I have a on web service function A(File myFile). I want to
send
the file abc.xml to A function and want to read the content of abc.xml
from
inside of A function with XmlTextReader(File). How can I do this?

Kind Regards,

Arda Coskun said:
I have changed some part of code as;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlTextReader myR = new XmlTextReader(GameForm.gamePath + "HighScores.xml");

XmlDocument myDoc = new XmlDocument();

myDoc.Load(myR);

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

didn't change inside of web service.

I started to get an error like this,

SoapException
System.Web.Services.Protocol
Sercer was unable to read request.

System.InvalidOperationException.
There is an error in XML document (1,246).

The XML declaration is unexpected. Line 1, position 260. at
System.Xml.XmlTextReader

...

How can I solve this? Thanks.

Here you are;

PacSim.exe
XmlException

Application :: Run + 0xf
GameForm :: Main + 0xa

Thanks,

What are the details of the XmlException?


--
Alex Feinman
---
Visit http://www.opennetcf.org
Thanks Mr. Feinman, but I couldn't achieve the result.

Here is the inside of my Web Service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

//Read highscores from XML

XmlTextReader myReader1 = new XmlTextReader(myXMLScores.Value);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();


while (!myReader1.LocalName.Equals("Player"))

{


string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

...

However, I cannot call it from an instance of my web service;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(@"\Storage\windows\Start
Menu\PacSim\HighScores.xml");

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

It says XmlException Error.

Kind Regards,

Define a method that accepts XmlDocument and use it to send the
xml
file
up.
XmlDocument can be loaded directly from a file

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi,

I want to send an XML file as a parameter to a web service, I used
FileStream class but couldn't achive a result.

Any help would be appriciated,

Kind Regards,
 
Actually, it does. There is nothing wrong with that xml as far as I can see.
How are you reading it? At what point does your code fail?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
Hi Mr. Feinman,

Thanks for you help but I have a problem about the XML that was created at
web service. Here is the XML
http://www.bilgiciftligi.com/PacSim/highscoresold.xml
XML seems normal but when you try to click the minus signs (tree view) it
does not shrink to next minus sign. I mean when you click <Player>, it
does
not shrink to closing tag </Player>. Therefore, I cannot read the file.

What can I do?

Kind Regards,


Alex Feinman said:
When data travel from the device to the web service:

Web Service:

[WebMethod]
public bool SubmitScores(XmlDocument scores)
{
//... do some validation or whatnot
scores.Save(Server.MapPath("Scores"));
return true;
}

Device:

private void SubmitScores()
{
XmlDocument scores = new XmlDocument();
scores.Load(myAppPath + \\scores.xml);
MyWebService svc = new MyWebService();
svc.SubmitScores(scores);
}


When data travel from the web service to the device:

Web Service:

[WebMethod]
public XmlDocument GetHighScores()
{
XmlDocument scores = new XmlDocument();
scores.Load(Server.MapPath("Scores"));
return scores;
}

Device:

private XmlDocument GetHighScores()
{
MyWebService svc = new MyWebService();
return svc.GetHighScores();
}

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
Mr. Feinman,

I want make this;

For instance I have a on web service function A(File myFile). I want to
send
the file abc.xml to A function and want to read the content of abc.xml
from
inside of A function with XmlTextReader(File). How can I do this?

Kind Regards,

I have changed some part of code as;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlTextReader myR = new XmlTextReader(GameForm.gamePath +
"HighScores.xml");

XmlDocument myDoc = new XmlDocument();

myDoc.Load(myR);

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

didn't change inside of web service.

I started to get an error like this,

SoapException
System.Web.Services.Protocol
Sercer was unable to read request.

System.InvalidOperationException.
There is an error in XML document (1,246).

The XML declaration is unexpected. Line 1, position 260. at
System.Xml.XmlTextReader

...

How can I solve this? Thanks.

Here you are;

PacSim.exe
XmlException

Application :: Run + 0xf
GameForm :: Main + 0xa

Thanks,

What are the details of the XmlException?


--
Alex Feinman
---
Visit http://www.opennetcf.org
Thanks Mr. Feinman, but I couldn't achieve the result.

Here is the inside of my Web Service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

//Read highscores from XML

XmlTextReader myReader1 = new XmlTextReader(myXMLScores.Value);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();


while (!myReader1.LocalName.Equals("Player"))

{


string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

...

However, I cannot call it from an instance of my web service;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(@"\Storage\windows\Start
Menu\PacSim\HighScores.xml");

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ".
These
players have been saved to online high scores list successfully.");

It says XmlException Error.

Kind Regards,

Define a method that accepts XmlDocument and use it to send the
xml
file
up.
XmlDocument can be loaded directly from a file

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi,

I want to send an XML file as a parameter to a web service, I
used
FileStream class but couldn't achive a result.

Any help would be appriciated,

Kind Regards,
 
Here is code that is in the web service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

if(File.Exists(pathReceivedHighScores))

{

File.Delete(pathReceivedHighScores);

}

File.Create(pathReceivedHighScores);

//Save newly received high scores from a mobile device

myXMLScores.Save(pathReceivedHighScores);

//Read received highscores from XML and match them with the server ones

XmlTextReader myReader1 = new XmlTextReader(pathReceivedHighScores);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;


while (!myReader1.LocalName.Equals("Player"))

{

string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

if (localName.Equals("Name"))

{

curName = data;

}


else if (localName.Equals("Country"))

{

curCountry = data;

}


else if (localName.Equals("Score"))

{

curScore = Convert.ToInt16(data);

}


else if (localName.Equals("Level"))

{

curLevel = Convert.ToInt16(data);

}

myReader1.Read();

}

//Saves current player's score

SaveHighScore(curName.ToString(), curCountry.ToString(), curScore,
curLevel);

//Add name of player that has been added to online database

savedScorePlayerNames += curName + ", ";

//Starts to read next player

myReader1.Read();

}

myReader1.Close();

return savedScorePlayerNames;

}

The problem is about reading the pathReceivedHighScores. The XML is
http://www.bilgiciftligi.com/PacSim/receivedhighscores.xml
..

SaveHighScore method works well I tried it.

I really cannot undertand what is wrong. I also change the encoding styles
of all XML to UTF-8.

Here is the error message when I try to send the highscores from my mobile.
System.Web.Services.Protocol Server was unable to read request. -->
System.InvalidOperationException. There is an error in XML document
(1,246). -->System.XML.XMLException,
....
....

Thanks,
Alex Feinman said:
Actually, it does. There is nothing wrong with that xml as far as I can see.
How are you reading it? At what point does your code fail?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
Hi Mr. Feinman,

Thanks for you help but I have a problem about the XML that was created at
web service. Here is the XML
http://www.bilgiciftligi.com/PacSim/highscoresold.xml
XML seems normal but when you try to click the minus signs (tree view) it
does not shrink to next minus sign. I mean when you click <Player>, it
does
not shrink to closing tag </Player>. Therefore, I cannot read the file.

What can I do?

Kind Regards,


Alex Feinman said:
When data travel from the device to the web service:

Web Service:

[WebMethod]
public bool SubmitScores(XmlDocument scores)
{
//... do some validation or whatnot
scores.Save(Server.MapPath("Scores"));
return true;
}

Device:

private void SubmitScores()
{
XmlDocument scores = new XmlDocument();
scores.Load(myAppPath + \\scores.xml);
MyWebService svc = new MyWebService();
svc.SubmitScores(scores);
}


When data travel from the web service to the device:

Web Service:

[WebMethod]
public XmlDocument GetHighScores()
{
XmlDocument scores = new XmlDocument();
scores.Load(Server.MapPath("Scores"));
return scores;
}

Device:

private XmlDocument GetHighScores()
{
MyWebService svc = new MyWebService();
return svc.GetHighScores();
}

--
Alex Feinman
---
Visit http://www.opennetcf.org
Mr. Feinman,

I want make this;

For instance I have a on web service function A(File myFile). I want to
send
the file abc.xml to A function and want to read the content of abc.xml
from
inside of A function with XmlTextReader(File). How can I do this?

Kind Regards,

I have changed some part of code as;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlTextReader myR = new XmlTextReader(GameForm.gamePath +
"HighScores.xml");

XmlDocument myDoc = new XmlDocument();

myDoc.Load(myR);

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ". These
players have been saved to online high scores list successfully.");

didn't change inside of web service.

I started to get an error like this,

SoapException
System.Web.Services.Protocol
Sercer was unable to read request.

System.InvalidOperationException.
There is an error in XML document (1,246).

The XML declaration is unexpected. Line 1, position 260. at
System.Xml.XmlTextReader

...

How can I solve this? Thanks.

Here you are;

PacSim.exe
XmlException

Application :: Run + 0xf
GameForm :: Main + 0xa

Thanks,

What are the details of the XmlException?


--
Alex Feinman
---
Visit http://www.opennetcf.org
Thanks Mr. Feinman, but I couldn't achieve the result.

Here is the inside of my Web Service;

[WebMethod]

public string SaveAllHighScores(XmlDocument myXMLScores)

{

//Read highscores from XML

XmlTextReader myReader1 = new XmlTextReader(myXMLScores.Value);

myReader1.WhitespaceHandling = WhitespaceHandling.None;

string savedScorePlayerNames = "";

string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

myReader1.ReadStartElement();


while (!myReader1.LocalName.Equals("Players"))

{

myReader1.Read();


while (!myReader1.LocalName.Equals("Player"))

{


string localName = myReader1.LocalName;

myReader1.Read();

string data = myReader1.ReadString();

...

However, I cannot call it from an instance of my web service;

PacSimService.PacSimScoringWebService myService = new
PacSim.PacSimService.PacSimScoringWebService();


XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(@"\Storage\windows\Start
Menu\PacSim\HighScores.xml");

//pop up a information page and saved scores

saveScoresInfoString = (myService.SaveAllHighScores(myDoc) + ".
These
players have been saved to online high scores list successfully.");

It says XmlException Error.

Kind Regards,

Define a method that accepts XmlDocument and use it to send the
xml
file
up.
XmlDocument can be loaded directly from a file

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi,

I want to send an XML file as a parameter to a web service, I
used
FileStream class but couldn't achive a result.

Any help would be appriciated,

Kind Regards,
 
Hi

I've sent a binaryfile through a webservice. In Delphi .NET however. I
used two variables in the interface for uploading the file: a "array of
byte" where the actual file is - and a integer with length of/size of
the "array of byte".

hopefully this is a pinpoint in the right direction.... (?)

regards,
Finn
 
Back
Top