2013-03-19 4 views
0

나는 웹 서비스 생성 :호출 웹 서비스

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Services; 
using System.Data.SqlClient; 
using System.Data; 

namespace MemberWebService 
{ 
    /// <summary> 
    /// Summary description for Service1 
    /// </summary> 
    [WebService(Namespace = "http://tempuri.org/")] 
    [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 Service1 : System.Web.Services.WebService 
    { 

     [WebMethod] 
     public DataSet GetMemberData(string memberId, string thirdName) 
     { 
      SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=Healthy;Integrated Security=TRUE"); 
      SqlDataAdapter da = new SqlDataAdapter(); 
      DataSet ds = new DataSet(); 

      da.SelectCommand = new SqlCommand("SELECT * FROM MemberMaster WHERE [email protected] and [email protected]", cn); 
      da.SelectCommand.Parameters.Add("@MemberId", SqlDbType.NVarChar).Value = memberId; 
      da.SelectCommand.Parameters.Add("@ThirdName", SqlDbType.NVarChar).Value = thirdName; 

      ds.Clear(); 
      da.Fill(ds); 
      return ds; 
     } 
    } 
} 

을하고 내가 그것을 실행할 때이 링크입니다 :

http://localhost:19722/Service1.asmx 

은하고 확인을 작동합니다.

웹 참조로 asp.net에서 호출하면 서버 포트가 열려있을 때까지 제대로 작동합니다. asp.net 페이지에서 웹 서비스를 볼 수 없으므로 어떻게 문제를 해결할 수 있습니까? 다른 장치에서이 웹 서비스 작업을하고 싶습니다. 어떻게 할 수 있습니까?

+0

ASMX는 기존 기술이므로 새로운 개발에 사용하면 안됩니다. WCF는 웹 서비스 클라이언트 및 서버의 모든 새로운 개발에 사용해야합니다. 한 가지 힌트 : Microsoft는 MSDN에서 [ASMX 포럼] (http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/threads)을 퇴역 시켰습니다. –

답변

2

이 포트는 Visual Studio에 특별히 사용됩니다.이 포트는 Cassini 또는 IIS Express 중 하나이며 디버깅 목적으로 만 사용되며 실제 프로덕션 작업에는 사용되지 않습니다. 서비스를 게시 할 준비가되면 정규 항구 (아마도 80 개)에서 IIS로 이동합니다. 그곳에 도착하면 고객이 항상 전화를 걸 수 있습니다.

IIS에 서비스를 게시 한 후에는 실제 영구 URL을 가리 키도록 클라이언트의 구성 파일을 업데이트하면됩니다.

+0

당신은 원격 호스트에 내 웹 서비스를 게시해야 함을 의미합니다. – user1045265

+0

그래, IIS가있는 모든 서버. 다른 서버 일 필요는 없습니다. 웹 서비스 응용 프로그램을 다른 가상 디렉터리 또는 웹 사이트에있는 웹 응용 프로그램과 동일한 서버에 둘 수 있습니다. –

+0

대단히 감사합니다. – user1045265