Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var serviceClient = new MulServiceClient("BasicHttpBinding_IMulService");

        Response.Write(serviceClient.MulInt(3, 5));

        serviceClient.Save(new Student {
            StudentId = 123, StudentName = "asdf"
        });

        Response.Write("<br>");

        Response.Write(serviceClient.DivInt(12, 2));

        Response.Write("<br>");

        try
        {
            // 예외 발생시에 WCF는 기본적으로 어떠한 예외인지 표시하지 않는다.

            // Service에서 App.config 옵션에 includeExceptionDetailInFaults를 주면 표시한다
            Response.Write(serviceClient.DivInt(12, 0));
        }
        catch (FaultException ex)
        {
            Response.Write(ex.Message);
        }

        Response.Write("<br>");

        try
        {
            // 예외 발생시에 WCF는 기본적으로 어떠한 예외인지 표시하지 않는다.

            // Service에서 App.config 옵션에 includeExceptionDetailInFaults를 주면 표시한다
            Response.Write(serviceClient.DivInt2(12, 0));
        }
        // Strongly typed exception handling
        catch (FaultException <DivFault> ex)
        {
            Response.Write(ex.Detail.Message);
            Response.Write(ex.Detail.OperationMessage);
        }
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // 파라미터에 Web.config파일 내의 binding name을 적어줘야 한다.
        //var serviceClient = new NewMulServiceClient("BasicHttpBinding_MultiplicationService");
        var serviceClient = new NewMulServiceClient("BasicHttpBinding_INewMulService");

        Response.Write(serviceClient.MulInt(70, 80).ToString());

        Response.Write("<br>");

        Response.Write(serviceClient.MulDouble(80, 80).ToString());

        Response.Write("<br>");

        //var tcpServiceClient = new NewMulServiceClient("NetTcpBinding_MultiplicationService");
        var tcpServiceClient = new MulServiceClient("NetTcpBinding_IMulService");

        Response.Write(tcpServiceClient.MulInt(3, 4));

        Response.Write("<br>");
    }