Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I create new website :: asp.net web service, and coding code in Service.asmx

After that I would like to deploy this web service to sharepoint for use in next step (infopath)

I click public web site, result public fail, I don't know how to deploy/public to sharepoint

Please suggest me !!

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 Service : System.Web.Services.WebService
{
  public Service () {
    //Uncomment the following line if using designed components
    //InitializeComponent();
  }
  [WebMethod]
  public void AddUser(string Name, string Dates)
  {
    using (SqlConnection conn = new SqlConnection("Server=192.168.1.4;Database=HR;Trusted_Connection=True;"))
    {
      // Open a connection to the MySQL database.
      conn.Open();
      // Add the user.
      using (SqlCommand cmd = new SqlCommand())
      {
        // Initialize the command object.
        cmd.Connection = conn;
        cmd.CommandText =
         "INSERT INTO Holidays " +
         "(HolidaysName, HolidaysDate) VALUES (@0, @1)";
        // Set the parameters for the command object.
        SqlParameter param = new SqlParameter("0", Name);
        cmd.Parameters.Add(param);
        param = new SqlParameter("1", Dates);
        cmd.Parameters.Add(param);
        // Add the record to the database.
        cmd.ExecuteNonQuery();
      }
      // Close the connection.
      conn.Close();
    }
    return;
  }
}
Posted

1 solution

Hope this[^] will give you an idea. But it shows how to create a custom Windows Communication Foundation (WCF) service in Microsoft Visual Studio 2010 that is hosted by Microsoft SharePoint Foundation 2010.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900