Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a new web service which I'm consuming using its URL from a testing application. Below is my testing app's code. I have set breakpoints in my Web Service and I want debug it when I come to the line "WebResponse res = req.GetResponse();" in my test app. But it doesn't go to my web method (DoHelp. I tried hosting the web service in IIS and attached the "aspnet_wp" process. Then it's working if I run from browser. Kindly give me some input to debug the web service from my test application.

string url = "http://localhost/MyService/Help.asmx?op=DoHelp";
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
        //HttpRequest req = HttpContext.Current.Request;
        req.Headers.Add("Id", "354535018567138");
        req.Headers.Add("format", "1");
        req.Headers.Add("Name", "0");

        req.ContentType = "audio/x-speex;rate=16000";
        req.Method = "POST";
        byte[] audioData = null;
        string path = Server.MapPath(".");
        path += "\\AudioFile\\audio_16k16bit.spx";
        //string xx = Nuance.DoVoiceRecognition();
        audioData = File.ReadAllBytes(path);
        Stream datastream = req.GetRequestStream();
        datastream.Write(audioData, 0, audioData.Length);
        datastream.Close();
        
        
        WebResponse res = req.GetResponse();
        StreamReader sr = new StreamReader(res.GetResponseStream());
        string outputResult = sr.ReadToEnd();
Posted

Have you un-commented this line in your web service code

C#
[System.Web.Script.Services.ScriptService]
 
Share this answer
 
Comments
jokertin92 17-Apr-12 1:56am    
No, that line is commented!!
un-comment this line:
<br />
[System.Web.Script.Services.ScriptService]
 
Share this answer
 
v2
Comments
jokertin92 17-Apr-12 3:01am    
Still the same!!
abhijeetgupta1988 17-Apr-12 3:09am    
I suggest you to check if simple web service ,with just "hello" string , can be consumed by your Application.
jokertin92 17-Apr-12 4:58am    
I got it working by accessing my web service using "GET" Method. But now I'm getting "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host" error at the line "string outputResult = sr.ReadToEnd();"
Running the URL of GET Method makes it working!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900