如何使用Http get Protocol调用webService方法 [英] How to call a webService Method Using Http get Protocol

查看:231
本文介绍了如何使用Http get Protocol调用webService方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我创建了一个简单的WebService方法,如果是Pass Id,它将从数据库返回Employee的名称。


那个webService工作正常我测试过它。


我的问题是现在我必须使用CLient应用程序中的HttpGet协议来调用这个web服务。


 


请提供一些样品。


 


问候,


Amar


感谢和问候,-Amar。

解决方案

嗨Amar,


您可以通过指定Web服务方法和Web服务方法的参数名称/值,直接从客户端应用程序调用Web服务。


Ex :


http://local/WebService.asmx/WebServiceMethod?id = 1


您可以使用javascript中的通用XmlHttpRequest或jQuery的Ajax方法来调用此Web服务。您必须指定GET方法并指定Web服务将返回到客户端应用程序的内容类型。


重要说明:请确保在Web应用程序的web.config中指定此内容:


    < system.web>

    < webServices>

        < protocols>

            < add name =" HttpGet" />

            < add name =" HttpPost" />

        < / protocols>

    < / webServices>

    < /system.web>


如果没有此功能,您将无法通过客户端应用调用您的网络服务。


 


Hi,

I have Created A simple WebService Method Like If a Pass Id it will return Name Of the Employee from database.

That webService is Working Fine i ahve Tested It.

My Question is Now I haveto call this webservice using HttpGet Protocol from CLient Application.

 

please provide me some samples on it.

 

Regards,

Amar


Thanks&Regards, -Amar.

解决方案

Hi Amar,

You can directly invoke your webservice from your client app by specifying the web service method and the parameter name/value of the web service method.

Ex:

http://local/WebService.asmx/WebServiceMethod?id=1

You can invoke this web service by using the generic XmlHttpRequest from javascript or the Ajax method of jQuery. You must specify the GET method and specify the content type the web service will return to your client app.

Important: Make sure you specify this in your web.config of your web app:

    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>

Without this, you won't be able to invoke your web service from your client app.

 


这篇关于如何使用Http get Protocol调用webService方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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