WSDL Program
C:\>wsdl /language:C# /out:MyProxyClass.cs http://localhost/ASP.NET/MyWebService.asmx
ASP.NET automatically creates WSDL and SOAP documents from .asmx
code such as this
VB.NET sample:
<%@ WebService Language="VBScript" Class="TempConvert" %>
Imports System
Imports System.Web.Services
Public Class TempConvert :Inherits WebService
<WebMethod()> Public Function FahrenheitToCelsius
(ByVal Fahrenheit As String) As String
dim fahr
fahr=trim(replace(Fahrenheit,",","."))
if fahr="" or IsNumeric(fahr)=false then return "Error"
return ((((fahr) - 32) / 9) * 5)
end function
<WebMethod()> Public Function CelsiusToFahrenheit
(ByVal Celsius As String) As String
dim cel
cel=trim(replace(Celsius,",","."))
if cel="" or IsNumeric(cel)=false then return "Error"
return ((((cel) * 9) / 5) + 32)
end function
end class 'TempConvert
SOAP Headers
[SoapHeader("timeStamp", Direction=SoapHeaderDirection.InOut)]
C# code such as
this sample and this sample:
<%@ WebService language="C#" class="TempConvert" %>
using System;
using System.Web.Services;
using System.Xml.Serialization;
[WebService(Namespace="http://localhost/MyWebServices/")]
public class FirstService : WebService
{
[WebMethod(Description="Add integers")]
public int Add(int a, int b)
{
return a + b;
}
[WebMethod(Description="Say Hello")]
public String SayHello()
{
return "Hello World";
}
}
In order for a client to access a Web method, it must be marked with
[WebMethod] or [WebMethod()] compiler declarative attribute
No method with this WebMethod attribute can be declared static because
an instance of that Web service must exist for access by clients.
|