Escolar Documentos
Profissional Documentos
Cultura Documentos
[WebMethod]
public double Subtract(double x, double y) {
return x - y;
}
}
27/9/2005 Francisco Hoyos 18
Servio web fora do .asmx:
arquivo fonte C#
using System.Web.Services;
public class MathService
{
[WebMethod]
public double Add(double x, double y) {
return x + y;
}
[WebMethod]
public double Subtract(double x, double y) {
return x - y;
}
}
[WebService(Namespace="urn:geometry")]
public class Geometry {
public UsernameToken Token;
[WebMethod] [SoapHeader("Token")]
public double Distance(Point orig, Point dest) {
if (!Token.username.Equals(Reverse(Token.password)))
throw new Exception("access denied");
return Math.Sqrt(Math.Pow(orig.x-dest.x, 2) +
Math.Pow(orig.y-dest.y, 2));
}
}
27/9/2005 Francisco Hoyos 35
Cliente na raa
Montar mensagem SOAP
manualmente, usando uma biblioteca
XML
Enviar mensagem via HTTP
Receber resposta SOAP via HTTP
Usar XML parser para obter valor de
retorno includo na resposta