在Web服务中调用Web方法 [英] To call webmethod in webservices

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

问题描述

你好,
我正在使用Web服务开发一个项目.在将Web服务调用到其他项目中的Business Object时遇到问题.
我使用asp.net webservices在一个项目中编写了webservices,而使用asp.net网站在其他项目中编写了主要的编码部分.
1.这是我在webservices中编写的两种方法.

Hello,
I am working on a project using webservices. I got a problem in calling webservices to Business Object which is in other project.
I wrote webservices in one project using asp.net webservices and the main coding part in other project using asp.net website.
1. These are the two methods that I wrote in webservices.

[WebMethod]
    public List<RestaurantCategory> GetAllCategories()
    {
        return dc.RestaurantCategories.ToList();
    }
    [WebMethod]
    public List<RestaurantCategory> GetCategoryByPKID(int pkcategoryId)
    {
        var query = dc.RestaurantCategories.Where(c => c.PkCategoryId == pkcategoryId).ToList();
        return query;
    }



2.我必须使用Linq调用Webservices到Business Object类,并且编写了类似
的代码



2. I have to call the webservices to Business Object class using Linq and I wrote the code like

 RRFDataContext dc = new RRFDataContext();
 WebService objProxy = new WebService();
 RestaurantCategory objcategoryws = new RestaurantCategory();
 public List<RestaurantCategory> GetAllCategories()
 {
     return dc.RestaurantCategories.ToList();
 }
 public localhost.RestaurantCategory GetCategoryByPKID(int pkcategoryId)
{
    return ((objProxy.GetCategoryByPKID(pkcategoryId));
}



问题是当我在gridview中选择选择按钮时,由于要选择我选择了GetCategoryByPKID,所以未显示formview.
请检查上面的代码并尽快给我答复.

谢谢



The problem is when I select select button in gridview the formview is not being displayed because to select I selected GetCategoryByPKID.
Please check the above code and give me reply soon.

Thanks

推荐答案

您能得到什么回报?并且您的代码正在访问Web服务吗?使服务主机位于localhost上,并在其中放置一个断点-确保单击按钮将其击中.
what do you get in return? and is your code hitting the web service? make the service host on localhost and put a breakpoint in - to make sure your hitting it with your button.


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

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