Note that there are some explanatory texts on larger screens.

plurals
  1. POTest ASMX webservice
    primarykey
    data
    text
    <p>I wrote a simple webservice for uploading a file. </p> <pre><code>&lt;%@ WebService Language="C#" class="AppWebService" %&gt; using System; using System.Web.Services; using System.Data; using System.Web; using System.Collections; using System.Web.Services.Protocols; using System.ComponentModel; using System.IO; [WebService(Namespace="http://myip/services")] public class AppWebService : WebService { [WebMethod] public string UploadFile(byte[] f, string fileName) { // the byte array argument contains the content of the file // the string argument contains the name and extension // of the file passed in the byte array try { // instance a memory stream and pass the // byte array to its constructor MemoryStream ms = new MemoryStream(f); // instance a filestream pointing to the // storage folder, use the original file name // to name the resulting file FileStream fs = new FileStream (System.Web.Hosting.HostingEnvironment.MapPath("/TransientStorage/") + fileName, FileMode.Create); // write the memory stream containing the original // file as a byte array to the filestream ms.WriteTo(fs); // clean up ms.Close(); fs.Close(); fs.Dispose(); // return OK if we made it this far return "OK"; } catch (Exception ex) { // return the error message if the operation fails return ex.Message.ToString(); } } [WebMethod] public string HelloWorld() { return "Hello World"; } } </code></pre> <p>Now I am trying to test the functionality but am having trouble interacting with the webservice via C#. I've searched around tried using <code>HTTPWebrequest (multipart/form-data)</code> that I found in <a href="https://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data">this post</a> but didn't have much success and am not sure that this is the right approach. </p> <p>How can I test the webservice that I wrote to see if I can successfully upload a file?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload