{"id":439,"date":"2017-07-12T15:56:27","date_gmt":"2017-07-12T07:56:27","guid":{"rendered":"http:\/\/www.x1985.org\/?p=439"},"modified":"2017-07-12T17:03:06","modified_gmt":"2017-07-12T09:03:06","slug":"webservice%e5%92%8cwebapi%e7%9a%84%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"http:\/\/www.x1985.org\/?p=439","title":{"rendered":"Web Service\u548cWeb API\u7684\u533a\u522b"},"content":{"rendered":"<p><span style=\"color: #ff0000; font-size: 18pt;\"><strong>Web Service\u7279\u5f81<\/strong><\/span><br \/>\n1\u3001\u5b83\u662f\u57fa\u4e8eSOAP\u534f\u8bae\u7684\uff0c\u6570\u636e\u683c\u5f0f\u662fXML<br \/>\n2\u3001\u53ea\u652f\u6301HTTP\u534f\u8bae<br \/>\n3\u3001\u5b83\u4e0d\u662f\u5f00\u6e90\u7684\uff0c\u4f46\u53ef\u4ee5\u88ab\u4efb\u610f\u4e00\u4e2a\u4e86\u89e3XML\u7684\u4eba\u4f7f\u7528<br \/>\n4\u3001\u5b83\u53ea\u80fd\u90e8\u7f72\u5728IIS\u4e0a<\/p>\n<p><span style=\"color: #ff0000; font-size: 18pt;\"><strong>Web API\u7279\u5f81\uff08\u7ea2\u8272\u6807\u8bb0\u4e0eWebService\u533a\u522b\uff09<\/strong><\/span><br \/>\n1\u3001\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6784\u5efaHTTP\u670d\u52a1\u7684\u65b0\u6846\u67b6<br \/>\n2\u3001\u5728.net\u5e73\u53f0\u4e0aWeb API\u00a0\u662f\u4e00\u4e2a<strong><span style=\"color: #ff0000;\">\u5f00\u6e90\u7684<\/span><\/strong>\u3001\u7406\u60f3\u7684\u3001<strong><span style=\"color: #ff0000;\">\u6784\u5efaREST-ful\u00a0\u670d\u52a1\u7684\u6280\u672f<\/span><\/strong><br \/>\n3\u3001\u4e0d\u50cfWCF REST Service.<strong><span style=\"color: #ff0000;\">\u5b83\u53ef\u4ee5\u4f7f\u7528HTTP\u7684\u5168\u90e8\u7279\u70b9<\/span><\/strong>\uff08\u6bd4\u5982URIs\u3001request\/response\u5934\uff0c\u7f13\u5b58\uff0c\u7248\u672c\u63a7\u5236\uff0c\u591a\u79cd\u5185\u5bb9\u683c\u5f0f\uff09<br \/>\n4\u3001<strong><span style=\"color: #ff0000;\">\u5b83\u4e5f\u652f\u6301MVC\u7684\u7279\u5f81<\/span><\/strong>\uff0c\u50cf\u8def\u7531\u3001\u63a7\u5236\u5668\u3001action\u3001filter\u3001\u6a21\u578b\u7ed1\u5b9a\u3001\u63a7\u5236\u53cd\u8f6c\uff08IOC\uff09\u6216\u4f9d\u8d56\u6ce8\u5165\uff08DI\uff09\uff0c\u5355\u5143\u6d4b\u8bd5\u3002\u8fd9\u4e9b\u53ef\u4ee5\u4f7f\u7a0b\u5e8f\u66f4\u7b80\u5355\u3001\u66f4\u5065\u58ee<br \/>\n5\u3001\u5b83<strong><span style=\"color: #ff0000;\">\u53ef\u4ee5\u90e8\u7f72\u5728\u5e94\u7528\u7a0b\u5e8f<\/span><\/strong>\u548cIIS\u4e0a<br \/>\n6\u3001<strong><span style=\"color: #ff0000;\">\u8fd9\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u6846\u67b6\uff0c\u5e76\u4e14\u5bf9\u9650\u5236\u5e26\u5bbd\u7684\u8bbe\u5907\uff0c\u6bd4\u5982\u667a\u80fd\u624b\u673a\u7b49\u652f\u6301\u7684\u5f88\u597d<\/span><\/strong><br \/>\n7\u3001<strong><span style=\"color: #ff0000;\">Response\u53ef\u4ee5\u88abWeb API\u7684MediaTypeFormatter\u8f6c\u6362\u6210Json\u3001XML\u00a0\u6216\u8005\u4efb\u4f55\u4f60\u60f3\u8f6c\u6362\u7684\u683c\u5f0f\u3002<\/span><\/strong><br \/>\n8\u3001<strong><span style=\"color: #ff0000;\">Web API\u975e\u5e38\u9002\u5408\u6784\u5efa\u79fb\u52a8\u5ba2\u6237\u7aef\u670d\u52a1<\/span><\/strong><\/p>\n<p>\u4e0b\u9762\u9644\u4e0a\u5404\u5927\u5e38\u7528\u63a5\u53e3\u5bf9\u6bd4\u8868\uff1a<\/p>\n<table style=\"text-align: center; border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr style=\"height: 40px; font-weight: bold; color: #f00;\">\n<td style=\"border: 1px solid #000; width: 55px;\"><b>\u540d\u79f0<\/b><\/td>\n<td style=\"border: 1px solid #000; width: 150px;\"><b>\u652f\u6301\u7684\u6570\u636e\u683c\u5f0f<\/b><\/td>\n<td style=\"border: 1px solid #000;\"><b>\u652f\u6301\u7684\u534f\u8bae<\/b><\/td>\n<td style=\"border: 1px solid #000; width: 60px;\"><b>\u662f\u5426\u53ef\u81ea\u5b9a\u4e49\u6269\u5c55<\/b><\/td>\n<td style=\"border: 1px solid #000; width: 100px;\"><b>\u90e8\u7f72\u65b9\u5f0f<\/b><\/td>\n<\/tr>\n<tr style=\"height: 40px;\">\n<td style=\"border: 1px solid #000;\"><b>Web Service<\/b><\/td>\n<td style=\"border: 1px solid #000;\">xml<\/td>\n<td style=\"border: 1px solid #000;\">Soap\u3001Http<\/td>\n<td style=\"border: 1px solid #000;\">\u5426<\/td>\n<td style=\"border: 1px solid #000;\">IIS<\/td>\n<\/tr>\n<tr style=\"height: 40px;\">\n<td style=\"border: 1px solid #000;\"><b>WCF<\/b><\/td>\n<td style=\"border: 1px solid #000;\">xml<\/td>\n<td style=\"border: 1px solid #000;\">\u57fa\u4e8eSoap,\u652f\u6301TCP\u3001HTTP\u3001HTTPS\u3001Named Pipes\u3001MSMQ<\/td>\n<td style=\"border: 1px solid #000;\">\u5426<\/td>\n<td style=\"border: 1px solid #000;\">IIS\u3001Self-Host<\/td>\n<\/tr>\n<tr style=\"height: 40px;\">\n<td style=\"border: 1px solid #000;\"><b>WCF REST<\/b><\/td>\n<td style=\"border: 1px solid #000;\">XML\u3001JSON\u4ee5\u53caATOM<\/td>\n<td style=\"border: 1px solid #000;\">Http(\u91c7\u7528webHttpBinding)<\/td>\n<td style=\"border: 1px solid #000;\">\u5426<\/td>\n<td style=\"border: 1px solid #000;\">IIS\u3001Self-Host<\/td>\n<\/tr>\n<tr style=\"height: 40px;\">\n<td style=\"border: 1px solid #000;\"><b>Web API<\/b><\/td>\n<td style=\"border: 1px solid #000;\">xml\u3001json<\/td>\n<td style=\"border: 1px solid #000;\">http<\/td>\n<td style=\"border: 1px solid #000;\">\u662f<\/td>\n<td style=\"border: 1px solid #000;\">IIS\u3001Self-Host<\/td>\n<\/tr>\n<tr style=\"height: 40px;\">\n<td style=\"border: 1px solid #000;\"><b>MVC<\/b><\/td>\n<td style=\"border: 1px solid #000;\">xml\u3001json<\/td>\n<td style=\"border: 1px solid #000;\">http<\/td>\n<td style=\"border: 1px solid #000;\">\u662f<\/td>\n<td style=\"border: 1px solid #000;\">IIS<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Web Service\u7279\u5f81 1\u3001\u5b83\u662f\u57fa\u4e8eSOAP\u534f\u8bae\u7684\uff0c\u6570\u636e\u683c\u5f0f\u662fXML 2\u3001\u53ea\u652f\u6301HTTP\u534f\u8bae 3\u3001\u5b83\u4e0d\u662f\u5f00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":269,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,1],"tags":[56,55,54],"_links":{"self":[{"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/posts\/439"}],"collection":[{"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=439"}],"version-history":[{"count":29,"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/posts\/439\/revisions"}],"predecessor-version":[{"id":469,"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/posts\/439\/revisions\/469"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/media\/269"}],"wp:attachment":[{"href":"http:\/\/www.x1985.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=439"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}