Results 1 to 37 of 37

Thread: [RESOLVED] [Workaround found] Easy: Pass string arg to Webservice

Threaded View

  1. #1

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Resolved [RESOLVED] [Workaround found] Easy: Pass string arg to Webservice

    All,

    I made a webservice and can Invoke the HelloWorld that gets made by the IDE. I also made a Webmethod that returns a record set thing and that seems to work fine, I can breakpoint in the code and everything.\

    However the following Webmethod does not work with the string argument:

    Code:
    [WebMethod] public byte[] FilePickUp(string sFileName)
    {
    	string sFilePath="C:\\Temp\\Dave.png";
    	byte[] byteContent = null;
    	try
    	{
            if (IsFileExist(sFilePath) == true)
    		{
                FileStream fs = new FileStream(sFilePath, FileMode.Open, FileAccess.ReadWrite);
    			byteContent = new byte[fs.Length];
    			fs.Read(byteContent, 0, (int)fs.Length);
    			fs.Close();
    		}
    		else
    		{
    			byteContent=new byte[1];
    			byteContent[0]=0;
    		}
    	}
    	catch(Exception ex)
    	{
    		throw ex;
    	}
    	return byteContent;
    }
    However, if I remove the string argument, I can call the Webmethod just fine.

    The Webmethod compiled with the string argument shows a text box under the Invoke button when I run from the IDE. However pressing Invoke just causes a nasty error:

    HTML Code:
    The page cannot be displayed 
    There is a problem with the page you are trying to reach and it cannot be displayed. 
    
    --------------------------------------------------------------------------------
    
    Please try the following:
    
    Open the localhost:1639 home page, and then look for links to the information you want. 
    Click the  Refresh button, or try again later.
    
    Click  Search to look for information on the Internet. 
    You can also see a list of related sites. 
    
    
    
    
    HTTP 500 - Internal server error 
    Internet Explorer  
    So when I remove the string argument I can call the Webmethod just fine, and get the .PNG junk dumped back into my browser.

    Any ideas?
    Last edited by Dave Sell; Jun 6th, 2009 at 01:48 PM.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width