我使用C#和Java创建了Web服务及其消费Web客户端,他们在同一台机器上工作,但我不知道如何从不同的机器上使用这些服务。有谁知道我需要采取什么步骤,或者至少指出我正确的方向?
这是我的网络服务摘录。 (.NET)
using System;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://deitel.com/", Description = "")]
[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 WebService : System.Web.Services.WebService
{
SqlConnection conn;
SqlDataReader dr;
public WebService()
{
conn = new SqlConnection("Data Source=Owner-PC\\SQLEXPRESS;Initial Catalog=myDatabase;Integrated Security=True");
}
[WebMethod(Description = "Insert Person into People table.")]
public void insertPerson(long id, string name, string surname, int age, long contact, string location)
{
SqlCommand command = new SqlCommand("INSERT INTO People(ID, Name, Surname, Age, Contact, Location) VALUES ('" + id
+ "','" + name + "','" + surname + "','" + age + "','"+ contact + "','" + location + "')", conn);
conn.Open();
command.ExecuteNonQuery();
conn.Close();
}
}