how to create a web service to take uploading file?

  • Thread starter Thread starter Rudy Ko
  • Start date Start date
R

Rudy Ko

Hi,

I want to create a web service to upload an xml file. Do anyone have
sample code? Thanks !!!

Regards,
Rudy
 
Rudy,
If you are talking about an attachment, and you want to be
standards-compliant, then look at the DIME attachment extension that's in WSE
(Web Service Extensions).

Otherwise, you could send any file as a byte stream as John indicated, or
you can just send the Xml Document as either a string or as an XmlDocument.
The main issue is getting it into the webservice call as a method parameter -
you can't do that with the standard "file upload control" arrangement because
it's not a multipart-encoded FORM post as it is with a web page.
Peter
 
Rudy said:
I want to create a web service to upload an xml file. Do anyone have
sample code? Thanks !!!

XML = string

so

[WebMethod]
public void Upload(string filename, string xml)
{
...
}

should do.

BTW, simple HTTP upload is more efficient than a web service
for upload.

Arne
 
There are some compatability issues if you send a string. Under the sheets
..net will encode this data. If you are exchanging it with another .net
application then you won't see any problems, but if you need to exchange
this data with another application that cannot or does not understand
encoding then you will run into probems.

The best way to send and receive xml is an XmlDocument object.

Arne Vajhøj said:
Rudy said:
I want to create a web service to upload an xml file. Do anyone have
sample code? Thanks !!!

XML = string

so

[WebMethod]
public void Upload(string filename, string xml)
{
...
}

should do.

BTW, simple HTTP upload is more efficient than a web service
for upload.

Arne
 
Greg said:
Arne Vajhøj said:
Rudy said:
I want to create a web service to upload an xml file. Do anyone have
sample code? Thanks !!!
[WebMethod]
public void Upload(string filename, string xml)
{
...
}

should do.
There are some compatability issues if you send a string. Under the
sheets .net will encode this data. If you are exchanging it with
another .net application then you won't see any problems, but if you
need to exchange this data with another application that cannot or does
not understand encoding then you will run into probems.

The best way to send and receive xml is an XmlDocument object.

2 x wrong

A string with XML works fine with non .NET apps.

XmlDocument does not work with non .NET apps.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top