Web Service

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

Arda Coskun

Hi,

I have created a smartphone 2003 application with C# and tried to use a web
service. I faced with an error like this on my smartphone:

System.Web.Services.Protocol Server was unable to process request. --->
System.ArgumentException: URI formats are not supported at
System.IO.Path.GetFullPathInpath)
at
System.IO.File. InternalCopy(SourceFileName, String destFileName, Boolean
overwrite) at
System.IO.File.Copy(String sourceFileName, String destFileName)
at
....

how can I solve this?

Kind Regards,
 
I invoke the Web Service (PacSimService) as;

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

myService.SaveLocalHighScores(myPac.Name, myPac.Country, myScore.getScore(),
myMaze.Level);

And here is inside of my Web Service;

[WebMethod]

public void SaveLocalHighScores(string userName, string userCountry, int
userScore, int userLevel)

{

if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))

{

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

}

File.Copy(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml");

//Read highscores from XML

XmlTextReader myReader = new
XmlTextReader(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

myReader.WhitespaceHandling = WhitespaceHandling.None;

//Write highscores to XML

XmlTextWriter myWriter = new
XmlTextWriter(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
System.Text.Encoding.ASCII);

myWriter.WriteStartDocument();

//<Players>

myWriter.WriteStartElement("Players");

//Read first Player element

myReader.ReadStartElement();

bool isCurrentPlayerFound = false;

bool isPlayerFound = false;

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

{

//Reads nested element(Name) of Player element.

myReader.Read();


string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

//<Player>

myWriter.WriteStartElement("Player");

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

{

string localName = myReader.LocalName;


//Read data of element

myReader.Read();


string data = myReader.ReadString();



if (localName.Equals("Name"))

{

curName = data;

//Is player found or need to be created (new account)

if(userName == curName)

{

isPlayerFound = true;

}

//Are the stats current player's or not

isCurrentPlayerFound = (userName == curName) ? true : false;

myWriter.WriteElementString("Name", curName);

}

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

{

curCountry = data;

myWriter.WriteElementString("Country", curCountry);

}

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

{

curScore = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Score", userScore.ToString());

}

else

{

myWriter.WriteElementString("Score", curScore.ToString());

}

}

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

{

curLevel = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Level", userLevel.ToString());

}

else

{

myWriter.WriteElementString("Level", curLevel.ToString());

}

}

//Moves next nested element in Player element

myReader.Read();

}

//</Player>

myWriter.WriteEndElement();


//Moves next nested element in Players element

myReader.Read();

}

if(!isPlayerFound)

{

myWriter.WriteStartElement("Player");

myWriter.WriteElementString("Name", userName);

myWriter.WriteElementString("Country", userCountry);

myWriter.WriteElementString("Score", userScore.ToString());

myWriter.WriteElementString("Level", userLevel.ToString());

myWriter.WriteEndElement();

}

//</Players>

myWriter.WriteEndElement();

//Close writer and reader

myWriter.Flush();

myWriter.Close();

myReader.Close();

}

Where am I wrong?

Kind Regards,

Arda


Alex Feinman said:
It sounds like you are trying to use a url where a file path is expected
 
And you error is obviously caused by the line:
if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))
(and the other ones like it)
If you are trying to save a file into a web server local filesystem, you
should use:

string translatedPath = Server.MapPath("HighScores.xml");
if(File.Exists(translatedPath))
.....

This assumes that the base url of the web service is
www.bilgiciftligi.com/PacSim/

Also if you intend to write files to the disk, you need to make sure that
the IIS process has rights to do so. Ideally you want to create a
subdirectory and only give write access to that directory. The account that
needs Modify access depends on your server - in W2K and XP it's ASPNET. In
Server 2003 it's "NETWORK SERVICE"

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
I invoke the Web Service (PacSimService) as;

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

myService.SaveLocalHighScores(myPac.Name, myPac.Country,
myScore.getScore(),
myMaze.Level);

And here is inside of my Web Service;

[WebMethod]

public void SaveLocalHighScores(string userName, string userCountry, int
userScore, int userLevel)

{

if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))

{

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

}

File.Copy(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml");

//Read highscores from XML

XmlTextReader myReader = new
XmlTextReader(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

myReader.WhitespaceHandling = WhitespaceHandling.None;

//Write highscores to XML

XmlTextWriter myWriter = new
XmlTextWriter(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
System.Text.Encoding.ASCII);

myWriter.WriteStartDocument();

//<Players>

myWriter.WriteStartElement("Players");

//Read first Player element

myReader.ReadStartElement();

bool isCurrentPlayerFound = false;

bool isPlayerFound = false;

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

{

//Reads nested element(Name) of Player element.

myReader.Read();


string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

//<Player>

myWriter.WriteStartElement("Player");

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

{

string localName = myReader.LocalName;


//Read data of element

myReader.Read();


string data = myReader.ReadString();



if (localName.Equals("Name"))

{

curName = data;

//Is player found or need to be created (new account)

if(userName == curName)

{

isPlayerFound = true;

}

//Are the stats current player's or not

isCurrentPlayerFound = (userName == curName) ? true : false;

myWriter.WriteElementString("Name", curName);

}

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

{

curCountry = data;

myWriter.WriteElementString("Country", curCountry);

}

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

{

curScore = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Score", userScore.ToString());

}

else

{

myWriter.WriteElementString("Score", curScore.ToString());

}

}

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

{

curLevel = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Level", userLevel.ToString());

}

else

{

myWriter.WriteElementString("Level", curLevel.ToString());

}

}

//Moves next nested element in Player element

myReader.Read();

}

//</Player>

myWriter.WriteEndElement();


//Moves next nested element in Players element

myReader.Read();

}

if(!isPlayerFound)

{

myWriter.WriteStartElement("Player");

myWriter.WriteElementString("Name", userName);

myWriter.WriteElementString("Country", userCountry);

myWriter.WriteElementString("Score", userScore.ToString());

myWriter.WriteElementString("Level", userLevel.ToString());

myWriter.WriteEndElement();

}

//</Players>

myWriter.WriteEndElement();

//Close writer and reader

myWriter.Flush();

myWriter.Close();

myReader.Close();

}

Where am I wrong?

Kind Regards,

Arda
 
Thank you Alex, it is working well right now.

Alex Feinman said:
And you error is obviously caused by the line:
if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))
(and the other ones like it)
If you are trying to save a file into a web server local filesystem, you
should use:

string translatedPath = Server.MapPath("HighScores.xml");
if(File.Exists(translatedPath))
....

This assumes that the base url of the web service is
www.bilgiciftligi.com/PacSim/

Also if you intend to write files to the disk, you need to make sure that
the IIS process has rights to do so. Ideally you want to create a
subdirectory and only give write access to that directory. The account that
needs Modify access depends on your server - in W2K and XP it's ASPNET. In
Server 2003 it's "NETWORK SERVICE"

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
I invoke the Web Service (PacSimService) as;

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

myService.SaveLocalHighScores(myPac.Name, myPac.Country,
myScore.getScore(),
myMaze.Level);

And here is inside of my Web Service;

[WebMethod]

public void SaveLocalHighScores(string userName, string userCountry, int
userScore, int userLevel)

{

if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))

{

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

}

File.Copy(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml");

//Read highscores from XML

XmlTextReader myReader = new
XmlTextReader(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

myReader.WhitespaceHandling = WhitespaceHandling.None;

//Write highscores to XML

XmlTextWriter myWriter = new
XmlTextWriter(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
System.Text.Encoding.ASCII);

myWriter.WriteStartDocument();

//<Players>

myWriter.WriteStartElement("Players");

//Read first Player element

myReader.ReadStartElement();

bool isCurrentPlayerFound = false;

bool isPlayerFound = false;

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

{

//Reads nested element(Name) of Player element.

myReader.Read();


string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

//<Player>

myWriter.WriteStartElement("Player");

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

{

string localName = myReader.LocalName;


//Read data of element

myReader.Read();


string data = myReader.ReadString();



if (localName.Equals("Name"))

{

curName = data;

//Is player found or need to be created (new account)

if(userName == curName)

{

isPlayerFound = true;

}

//Are the stats current player's or not

isCurrentPlayerFound = (userName == curName) ? true : false;

myWriter.WriteElementString("Name", curName);

}

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

{

curCountry = data;

myWriter.WriteElementString("Country", curCountry);

}

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

{

curScore = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Score", userScore.ToString());

}

else

{

myWriter.WriteElementString("Score", curScore.ToString());

}

}

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

{

curLevel = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Level", userLevel.ToString());

}

else

{

myWriter.WriteElementString("Level", curLevel.ToString());

}

}

//Moves next nested element in Player element

myReader.Read();

}

//</Player>

myWriter.WriteEndElement();


//Moves next nested element in Players element

myReader.Read();

}

if(!isPlayerFound)

{

myWriter.WriteStartElement("Player");

myWriter.WriteElementString("Name", userName);

myWriter.WriteElementString("Country", userCountry);

myWriter.WriteElementString("Score", userScore.ToString());

myWriter.WriteElementString("Level", userLevel.ToString());

myWriter.WriteEndElement();

}

//</Players>

myWriter.WriteEndElement();

//Close writer and reader

myWriter.Flush();

myWriter.Close();

myReader.Close();

}

Where am I wrong?

Kind Regards,

Arda


Alex Feinman said:
It sounds like you are trying to use a url where a file path is expected

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

I have created a smartphone 2003 application with C# and tried to use a
web
service. I faced with an error like this on my smartphone:

System.Web.Services.Protocol Server was unable to process request. --->
System.ArgumentException: URI formats are not supported at
System.IO.Path.GetFullPathInpath)
at
System.IO.File. InternalCopy(SourceFileName, String destFileName, Boolean
overwrite) at
System.IO.File.Copy(String sourceFileName, String destFileName)
at
...

how can I solve this?

Kind Regards,
 
One more question, is it possible to close the GPRS connection when sending
and recieving finished? Which class should I use to close the connection to
GPRS.

Thanks again,

Alex Feinman said:
And you error is obviously caused by the line:
if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))
(and the other ones like it)
If you are trying to save a file into a web server local filesystem, you
should use:

string translatedPath = Server.MapPath("HighScores.xml");
if(File.Exists(translatedPath))
....

This assumes that the base url of the web service is
www.bilgiciftligi.com/PacSim/

Also if you intend to write files to the disk, you need to make sure that
the IIS process has rights to do so. Ideally you want to create a
subdirectory and only give write access to that directory. The account that
needs Modify access depends on your server - in W2K and XP it's ASPNET. In
Server 2003 it's "NETWORK SERVICE"

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
I invoke the Web Service (PacSimService) as;

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

myService.SaveLocalHighScores(myPac.Name, myPac.Country,
myScore.getScore(),
myMaze.Level);

And here is inside of my Web Service;

[WebMethod]

public void SaveLocalHighScores(string userName, string userCountry, int
userScore, int userLevel)

{

if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))

{

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

}

File.Copy(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml");

//Read highscores from XML

XmlTextReader myReader = new
XmlTextReader(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

myReader.WhitespaceHandling = WhitespaceHandling.None;

//Write highscores to XML

XmlTextWriter myWriter = new
XmlTextWriter(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
System.Text.Encoding.ASCII);

myWriter.WriteStartDocument();

//<Players>

myWriter.WriteStartElement("Players");

//Read first Player element

myReader.ReadStartElement();

bool isCurrentPlayerFound = false;

bool isPlayerFound = false;

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

{

//Reads nested element(Name) of Player element.

myReader.Read();


string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

//<Player>

myWriter.WriteStartElement("Player");

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

{

string localName = myReader.LocalName;


//Read data of element

myReader.Read();


string data = myReader.ReadString();



if (localName.Equals("Name"))

{

curName = data;

//Is player found or need to be created (new account)

if(userName == curName)

{

isPlayerFound = true;

}

//Are the stats current player's or not

isCurrentPlayerFound = (userName == curName) ? true : false;

myWriter.WriteElementString("Name", curName);

}

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

{

curCountry = data;

myWriter.WriteElementString("Country", curCountry);

}

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

{

curScore = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Score", userScore.ToString());

}

else

{

myWriter.WriteElementString("Score", curScore.ToString());

}

}

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

{

curLevel = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Level", userLevel.ToString());

}

else

{

myWriter.WriteElementString("Level", curLevel.ToString());

}

}

//Moves next nested element in Player element

myReader.Read();

}

//</Player>

myWriter.WriteEndElement();


//Moves next nested element in Players element

myReader.Read();

}

if(!isPlayerFound)

{

myWriter.WriteStartElement("Player");

myWriter.WriteElementString("Name", userName);

myWriter.WriteElementString("Country", userCountry);

myWriter.WriteElementString("Score", userScore.ToString());

myWriter.WriteElementString("Level", userLevel.ToString());

myWriter.WriteEndElement();

}

//</Players>

myWriter.WriteEndElement();

//Close writer and reader

myWriter.Flush();

myWriter.Close();

myReader.Close();

}

Where am I wrong?

Kind Regards,

Arda


Alex Feinman said:
It sounds like you are trying to use a url where a file path is expected

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

I have created a smartphone 2003 application with C# and tried to use a
web
service. I faced with an error like this on my smartphone:

System.Web.Services.Protocol Server was unable to process request. --->
System.ArgumentException: URI formats are not supported at
System.IO.Path.GetFullPathInpath)
at
System.IO.File. InternalCopy(SourceFileName, String destFileName, Boolean
overwrite) at
System.IO.File.Copy(String sourceFileName, String destFileName)
at
...

how can I solve this?

Kind Regards,
 
On most 2003 devices you cannot terminate connection. In case of GPRS it
will linger, but there would be no traffic so your user will not incur
charges.

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
One more question, is it possible to close the GPRS connection when
sending
and recieving finished? Which class should I use to close the connection
to
GPRS.

Thanks again,

Alex Feinman said:
And you error is obviously caused by the line:
if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))
(and the other ones like it)
If you are trying to save a file into a web server local filesystem, you
should use:

string translatedPath = Server.MapPath("HighScores.xml");
if(File.Exists(translatedPath))
....

This assumes that the base url of the web service is
www.bilgiciftligi.com/PacSim/

Also if you intend to write files to the disk, you need to make sure that
the IIS process has rights to do so. Ideally you want to create a
subdirectory and only give write access to that directory. The account that
needs Modify access depends on your server - in W2K and XP it's ASPNET.
In
Server 2003 it's "NETWORK SERVICE"

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
I invoke the Web Service (PacSimService) as;

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

myService.SaveLocalHighScores(myPac.Name, myPac.Country,
myScore.getScore(),
myMaze.Level);

And here is inside of my Web Service;

[WebMethod]

public void SaveLocalHighScores(string userName, string userCountry,
int
userScore, int userLevel)

{

if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))

{

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

}

File.Copy(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml");

//Read highscores from XML

XmlTextReader myReader = new
XmlTextReader(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

myReader.WhitespaceHandling = WhitespaceHandling.None;

//Write highscores to XML

XmlTextWriter myWriter = new
XmlTextWriter(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
System.Text.Encoding.ASCII);

myWriter.WriteStartDocument();

//<Players>

myWriter.WriteStartElement("Players");

//Read first Player element

myReader.ReadStartElement();

bool isCurrentPlayerFound = false;

bool isPlayerFound = false;

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

{

//Reads nested element(Name) of Player element.

myReader.Read();


string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

//<Player>

myWriter.WriteStartElement("Player");

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

{

string localName = myReader.LocalName;


//Read data of element

myReader.Read();


string data = myReader.ReadString();



if (localName.Equals("Name"))

{

curName = data;

//Is player found or need to be created (new account)

if(userName == curName)

{

isPlayerFound = true;

}

//Are the stats current player's or not

isCurrentPlayerFound = (userName == curName) ? true : false;

myWriter.WriteElementString("Name", curName);

}

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

{

curCountry = data;

myWriter.WriteElementString("Country", curCountry);

}

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

{

curScore = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Score", userScore.ToString());

}

else

{

myWriter.WriteElementString("Score", curScore.ToString());

}

}

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

{

curLevel = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Level", userLevel.ToString());

}

else

{

myWriter.WriteElementString("Level", curLevel.ToString());

}

}

//Moves next nested element in Player element

myReader.Read();

}

//</Player>

myWriter.WriteEndElement();


//Moves next nested element in Players element

myReader.Read();

}

if(!isPlayerFound)

{

myWriter.WriteStartElement("Player");

myWriter.WriteElementString("Name", userName);

myWriter.WriteElementString("Country", userCountry);

myWriter.WriteElementString("Score", userScore.ToString());

myWriter.WriteElementString("Level", userLevel.ToString());

myWriter.WriteEndElement();

}

//</Players>

myWriter.WriteEndElement();

//Close writer and reader

myWriter.Flush();

myWriter.Close();

myReader.Close();

}

Where am I wrong?

Kind Regards,

Arda


It sounds like you are trying to use a url where a file path is expected

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

I have created a smartphone 2003 application with C# and tried to
use a
web
service. I faced with an error like this on my smartphone:

System.Web.Services.Protocol Server was unable to process request. --->
System.ArgumentException: URI formats are not supported at
System.IO.Path.GetFullPathInpath)
at
System.IO.File. InternalCopy(SourceFileName, String destFileName,
Boolean
overwrite) at
System.IO.File.Copy(String sourceFileName, String destFileName)
at
...

how can I solve this?

Kind Regards,
 
Hmm, oki thanks again.

Alex Feinman said:
On most 2003 devices you cannot terminate connection. In case of GPRS it
will linger, but there would be no traffic so your user will not incur
charges.

--
Alex Feinman
---
Visit http://www.opennetcf.org
Arda Coskun said:
One more question, is it possible to close the GPRS connection when
sending
and recieving finished? Which class should I use to close the connection
to
GPRS.

Thanks again,

Alex Feinman said:
And you error is obviously caused by the line:
if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))
(and the other ones like it)
If you are trying to save a file into a web server local filesystem, you
should use:

string translatedPath = Server.MapPath("HighScores.xml");
if(File.Exists(translatedPath))
....

This assumes that the base url of the web service is
www.bilgiciftligi.com/PacSim/

Also if you intend to write files to the disk, you need to make sure that
the IIS process has rights to do so. Ideally you want to create a
subdirectory and only give write access to that directory. The account that
needs Modify access depends on your server - in W2K and XP it's ASPNET.
In
Server 2003 it's "NETWORK SERVICE"

--
Alex Feinman
---
Visit http://www.opennetcf.org
I invoke the Web Service (PacSimService) as;

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

myService.SaveLocalHighScores(myPac.Name, myPac.Country,
myScore.getScore(),
myMaze.Level);

And here is inside of my Web Service;

[WebMethod]

public void SaveLocalHighScores(string userName, string userCountry,
int
userScore, int userLevel)

{

if((File.Exists(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml")))

{

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

}

File.Copy(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

File.Delete(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml");

//Read highscores from XML

XmlTextReader myReader = new
XmlTextReader(@"http://www.bilgiciftligi.com/PacSim/HighScoresOld.xml");

myReader.WhitespaceHandling = WhitespaceHandling.None;

//Write highscores to XML

XmlTextWriter myWriter = new
XmlTextWriter(@"http://www.bilgiciftligi.com/PacSim/HighScores.xml",
System.Text.Encoding.ASCII);

myWriter.WriteStartDocument();

//<Players>

myWriter.WriteStartElement("Players");

//Read first Player element

myReader.ReadStartElement();

bool isCurrentPlayerFound = false;

bool isPlayerFound = false;

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

{

//Reads nested element(Name) of Player element.

myReader.Read();


string curName = "";

string curCountry = "";

int curScore = 0;

int curLevel = 1;

//<Player>

myWriter.WriteStartElement("Player");

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

{

string localName = myReader.LocalName;


//Read data of element

myReader.Read();


string data = myReader.ReadString();



if (localName.Equals("Name"))

{

curName = data;

//Is player found or need to be created (new account)

if(userName == curName)

{

isPlayerFound = true;

}

//Are the stats current player's or not

isCurrentPlayerFound = (userName == curName) ? true : false;

myWriter.WriteElementString("Name", curName);

}

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

{

curCountry = data;

myWriter.WriteElementString("Country", curCountry);

}

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

{

curScore = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Score", userScore.ToString());

}

else

{

myWriter.WriteElementString("Score", curScore.ToString());

}

}

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

{

curLevel = Convert.ToInt16(data);

if(isCurrentPlayerFound && (userScore > curScore))

{

myWriter.WriteElementString("Level", userLevel.ToString());

}

else

{

myWriter.WriteElementString("Level", curLevel.ToString());

}

}

//Moves next nested element in Player element

myReader.Read();

}

//</Player>

myWriter.WriteEndElement();


//Moves next nested element in Players element

myReader.Read();

}

if(!isPlayerFound)

{

myWriter.WriteStartElement("Player");

myWriter.WriteElementString("Name", userName);

myWriter.WriteElementString("Country", userCountry);

myWriter.WriteElementString("Score", userScore.ToString());

myWriter.WriteElementString("Level", userLevel.ToString());

myWriter.WriteEndElement();

}

//</Players>

myWriter.WriteEndElement();

//Close writer and reader

myWriter.Flush();

myWriter.Close();

myReader.Close();

}

Where am I wrong?

Kind Regards,

Arda


It sounds like you are trying to use a url where a file path is expected

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

I have created a smartphone 2003 application with C# and tried to
use a
web
service. I faced with an error like this on my smartphone:

System.Web.Services.Protocol Server was unable to process request. --->
System.ArgumentException: URI formats are not supported at
System.IO.Path.GetFullPathInpath)
at
System.IO.File. InternalCopy(SourceFileName, String destFileName,
Boolean
overwrite) at
System.IO.File.Copy(String sourceFileName, String destFileName)
at
...

how can I solve this?

Kind Regards,
 
Back
Top