I already have my methods to perform CRUD operations ready in a
class . that were used in a Windows Forms application
You can use yes, just call them within a web services method.
From what I understand I can publish Web Service using IIS , so
any device that has my address using a local network can
access my Web Service.
Yes, you can publish on IIS
, if your network was accessible by the device it will connect with your web services normally.
With a project with the methods of type [Webmethod] properly
configured will be able to use the methods in any language
programming ?
The ideal is that it is in what you have the most knowledge, but it can be done in other language.
I have vague knowledge about web services, but from what I understand
that the main objective would be the integration of information .
Web service is a solution used in systems integration and communication between different applications
using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using WebServiceRohr.Classes.Banco;
using RohrLib.Classes;
using WebServiceRohr.Classes;
using RohrApp.Classes;
using System.Data;
using System.Data.SqlClient;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace WebService
{
/// <summary>
///
/// </summary>
[WebService(Description = "Web Service to Work with the Mobile Application", Namespace = "www.seusite.com.br")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class MobileWebService1 : WebServiceBase
{
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod()]
public void MeuMetodo(Int64 id, String Nome)
{
using (var DBCtx = new RohrdbContext())
{
try
{
// Aqui eu uso entity framework ....
// faça suas alterações de acordo com suas classes...
var Tabela = DBCtx.SuaTabela
.Where(O => O.id == id)
.ToList();
// se precisar retornar dados com json
JavaScriptSerializer js = new JavaScriptSerializer();
string RespJson = js.Serialize(Tabela);
writeJsonData(RespJson);
}
catch (Exception exc)
{
}
}
}
protected void writeJsonData(string s)
{
HttpContext context = this.Context;
HttpResponse response = context.Response;
context.Response.ContentType = "application/json";
byte[] b = response.ContentEncoding.GetBytes(s);
response.AddHeader("Content-Length", b.Length.ToString());
response.BinaryWrite(b);
try
{
this.Context.Response.Flush();
this.Context.Response.Close();
}
catch (Exception) { }
}
}
}
base class for connections
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Configuration;
using RohrLib.Classes;
using System.Web.UI;
namespace WebServiceRohr.Classes
{
public class WebServiceBase : WebService
{
private Int32 m_VSParams = 0;
StateBag ViewState = new System.Web.UI.StateBag();
// Create a new VSParam with a unique name
public ViewstateParam<T> CreateParam<T>()
{
m_VSParams++;
return new ViewstateParam<T>(ViewState, "VSP__" + m_VSParams.ToString());
}
// Usado nos diversos DBConn
protected ConnectionStringSettings ConnString
{
get
{
return ConfigurationManager.ConnectionStrings["DBConn"];
}
}
protected String ConnString_
{
get
{
return Convert.ToString(ConfigurationManager.ConnectionStrings["DBConn"]);
}
}
private DBConnection m_DBConn = null;
public DBConnection DBConn
{
get
{
if (m_DBConn == null)
m_DBConn = new DBConnection(ConnString.ConnectionString);
return m_DBConn;
}
}
}
}
Thank you very much ! then I noticed I was doing a lot of thinking, I should have asked only if my ASP.NET Web Service Application project could be consumed in another language, but thank you very much for the answer =D +1 .
– stringnome
Yes, it can be consumed yes.
– Marco Souza