Fabiano Carvalho
Fabiano Carvalho

Reputation: 512

Get value submitted with POST method Web Service

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.

Scenario

Customer> Page> WebService

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

I am currently developing in C #

Upvotes: 1

Views: 2620

Answers (1)

Vijunav Vastivch
Vijunav Vastivch

Reputation: 4191

Here's the step:

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.

It will look like this:

 [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.

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

    }

Run the project.

Upvotes: 1

Related Questions