Use wcf3.5 for restful Web Services and IIS deployment

Source: Internet
Author: User

Implementation:

The general practice is to add a series of features on the service interface, such as the operationcontract feature. However, to implement restful web services, you must add the [webget] feature. Because this feature can only be applied to get requests, if you want to use post requests, you must add the [webinvoke] feature.

For example:

[Operationcontract]
[Webget (uritemplate = "/")]
String helloworld ();

[Operationcontract]
[Webinvoke (uritemplate = "/", method = "Post")]
Result getdatausingdatacontract (compositetype composite );

After adding a service, use a service class to implement this interface. However, if this is the case, isn't it necessary to underestimate Microsoft?

Next, we need to declare servicehostfactory in this class. In this way, it can basically run in ASP. NET development server.

Test with a variety of testing tools, basically no problem.

 

It's too early to be happy. It can run correctly in ASP. NET development server, and does not mean it can also run correctly in IIS. If you do not do anything, once the service is set up on the server, you will find that the service has not been correctly displayed! In fact, configuring config in IIS means everything is fine. To remove the endpoint address, manually specify the endpoint address and modify it to allow others to specify and manage IIS, and IIS users do not need to set any wildcards in IIS, think about it !! For the rest, you do not need to intervene in anything. Just go to bed with peace of mind, this service will be able to work well under the management of IIS.

 

The final restful web service address will look like this: http: // *********/******. svc /***.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.