调试通过URL使用的Web服务 [英] Debug web service consumed through URL

查看:71
本文介绍了调试通过URL使用的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的Web服务,我正在使用它从测试应用程序中获取的URL.以下是我的测试应用程序的代码.我在Web服务中设置了断点,当我进入"WebResponse res = req.GetResponse();"这一行时,我想对其进行调试.在我的测试应用中但这并不能用于我的Web方法(DoHelp.我尝试将Web服务托管在IIS中并附加了"aspnet_wp"进程.然后,如果我从浏览器运行,它便可以正常工作.请给我一些输入信息以调试我的测试应用程序中的Web服务.

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();

推荐答案

您是否已在Web服务代码中取消注释此行

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

[System.Web.Script.Services.ScriptService]


取消注释此行:
un-comment this line:
<br />
[System.Web.Script.Services.ScriptService]


运行GET方法的URL使其可以正常工作!!!
Running the URL of GET Method makes it working!!!


这篇关于调试通过URL使用的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆