Módulo web (asp.net + soap) |
Top Previous Next |
|
Faça um projeto Web Service Application
Fonte
using System.Text; using System.Web.Services; using System.Collections.Generic;
namespace Lista { [WebService(Namespace = "http://www.servico.market.com.br/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service1 : System.Web.Services.WebService { // classe interna só para exemplificar public class Tipo { public int Codigo { get; set; } public string Nome { get; set; } }
[WebMethod(Description = "Receber tipos com parametro")] public string GravarTipos(string Lista) { List<Tipo> tipos = new List<Tipo>();
// parametro código não tem muita função é só para exemplificar string[] array = Lista.Split('|'); int codigo = 0; foreach (string s in array) { if (s.IndexOf(';') == -1) continue;
Tipo tipo = new Tipo(); if (int.TryParse(s.Split(';')[0], out codigo)) { tipo.Codigo = codigo; tipo.Nome = s.Split(';')[1]; tipos.Add(tipo); } } return tipos.Count.ToString() + " tipos recebidos"; } } } Rodando aparece assim Localmente ele retorna assim: (localhost retorna, na web não permite teste) - passei código "1"
|