Web Services အကျိုးဆက်
- Previous Page WS Platform
- Next Page WS Usage
ကိုယ်စားပြု အော်ပို့က် တစ် ခု က ဝင့် ဝန်ဆောင်မှု အစိတ်အပိုင်း အသုံးပြု နိုင်ပါသည်
ဝင့် ဝန်ဆောင်မှု ဖန်တီး နှင့် ပညာရှင် ကျော်ကြော် သည် ပညာရှင် နှစ် ပုံစံ မှာ မပြတ် ဘဲ ဖြစ်သည်
အက်ပြင် အခြေအနေ
ဤ အခြေအနေ တွင် သင့် သို့ လိုချင် သော ဝင့် ဝန်ဆောင်မှု ကို ဖန်တီး ရန် သင့် သို့ လိုချင် သော အယူအယဲ ကို အသုံးပြု ပါ။
<%@ WebService Language="VB" Class="TempConvert" %> Imports System Imports System.Web.Services Public Class TempConvert :Inherits WebService <WebMethod()> Public Function FahrenheitToCelsius (ByVal Fahrenheit As Int16) As Int16 Dim celsius As Int16 celsius = ((((Fahrenheit) - 32) / 9) * 5) Return celsius End Function <WebMethod()> Public Function CelsiusToFahrenheit (ByVal Celsius As Int16) As Int16 Dim fahrenheit As Int16 fahrenheit = ((((Celsius) * 9) / 5) + 32) Return fahrenheit End Function End Class
ဤ အခမဲ့ အော်ပို့က် သည် အဆိုပါ .asmx ဖိုင် ဖြစ်သည်။ ယူအက်အက် ဝင့် ဝန်ဆောင်မှု အတွက် အသုံးပြု သော အယူအယဲ အော်ပို့က် အပိုင်းအခြာ ဖြစ်သည်
ဤ အခြေအနေ ကို လက်ခံ ရန် သင့် သို့ လိုချင် သော .NET ပြည်သူ ပြည်ရေး ကို လိုင်းနယ် ပါ။
အခမဲ့ ပထမ အော်ပို့က် တွင် ဤ ပါဝင်သည် သည် ဝင့် ဝန်ဆောင်မှု ဖြစ်သည်။ အက္ခရာ အော်ပို့က် အော်ပို့က် ကို "TempConvert" ဟု သတ်မှတ် ပါသည်
<%@ WebService Language="VB" Class="TempConvert" %>
အော်ပို့က် အော်ပို့က် အော်ပို့က် ကို .NET အဆိုပါ အော်ပို့က် ကို ခေါ်ဆို ပါသည်
Imports System Imports System.Web.Services
အော်ပို့က် အော်ပို့က် TempConvert ကို WebSerivce ကို သတ်မှတ် ပါသည်
Public Class TempConvert :Inherits WebService
နောက်လာမည့် အပ်ခြေ မှာ အခြေခံ ဗီယာ ပညာရှင် ဖြစ်သည်။ ဤ အော်ပို့က် တွင် အသုံးပြု သော ပုံစံ မှာ အတ္ထုပါး နှစ် ပုံစံ ရှိ သည်။ တစ် ပုံစံ က ဖီလိပ် အတ္ထုပါး ကို ဆယ်ယာယ် အတ္ထုပါး သို့ ပြောင်းလဲ ပေးသည် တွင် နှင့် တစ် ပုံစံ က ဆယ်ယာယ် အတ္ထုပါး ကို ဖီလိပ် အတ္ထုပါး သို့ ပြောင်းလဲ ပေးသည်။
အသုံးချက် အချင်းမှာ သာ မျဉ်းကျူးကြည်း ဖြစ်သည်။ ဤ ပုံစံ ကို "WebMethod" ဟု သတ်မှတ် ပါသည်။
သင့် သို့ လိုချင် သော ဝင့် ဝန်ဆောင်မှု ဖြစ်သော အော်ပို့က် တွင် "WebMethod" ကို ပြင်ဆင် ပါ။
<WebMethod()> Public Function FahrenheitToCelsius (ByVal Fahrenheit As Int16) As Int16 Dim celsius As Int16 celsius = ((((Fahrenheit) - 32) / 9) * 5) Return celsius End Function <WebMethod()> Public Function CelsiusToFahrenheit (ByVal Celsius As Int16) As Int16 Dim fahrenheit As Int16 fahrenheit = ((((Celsius) * 9) / 5) + 32) Return fahrenheit End Function
The last thing to do is to terminate the function and class:
End Function End Class
If you save this file as a .asmx file and publish it on a server that supports .NET, you will have your first working Web Service.
ASP.NET's Automatic Processing
With ASP.NET, you do not need to write WSDL and SOAP documents manually.
If you study our example carefully, you will find that ASP.NET will automatically create WSDL and SOAP requests.
- Previous Page WS Platform
- Next Page WS Usage