Ein Beispiel für Web Services |
Jede mögliche Anwendung kann tun haben den Web-Service-Bestandteil.
Ein Web hält kann unabhängig davon die Programmiersprache verursacht werden instand.
|
Ein Beispiel des ASP.NET Web-Services
|
Im folgenden Beispiel verwenden wir ASP.NET, um einfachen Web-Service zu verursachen.
|
<%@ 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
|
|
Dieses Dokument ist die .asmx Akte. Dieses ist eine ASP.NET Dateiextension für die XML Web-Dienstleistungen.
|
Um das oben genannte Beispiel laufen zu lassen benötigst du .NET server.
|
The first line in the document that it is the Web Service, written in the VB and the
class name is a "TempConvert":
|
<%@ WebService Language="VB" Class="TempConvert" %>
|
|
Next lines imports a namespace "System.Web.Services" from a .NET framework.
|
Imports System
Imports System.Web.Services
|
|
The next line defines that "TempConvert" class is the WebSerivce class type:
|
Public Class TempConvert :Inherits WebService
|
|
Next step is the basic VB programming. This application do have two functions. One to
convert from the Fahrenheit to Celsius, and the other one to convert from Celsius to
Fahrenheit.
|
The only difference from the normal application is, this function is been defined as
the "WebMethod".
|
Use "WebMethod" to mark the functions in the application that you would like
to make into an web services.
|
<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
|
|
Last thing to do is, end the function and the class:
|
|
If you save this as the .asmx file and publish it on the server with a .NET support,
you should have the first working Web Service. Like our example Web Service
|
|
|
Keywords: web services framework, web services applications, web services programming,
web services implementation, web services soap, web services tomcat, web services xml,
web services interface, web services specification, web services performance,
web services php, web services apache, web services documentation, web services ejb,
web services oracle, web services samples, web services application, web services code,
web services ibm, web services wsdl, web services wsad, web services project,
web services client, web service tutorial, web services development, web services developers,
web services session, using examples, web service sample, sample examples,
web service code, web service tutorials, web services developer, web service samples,
code examples
|