获取通过POST方法Web服务提交的值 [英] Get value submitted with POST method Web Service

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

问题描述

我正在创建一个运行良好的WebService. 现在,在另一部分中,我需要创建一个页面,该页面会将数据发送到此Web服务. 如何使用POST方法获取发送到此页面的数据.

I'm creating a WebService that is working perfectly. Now the other part, I need to create a page that will send the data to this webservice. How can I get the data sent to this page with the POST method.

场景

客户>页面> Web服务

Customer> Page> WebService

客户端将JSON文本发送到页面,页面将发送到Web服务.

The client will send JSON text to the page, and the page will send to the Web Service.

我目前正在使用C#开发

I am currently developing in C #

推荐答案

步骤如下:

1. Open VS Studio.
2. create new empty Web Application.
3. write click your project name > add > new item
4. Search box on the right then enter "web service".
5. select web service > enter web service name the hit ok.

它看起来像这样:

 [WebMethod]
  public string HelloWorld(String sendMeToDb)
  {
     //this could be send to db or anything.
      //like
        Insert sendMeToDb what ever you want;
      return sendMeToDb;
  }
 -Clean > build > Publish.
 -ojb project folder\Release\Package\PackageTmp.
 -Copy Content
6.(Paste) Deploy Web Service in your local or in other server PC in (IIS)
7. Set up IIS.
8. [Register][1] asp.net in IIS.

9. Create new Website.
10. Copy and paste your project to Newly created website.
11.enable Directory Browsing.
12. Set up application pool framework.
13. right click .asmx file > Browse.

如果Web服务正常运行,那么.

If Web Service running normally then.

14. copy the web service url.
15. Create new empty Web Application Project.
16. Right Click References > Add Service References.
17. Address dropdown paste the url copied from .asmx > Click Go
18.Input namespace then ok.

项目表单加载如下所示.

Project Form Load Look like this.

 protected void Page_Load(object sender, EventArgs e)
    {
        ServiceReference1.WebService1SoapClient cli = new ServiceReference1.WebService1SoapClient();
       String str= cli.HelloWorld("Send Me To DB");

    }

运行项目.

这篇关于获取通过POST方法Web服务提交的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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