Ã÷»ÔÕ¾/ÍøÕ¾½Ì³Ì/ÄÚÈÝ

ϸϸƷζASP.NET(5)

ÍøÕ¾½Ì³Ì2024-02-07 ÔĶÁ
[ÕªÒª]¿ª·¢Web Services£¨Web·þÎñ£© £  ÔÚInternetÉÏ×÷Ϊ·þÎñ·¢²¼µÄ Èí¼þ ÊÇ Web ServicesµÄºËÐÄ¡£ ASP.NET ÌṩÁËÒ»¸ö Web ServicesµÄ»ù´¡¹¹Ôì»·¾³£¬´Ó¶øʹ¿ª·¢ÈËÔ±Äܹ»ÎªÕâ¸ö·þÎñÄ£ÐÍ´´½¨·þÎñ¡£ ÏÖÔÚÎÒÃÇÀ´¸ú×ÙÒ»¸ö¼òµ¥µÄÀý×Ó¡£±ÈÈç˵ÄãÒª´ÓÒ»¸öÔÚÏßÊéÉÌÄÇÀï...
¿ª·¢Web Services£¨Web·þÎñ£©
£ 
ÔÚInternetÉÏ×÷Ϊ·þÎñ·¢²¼µÄ Èí¼þ ÊÇ Web ServicesµÄºËÐÄ¡£ ASP.NET ÌṩÁËÒ»¸ö Web ServicesµÄ»ù´¡¹¹Ôì»·¾³£¬´Ó¶øʹ¿ª·¢ÈËÔ±Äܹ»ÎªÕâ¸ö·þÎñÄ£ÐÍ´´½¨·þÎñ¡£
ÏÖÔÚÎÒÃÇÀ´¸ú×ÙÒ»¸ö¼òµ¥µÄÀý×Ó¡£±ÈÈç˵ÄãÒª´ÓÒ»¸öÔÚÏßÊéÉÌÄÇÀﹺÂòÊé¼®£¬ËûÃÇÓÐÒ»¸ö¸ú×Ùϵͳ£¬Ê¹ÄãÄܹ»¿´µ½×Ô¼º¶¨µ¥µÄ״̬¡£ÊéÉÌÓÃÒ»¸ö½µØÔËÊ乫˾À´ÔËÊäÄ㶩µÄ»õ¡£Õâ¸öÔËÊ乫˾ҲÓÐÒ»¸ö¸ú×Ùϵͳ¡£ÕâÑù£¬ÎªÁ˵õ½ÄãµÄ¶¨µ¥µÄÈ·ÇÐ״̬£¬ÄãÒª²é¿´Á½¸öÕ¾µã¡£Èç¹ûÊéÉÌÄܹ»½«Ëü×Ô¼ºµÄ¶¨µ¥×´Ì¬ºÍÔËÊ乫˾µÄ״̬ÐÅϢһͬÏÔʾ³öÀ´£¬¾Í»áºÜ·½±ã¡£
Web Services¾ÍÔÊÐíÄãÔÚWebÉϽ«¿Í»§ÉÌÓú¯Êý±©Â¶¸ø¹«ÖÚ£¬ÀýÈç°ü¹ü¸ú×Ùϸ½Ú¡£±àдһ¸ö¶ÔÏ󣬽«Æä·½·¨×÷ΪURI±©Â¶³öÀ´£¬URI·µ»ØÒ»¸ö XML Êý¾Ý¡£ÏÖÔÚÊéÉÌ¿ÉÒÔµ÷ÓÃÔËÊ乫˾µÄ¸ú×Ù·þÎñ£¬²¢½«¸ú×ٵĽá¹ûºÏ²¢µ½Ëü×Ô¼ºµÄ¶¨µ¥¸ú×ÙÓ¦ÓóÌÐòÖС£ÒÔÏÂÊÇÔËÊ乫˾ÈçºÎÓà C#´´½¨Ò»¸ö·þÎñµÄ´úÂ룺
<%@ WebService language=¡°c#¡± %>
using System.Web.Services;
public class Shipping {
[WebMethod]
public String OrderStatus(String OrderNumber) {
// code here to retrieve order details from data store
return Status;
}
}
ÒÔÉÏ´úÂë±£´æÓÚ Tracking.asmxÎļþÖУ¬Î»ÓÚÔËÊ乫˾ WebÕ¾µãµÄÓ¦ÓóÌÐòĿ¼ÖС£ÕâÑùÊéÉ̾ͿÉÒÔʹÓöàÖÖ·½·¨À´µ÷ÓÃÕâ¸ö Web ServicesÁË¡£±ÈÈçʹÓà HTTP-GET£¬²ÎÊýͬ²éѯ×Ö·û´®Ò»Í¬±»´«µÝ£º
http://orders.ups.com/orders/Tracking.asmx/OrderStatus?OrderNumber=BRU123
ÊéÉÌ»¹¿ÉÒÔʹÓà HTTP-POST£¬·½·¨µÄ²ÎÊý×÷Ϊ±íµ¥ÖµÔÚpostÌåÄÚ´«µÝ¡£»òÕß»¹¿ÉÒÔʹÓÃHTTP-SOAP£¬·½·¨µÄ²ÎÊý±»°ü¹üÔÚÒ»¸ö¹¤Òµ±ê×¼ XML ¸ñʽÖС£
ÏÖÔÚÓû§Ö»ÐèÒªÔÚÊéÉÌÄÇÀï²éѯËûÃǵĶ¨µ¥Ï¸½Ú£¬ÊéÉÌµÄ Web Ó¦ÓóÌÐò¾Í»á´ÓÔËÊ乫˾ÄÇÀïÊÕ¼¯¸ú×ÙÐÅÏ¢£¬È»ºóͬÊéµÄ״̬һÆ𷵻ء£ÊéÉÌÒ²¿ÉÒÔ½«ËüµÄ¶¨µ¥×´Ì¬Ï¸½Ú×÷Ϊһ¸öWeb Services±©Â¶³öÀ´£¬ÈÃÆäËüÈËʹÓÃËü¡£
Web ServicesµÄΰ´óÖ®´¦ÔÚÓÚ£¬ËüÔÊÐíÄ㱩¶һ¸ö·þÎñ¶ø²»±Ø±©Â¶Êý¾Ý»òËùÓеÄÉÌÒµ¹æÔò¡£µ±×Ô¶¯ÌṩÉÌÒµ·þÎñµÄͬʱ£¬´úÂëºÍÊý¾Ý¶¼ÊÇ°²È«µÄ¡£ÔÚÒÔºó¼¸ÄêÀËæ×ÅB2B·½°¸µÄ¿ÉÀûÓã¬Web ServicesµÄÊг¡»áµÃµ½¿ìËÙµÄÔö³¤¡£

……

Ïà¹ØÔĶÁ