푸터 콘텐츠로 바로가기
.NET 도움말

streamjsonrpc c# (개발자를 위한 작동 방식)

JSON-RPC 프로토콜을 사용하면, C#에서 StreamJsonRpc를 통해 다양한 전송 수준에서 클라이언트와 서버 간의 효과적인 통신이 가능합니다. 이 라이브러리를 사용하면 원격 프로시저 호출을 보다 쉽게 구현할 수 있으며, 원격 서버에서 메서드를 호출할 수 있는 신뢰할 수 있는 분산 시스템을 개발자가 작성할 수 있습니다. StreamJsonRpc는 이 라이브러리를 사용하여 IronPDF와 함께 사용할 때, 데이터를 통해 전송된 JSON-RPC 요청을 기반으로 동적 PDF 생성을 허용하여 응용 프로그램 기능을 향상시킵니다. IronPDF는 PDF 생성 및 조작을 위한 완벽한 .NET Framework를 제공합니다. 개발자들이 맞춤형 보고서, 청구서 또는 PDF를 필요에 따라 생성해야 하는 문서 중심의 응용 프로그램을 만드는 과정을 간소화하려는 경우, 이 인터페이스는 매우 유용합니다.

IronPDF는 HTML, ASPX 및 원시 데이터를 고품질 PDF 출판물로 변환하는 것을 지원하여 개발자에게 컨텐츠를 구성하고 전달하는 데에 유연성과 효율성을 제공합니다. StreamJsonRpc와 IronPDF는 C# 개발자들이 복잡한 PDF와 원격 프로시저 호출을 쉽게 결합할 수 있는 반응적이고 확장 가능한 앱을 구축할 수 있도록 함께 작동합니다.

StreamJsonRpc란 무엇인가요?

StreamJsonRpc는 경량의 효율적인 와이어 프로토콜을 사용하여 원격 프로시저 호출(RPC)을 용이하게 하는 교차 플랫폼 라이브러리입니다. 이는 TCP/IP, 네임드 파이프, HTTP와 같은 다양한 통신 채널을 지원하는 기본 전송 메커니즘을 활용합니다. 이 라이브러리는 .NET 이벤트를 활용하여 들어오는 요청과 응답을 처리하여 비동기 통신을 위한 견고한 메커니즘을 제공합니다. 개발자는 StreamJsonRpc API를 사용하여 RPC 요청을 처리할 방법 구현을 첨부하고 사용자 정의 동작을 정의할 수 있습니다. StreamJsonRpc는 .NET 포터블 라이브러리로 제공되어 다양한 플랫폼 간의 호환성을 보장하고 다양한 .NET 응용 프로그램에 원활하게 통합할 수 있도록 합니다.

streamjsonrpc c# (개발자를 위한 작동 원리): 그림 1

StreamJsonRpc의 주요 특성 중 하나는 알림과 진행 상황 보고를 포함한 양방향 통신에 대한 강력한 지원입니다. HTTP, Named Pipes, TCP/IP 등 다양한 전송 프로토콜을 지원하여 프로그램에 더 많은 통신 옵션을 제공합니다. JSON-RPC 메시지 직렬화 및 역직렬화는 StreamJsonRpc에 의해 처리되어 많은 플랫폼과 JSON 지원 컴퓨터 언어 간의 호환성을 보장합니다.

StreamJsonRpc는 성능과 확장성을 염두에 두고 설계되었습니다. 기존의 C# 프로그램과 호환되며, 클라이언트-서버 응용 프로그램, 마이크로서비스 아키텍처, 분산 시스템 및 안정적이고 효율적인 통신이 중요한 기타 응용 프로그램을 구축하는 데 사용할 수 있습니다. C# 프로젝트에 원격 프로시저 호출을 통합할 때 개발자들은 그 신뢰성과 사용의 용이성 때문에 이를 선택하는 경향이 있습니다.

StreamJsonRpc의 기능

C#의 StreamJsonRpc는 JSON-RPC 프로토콜 기반의 클라이언트-서버 응용 프로그램 통신을 용이하게 하고 개선하는 데 필요한 종합적인 기능 모음을 제공합니다.

원격 프로시저 호출 (RPC)

StreamJsonRpc는 원격 작업을 로컬 함수 호출인 것처럼 고려함으로써 클라이언트가 서버에서 원격 프로시저 호출을 통해 메서드를 호출할 수 있게 합니다. 네트워크 통신의 복잡성을 숨김으로써 이 추상화는 분산 응용 프로그램의 생성을 용이하게 합니다.

양방향 통신

라이브러리는 양방향 클라이언트-서버 통신을 지원합니다. 클라이언트가 서버에 요청을 제출할 수 있으며, 서버는 알림이나 결과로 응답할 수 있어 실시간 통신과 업데이트가 가능합니다.

전송 계층 비종속성

StreamJsonRpc는 전송 계층에 종속되지 않아 HTTP, Named Pipes, TCP/IP 등의 다양한 전송 프로토콜을 통해 작동할 수 있습니다. 이 적응성 덕분에 개발자들은 자신의 응용 프로그램과 네트워크 설정의 요구 조건에 따라 최상의 전송 방법을 선택할 수 있습니다.

직렬화 및 역직렬화

JSON-RPC 메시지 직렬화 및 역직렬화를 관리하여 다양한 플랫폼과 JSON 기능이 있는 컴퓨터 언어 간에 원활한 통신을 보장합니다.

진행 상황 보고

StreamJsonRpc는 장시간 실행되는 작업에 대한 진행 상황 보고 기법을 지원합니다. 이 기능은 서버가 현재 프로세스의 상태를 클라이언트에게 업데이트하도록 하여 사용자 경험과 투명성을 향상시킵니다.

오류 처리

원격 메서드 호출 중 발생하는 예외 및 문제를 처리하기 위해 라이브러리는 광범위한 오류 처리 기능을 제공합니다. 이로 인해 분산 시스템의 신뢰성과 안정성이 보장됩니다.

확장 포인트

StreamJsonRpc는 개발자가 그 기능을 변경하거나 기존 응용 프로그램 아키텍처에 포함할 수 있도록 확장할 수 있습니다. 그 유연성 덕분에 다양한 통합 요구 사항과 응용 프로그램 시나리오에 맞게 맞춤화할 수 있습니다.

성능 최적화

StreamJsonRpc는 클라이언트-서버 통신에서 효율적인 사용자 정의 메시지 처리와 전송 계층 관리를 통해 대역폭을 최적화하면서 낮은 오버헤드를 보장합니다.

비동기 지원

비동기 작업을 사용하여 응용 프로그램이 향상된 반응성과 확장성을 달성할 수 있도록 합니다. 비동기 통신 패턴을 완벽하게 지원합니다.

상호 운용성

StreamJsonRpc는 JSON-RPC 표준과의 준수를 통해 C# 응용 프로그램과 다른 언어로 작성된 JSON 지원 서비스간의 상호 운용성을 촉진하여 다양한 환경에서 원활한 통합을 용이하게 합니다.

이 주요 기능 외에도 압축 바이너리 직렬화 및 동적 클라이언트 프록시 지원과 같은 JSON-RPC 사양을 넘는 몇 가지 추가 기능이 있습니다.

Create and Config StreamJsonRpc C

C# 응용 프로그램에서 StreamJsonRpc를 생성하고 구성하려면 클라이언트와 서버를 설정해야 합니다. 각 부분에 대한 자세한 지침은 다음과 같습니다:

프로젝트 설정

먼저 .NET 프로젝트가 준비되었는지 확인하십시오. Visual Studio 또는 .NET CLI를 사용하여 새로 만들 수 있습니다.

dotnet new console -n StreamjsonrpcExample
cd StreamjsonrpcExample
dotnet new console -n StreamjsonrpcExample
cd StreamjsonrpcExample
SHELL

StreamJsonRpc Install-Package

JSON-RPC 통신을 구현하기 위해 NuGet에서 StreamJsonRpc 패키지를 설치하십시오. 필요한 라이브러리를 포함하고 있습니다.

dotnet add package StreamJsonRpc
dotnet add package StreamJsonRpc
SHELL

JSON-RPC 서버 구현

JSON-RPC의 서버로 작동할 클래스를 만드세요. 다음은 간단한 예시입니다:

using Microsoft.AspNetCore.Hosting;
using StreamJsonRpc;
using System;
using System.Threading.Tasks;

public class MyService
{
    // Asynchronous method to add two integers
    public Task<int> AddAsync(int a, int b)
    {
        return Task.FromResult(a + b);
    }

    // Asynchronous method to greet a user
    public Task<string> GreetAsync(string name)
    {
        return Task.FromResult($"Hello, {name}!");
    }
}

class Program
{
    static void Main(string[] args)
    {
        // Initialize the service offering RPC methods
        var service = new MyService();

        // Create a StreamJsonRpc server listening on websockets
        var jsonRpc = new JsonRpc(new ServerWebSocketJsonRpcMessageHandler("ws://localhost:8080"));

        // Add service as RPC target
        jsonRpc.AddLocalRpcTarget(service);

        // Start listening for incoming JSON-RPC requests
        jsonRpc.StartListening();

        Console.WriteLine("JsonRpc server listening on ws://localhost:8080");
        Console.WriteLine("Press any key to stop the server...");

        // Wait for user input to stop the server
        Console.ReadKey();

        // Dispose resources when done
        jsonRpc.Dispose();
    }
}
using Microsoft.AspNetCore.Hosting;
using StreamJsonRpc;
using System;
using System.Threading.Tasks;

public class MyService
{
    // Asynchronous method to add two integers
    public Task<int> AddAsync(int a, int b)
    {
        return Task.FromResult(a + b);
    }

    // Asynchronous method to greet a user
    public Task<string> GreetAsync(string name)
    {
        return Task.FromResult($"Hello, {name}!");
    }
}

class Program
{
    static void Main(string[] args)
    {
        // Initialize the service offering RPC methods
        var service = new MyService();

        // Create a StreamJsonRpc server listening on websockets
        var jsonRpc = new JsonRpc(new ServerWebSocketJsonRpcMessageHandler("ws://localhost:8080"));

        // Add service as RPC target
        jsonRpc.AddLocalRpcTarget(service);

        // Start listening for incoming JSON-RPC requests
        jsonRpc.StartListening();

        Console.WriteLine("JsonRpc server listening on ws://localhost:8080");
        Console.WriteLine("Press any key to stop the server...");

        // Wait for user input to stop the server
        Console.ReadKey();

        // Dispose resources when done
        jsonRpc.Dispose();
    }
}
Imports Microsoft.AspNetCore.Hosting
Imports StreamJsonRpc
Imports System
Imports System.Threading.Tasks

Public Class MyService
	' Asynchronous method to add two integers
	Public Function AddAsync(ByVal a As Integer, ByVal b As Integer) As Task(Of Integer)
		Return Task.FromResult(a + b)
	End Function

	' Asynchronous method to greet a user
	Public Function GreetAsync(ByVal name As String) As Task(Of String)
		Return Task.FromResult($"Hello, {name}!")
	End Function
End Class

Friend Class Program
	Shared Sub Main(ByVal args() As String)
		' Initialize the service offering RPC methods
		Dim service = New MyService()

		' Create a StreamJsonRpc server listening on websockets
		Dim jsonRpc As New JsonRpc(New ServerWebSocketJsonRpcMessageHandler("ws://localhost:8080"))

		' Add service as RPC target
		jsonRpc.AddLocalRpcTarget(service)

		' Start listening for incoming JSON-RPC requests
		jsonRpc.StartListening()

		Console.WriteLine("JsonRpc server listening on ws://localhost:8080")
		Console.WriteLine("Press any key to stop the server...")

		' Wait for user input to stop the server
		Console.ReadKey()

		' Dispose resources when done
		jsonRpc.Dispose()
	End Sub
End Class
$vbLabelText   $csharpLabel

MyService 클래스: 클라이언트가 원격으로 호출할 수 있는 메서드를 지정합니다, 예를 들어 AddAsyncGreetAsync.

streamjsonrpc c# (개발자를 위한 작동 원리): 그림 2

이는 새로운 JsonRpc 인스턴스를 시작하고, MyService을 초기화하며, ws://localhost:8080에서 통신할 수 있도록 WebSocket 메시지 핸들러를 구성합니다. 서버는 MyService을 새로운 로컬 RPC 대상으로 노출하고 JSON-RPC 쿼리가 도착할 때까지 대기하기 시작합니다. 키를 눌러 수신을 중지하고 리소스를 폐기하세요.

클라이언트 설정

JSON-RPC의 클라이언트로 작동할 클래스를 만드세요. 다음은 간단한 예시입니다:

using StreamJsonRpc;
using System;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        // Create a JSON-RPC client connected to the WebSocket server endpoint
        var proxy = new JsonRpc(new ClientWebSocketJsonRpcMessageHandler("ws://localhost:8080"));

        // Start listening for incoming messages from the server
        await proxy.StartListeningAsync();

        // Invoke the AddAsync method on the server
        var resultAdd = await proxy.InvokeAsync<int>("AddAsync", 10, 20);
        Console.WriteLine($"AddAsync result: {resultAdd}");

        // Invoke the GreetAsync method on the server
        var resultGreet = await proxy.InvokeAsync<string>("GreetAsync", "John");
        Console.WriteLine($"GreetAsync result: {resultGreet}");

        // Dispose the proxy when done
        proxy.Dispose();
    }
}
using StreamJsonRpc;
using System;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        // Create a JSON-RPC client connected to the WebSocket server endpoint
        var proxy = new JsonRpc(new ClientWebSocketJsonRpcMessageHandler("ws://localhost:8080"));

        // Start listening for incoming messages from the server
        await proxy.StartListeningAsync();

        // Invoke the AddAsync method on the server
        var resultAdd = await proxy.InvokeAsync<int>("AddAsync", 10, 20);
        Console.WriteLine($"AddAsync result: {resultAdd}");

        // Invoke the GreetAsync method on the server
        var resultGreet = await proxy.InvokeAsync<string>("GreetAsync", "John");
        Console.WriteLine($"GreetAsync result: {resultGreet}");

        // Dispose the proxy when done
        proxy.Dispose();
    }
}
Imports StreamJsonRpc
Imports System
Imports System.Threading.Tasks

Friend Class Program
	Shared Async Function Main(ByVal args() As String) As Task
		' Create a JSON-RPC client connected to the WebSocket server endpoint
		Dim proxy = New JsonRpc(New ClientWebSocketJsonRpcMessageHandler("ws://localhost:8080"))

		' Start listening for incoming messages from the server
		Await proxy.StartListeningAsync()

		' Invoke the AddAsync method on the server
		Dim resultAdd = Await proxy.InvokeAsync(Of Integer)("AddAsync", 10, 20)
		Console.WriteLine($"AddAsync result: {resultAdd}")

		' Invoke the GreetAsync method on the server
		Dim resultGreet = Await proxy.InvokeAsync(Of String)("GreetAsync", "John")
		Console.WriteLine($"GreetAsync result: {resultGreet}")

		' Dispose the proxy when done
		proxy.Dispose()
	End Function
End Class
$vbLabelText   $csharpLabel

이 예제는 WebSocket 메시지 핸들러와 함께 ws://localhost:8080에 연결하여 JsonRpc 인스턴스를 시작합니다. 그런 다음 JSON-RPC 서버와 연결을 설정하여 서버에 정의된 AddAsyncGreetAsync 메서드를 활성화합니다 (MyService). 마지막으로 서버가 반환한 결과를 보여주고 RPC 호출이 완료된 후 리소스를 해제합니다.

streamjsonrpc c# (개발자를 위한 작동 원리): 그림 3

시작하기

JSON-RPC 쿼리를 통해 교환된 데이터를 사용하여 StreamJsonRpc와 IronPDF를 통합함으로써 C# 애플리케이션에서 PDF 페이지를 동적으로 생성할 수 있습니다. IronPDF 및 StreamJsonRpc 설정을 위한 기본 사용 방법은 다음과 같습니다:

IronPDF 란 무엇인가요?

IronPDF는 C# 프로그램에서 PDF 문서를 생성, 읽기 및 편집하는 데 사용할 수 있습니다. 이 도구는 개발자가 HTML, CSS, JavaScript 정보를 인쇄 가능한 고품질 PDF로 변환하는 것을 간단하게 만듭니다. 주요 작업으로는 머리글 및 바닥글 추가, PDF 분할 및 병합, 문서 워터마킹 및 HTML을 PDF로 변환하는 것이 포함됩니다. IronPDF는 .NET Framework와 .NET Core 모두를 지원하므로 다양한 응용 프로그램에 유용합니다.

PDF는 사용하기 쉽고 많은 콘텐츠를 제공하기 때문에 개발자들이 자신의 제품에 쉽게 통합할 수 있습니다. IronPDF는 복잡한 레이아웃과 서식을 쉽게 처리할 수 있기 때문에 생성된 출력 PDF는 원본 HTML 텍스트와 거의 일치합니다.

streamjsonrpc c# (개발자를 위한 작동 원리): 그림 4

IronPDF 의 특징

HTML에서 PDF 생성

JavaScript, HTML, CSS 파일을 PDF로 변환합니다. IronPDF 미디어 쿼리와 반응형 디자인을 지원하며, 이는 최신 웹 표준 두 가지입니다. HTML과 CSS를 사용하여 PDF 문서, 보고서, 영수증을 동적으로 장식하는 데 유용한 도구입니다.

PDF 편집

기존 PDF 파일에 텍스트, 사진 및 기타 콘텐츠를 추가할 수 있습니다. PDF 파일에서 텍스트와 이미지를 추출합니다. 개발자들은 여러 PDF를 하나의 파일로 결합하거나 PDF 파일을 여러 개의 개별 문서로 분할할 수 있습니다. 워터마크, 주석, 머리글 및 바닥글을 포함하세요.

PDF 변환

IronPDF를 사용하여 Word, Excel 및 이미지 파일을 포함한 다양한 파일 형식을 PDF로 변환할 수 있습니다. 이를 통해 PDF를 이미지(PNG, JPEG 등)로 변환할 수도 있습니다.

성능 및 신뢰성

산업 현장에서는 고성능과 신뢰성이 중요한 설계 요소입니다. IronPDF는 대규모 문서 세트를 쉽게 관리합니다.

IronPDF 설치

.NET 프로젝트에서 PDF를 다루는 데 필요한 도구를 얻으려면 IronPDF 패키지를 설치하십시오.

dotnet add package IronPdf
dotnet add package IronPdf
SHELL

IronPDF와 함께하는 StreamJsonRpc

서비스 클래스 생성

수신된 데이터를 기반으로 PDF를 생성하는 메서드를 서비스 클래스 PdfService.cs에 제공합니다. 예를 들어 설명하자면:

using IronPdf;
using System.IO;
using System.Threading.Tasks;

public class PdfService
{
    // Asynchronously generates a PDF from HTML content
    public async Task<byte[]> GeneratePdfAsync(string htmlContent)
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        return await pdf.BinaryDataAsync();
    }
}
using IronPdf;
using System.IO;
using System.Threading.Tasks;

public class PdfService
{
    // Asynchronously generates a PDF from HTML content
    public async Task<byte[]> GeneratePdfAsync(string htmlContent)
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        return await pdf.BinaryDataAsync();
    }
}
Imports IronPdf
Imports System.IO
Imports System.Threading.Tasks

Public Class PdfService
	' Asynchronously generates a PDF from HTML content
	Public Async Function GeneratePdfAsync(ByVal htmlContent As String) As Task(Of Byte())
		Dim renderer = New ChromePdfRenderer()
		Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
		Return Await pdf.BinaryDataAsync()
	End Function
End Class
$vbLabelText   $csharpLabel

StreamJsonRpc 서버 설정

StreamJsonRpc에 대한 인터페이스로 서버에서 Program.cs을 사용하여 스트림 JSON-RPC를 통해 GeneratePdfAsync 메서드를 제공하세요:

using StreamJsonRpc;
using System;
using System.Net.WebSockets;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        // Initialize PdfService which generates PDFs
        var service = new PdfService();

        // Create JSON-RPC server listening on websockets
        var jsonRpc = new JsonRpc(new WebSocketRpcServerMessageHandler(new Uri("ws://localhost:8080")));

        // Add the PdfService as an RPC target
        jsonRpc.AddLocalRpcTarget(service);

        // Start listening for incoming JSON-RPC requests
        jsonRpc.StartListening();

        Console.WriteLine("JsonRpc server listening on ws://localhost:8080");
        Console.WriteLine("Press any key to stop the server...");

        // Wait for user input to stop the server
        Console.ReadKey();

        // Gracefully stop listening and dispose resources when done
        await jsonRpc.StopListeningAsync();
        jsonRpc.Dispose();
    }
}
using StreamJsonRpc;
using System;
using System.Net.WebSockets;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        // Initialize PdfService which generates PDFs
        var service = new PdfService();

        // Create JSON-RPC server listening on websockets
        var jsonRpc = new JsonRpc(new WebSocketRpcServerMessageHandler(new Uri("ws://localhost:8080")));

        // Add the PdfService as an RPC target
        jsonRpc.AddLocalRpcTarget(service);

        // Start listening for incoming JSON-RPC requests
        jsonRpc.StartListening();

        Console.WriteLine("JsonRpc server listening on ws://localhost:8080");
        Console.WriteLine("Press any key to stop the server...");

        // Wait for user input to stop the server
        Console.ReadKey();

        // Gracefully stop listening and dispose resources when done
        await jsonRpc.StopListeningAsync();
        jsonRpc.Dispose();
    }
}
Imports StreamJsonRpc
Imports System
Imports System.Net.WebSockets
Imports System.Threading.Tasks

Friend Class Program
	Shared Async Function Main(ByVal args() As String) As Task
		' Initialize PdfService which generates PDFs
		Dim service = New PdfService()

		' Create JSON-RPC server listening on websockets
		Dim jsonRpc As New JsonRpc(New WebSocketRpcServerMessageHandler(New Uri("ws://localhost:8080")))

		' Add the PdfService as an RPC target
		jsonRpc.AddLocalRpcTarget(service)

		' Start listening for incoming JSON-RPC requests
		jsonRpc.StartListening()

		Console.WriteLine("JsonRpc server listening on ws://localhost:8080")
		Console.WriteLine("Press any key to stop the server...")

		' Wait for user input to stop the server
		Console.ReadKey()

		' Gracefully stop listening and dispose resources when done
		Await jsonRpc.StopListeningAsync()
		jsonRpc.Dispose()
	End Function
End Class
$vbLabelText   $csharpLabel

streamjsonrpc c# (개발자를 위한 작동 원리): 그림 5

IronPDF 클라이언트 생성

서버에 연결하고 PDF 생성을 요청하려면, StreamJsonRpc 클라이언트 (ClientProgram.cs)를 구현하세요:

using StreamJsonRpc;
using System;
using System.Net.WebSockets;
using System.Text;
using System.Threading.Tasks;
using System.IO;

class ClientProgram
{
    static async Task Main(string[] args)
    {
        // Create JSON-RPC client connected to WebSocket server endpoint
        var proxy = new JsonRpc(new WebSocketRpcClientMessageHandler(new Uri("ws://localhost:8080")));

        // Start listening for incoming messages from the server
        await proxy.StartListeningAsync();

        // Example HTML content
        string htmlContent = "<html><body><h1>Hello, IronPDF!</h1></body></html>";

        // Invoke GeneratePdfAsync method on the server
        var pdfBytes = await proxy.InvokeAsync<byte[]>("GeneratePdfAsync", htmlContent);

        // Save the resulted PDF to a file
        File.WriteAllBytes("GeneratedPdf.pdf", pdfBytes);

        Console.WriteLine("PDF generated: GeneratedPdf.pdf");

        // Dispose the proxy when done
        proxy.Dispose();
    }
}
using StreamJsonRpc;
using System;
using System.Net.WebSockets;
using System.Text;
using System.Threading.Tasks;
using System.IO;

class ClientProgram
{
    static async Task Main(string[] args)
    {
        // Create JSON-RPC client connected to WebSocket server endpoint
        var proxy = new JsonRpc(new WebSocketRpcClientMessageHandler(new Uri("ws://localhost:8080")));

        // Start listening for incoming messages from the server
        await proxy.StartListeningAsync();

        // Example HTML content
        string htmlContent = "<html><body><h1>Hello, IronPDF!</h1></body></html>";

        // Invoke GeneratePdfAsync method on the server
        var pdfBytes = await proxy.InvokeAsync<byte[]>("GeneratePdfAsync", htmlContent);

        // Save the resulted PDF to a file
        File.WriteAllBytes("GeneratedPdf.pdf", pdfBytes);

        Console.WriteLine("PDF generated: GeneratedPdf.pdf");

        // Dispose the proxy when done
        proxy.Dispose();
    }
}
Imports StreamJsonRpc
Imports System
Imports System.Net.WebSockets
Imports System.Text
Imports System.Threading.Tasks
Imports System.IO

Friend Class ClientProgram
	Shared Async Function Main(ByVal args() As String) As Task
		' Create JSON-RPC client connected to WebSocket server endpoint
		Dim proxy = New JsonRpc(New WebSocketRpcClientMessageHandler(New Uri("ws://localhost:8080")))

		' Start listening for incoming messages from the server
		Await proxy.StartListeningAsync()

		' Example HTML content
		Dim htmlContent As String = "<html><body><h1>Hello, IronPDF!</h1></body></html>"

		' Invoke GeneratePdfAsync method on the server
		Dim pdfBytes = Await proxy.InvokeAsync(Of Byte())("GeneratePdfAsync", htmlContent)

		' Save the resulted PDF to a file
		File.WriteAllBytes("GeneratedPdf.pdf", pdfBytes)

		Console.WriteLine("PDF generated: GeneratedPdf.pdf")

		' Dispose the proxy when done
		proxy.Dispose()
	End Function
End Class
$vbLabelText   $csharpLabel

PdfService.cs 클래스는 C# 응용 프로그램에서 IronPDF를 사용하여 PDF 문서를 쉽게 생성할 수 있도록 하는 StreamJsonRpc 서버 구현의 기본 구성 요소입니다. IronPDF의 RenderHtmlAsPdf을 활용하여 이 서비스 클래스는 HTML 자료를 PDF 형식으로 변환하는 데 필요한 메서드를 포함하고 있습니다. HTML 콘텐츠는 GeneratePdfAsync 메서드를 통해 비동기로 수신되며 (async Task<byte[]> GeneratePdfAsync(string htmlContent)) 지정됩니다.

이 메서드는 ChromePdfRenderer 인스턴스를 생성하여 변환을 수행하고, RenderHtmlAsPdf(htmlContent)과 함께 PDF 문서를 생성합니다. 생성된 PDF의 바이너리 데이터는 이후에 비동기적으로 메서드 (pdf.BinaryDataAsync())에 의해 가져와 byte[] 배열로 반환됩니다.

streamjsonrpc c# (개발자를 위한 작동 원리): 그림 6

이 메서드는 빠르고 반응성 있는 PDF 생성을 보장하여 문서를 빠르게 생성해야 하는 응용 프로그램에 적합합니다. PDF 생성 로직은 PdfService.cs에 포함되어 있어 개발자가 StreamJsonRpc를 통해 이 기능을 쉽게 통합하고 노출할 수 있도록 합니다. 이는 원격 클라이언트가 서버 측 설계의 모듈성 및 명확성을 유지하면서 PDF 생성 작업을 원활하게 호출할 수 있도록 합니다.

streamjsonrpc c# (개발자를 위한 작동 원리): 그림 7

결론

요약하자면, 개발자들은 StreamJsonRpc와 IronPDF를 결합함으로써 강력한 PDF 제작 기능을 활용하고 원격 프로시저 호출(RPC)을 지원하는 안정적이고 효과적인 .NET 앱을 만들 수 있습니다. StreamJsonRpc는 클라이언트와 서버 구성 요소 간의 원활한 통신을 가능하게 하는 경량 프로토콜인 JSON-RPC를 사용합니다. 개발자는 이를 IronPDF와 함께 사용하여 이러한 원격 호출의 결과에 따라 동적이고 데이터 기반의 PDF를 생성할 수 있습니다.

보고서, 청구서 또는 최신 데이터를 반영해야 하는 다른 문서를 준비할 때 실시간 데이터 검색 및 PDF 출력을 허용하므로 이 통합은 매우 유용합니다. 이 기술들의 통합은 개발 프로세스를 최적화하고 성능을 향상시키며 복잡한 비즈니스 요구를 효과적으로 충족시키기 위한 애플리케이션의 능력을 강화합니다.

IronPDF와 Iron Software Development Tools로 개발자는 더욱 많은 웹 앱과 기능을 빠르게 생성할 수 있으며, 시작 가격은 $799부터입니다. 이를 달성하기 위해 본질적인 개념을 매우 유연한 Iron Software 도구 상자와 결합합니다.

개발자가 프로젝트와 관련된 모든 라이선스 옵션이 명확하게 설명된 경우 최적의 모델을 선택하기가 더 쉬울 것입니다. 위에 나열된 이점들은 개발자가 시기 적절하고, 조정되며, 효율적인 방식으로 다양한 문제에 대한 솔루션을 만들기 쉽게 만듭니다.

자주 묻는 질문

C#에서 HTML을 PDF로 변환하는 방법은 무엇인가요?

PDF 라이브러리의 RenderHtmlAsPdf 메서드를 사용하여 HTML 문자열을 PDF로 변환할 수 있습니다. 또한, HTML 파일을 PDF로 변환하는 것은 RenderHtmlFileAsPdf 메서드를 사용하여 달성할 수 있습니다.

StreamJsonRpc란 무엇이며 C#에서 어떻게 작동하나요?

StreamJsonRpc는 JSON-RPC 프로토콜을 사용하여 원격 프로시저 호출을 촉진하는 C# 라이브러리입니다. 이는 TCP/IP, 네임드 파이프, HTTP와 같은 다양한 전송 프로토콜을 통해 클라이언트와 서버 간의 양방향 통신을 가능하게 합니다.

StreamJsonRpc가 PDF 생성 기능을 어떻게 향상시키나요?

StreamJsonRpc는 PDF 생성 작업을 JSON-RPC를 통해 원격 클라이언트가 PDF 라이브러리를 사용하여 HTML 콘텐츠를 동적으로 PDF로 변환할 수 있도록 하여 PDF 생성 기능을 향상시킵니다.

StreamJsonRpc가 분산 시스템에 유익한 이유는 무엇인가요?

StreamJsonRpc는 원활한 원격 메서드 호출을 가능하게 하고 비동기 작업을 지원하며, 강력한 오류 처리를 제공하여 시스템 신뢰성과 효율성을 향상시킵니다.

C# 프로젝트에서 StreamJsonRpc를 설정하는 데 포함되는 단계는 무엇인가요?

StreamJsonRpc를 C# 프로젝트에 설정하려면, .NET 프로젝트를 생성하고, NuGet을 통해 StreamJsonRpc 패키지를 설치하며, 선택한 전송 프로토콜을 통해 통신하도록 설정된 JSON-RPC 서버와 클라이언트를 구현해야 합니다.

StreamJsonRpc를 .NET 애플리케이션에서 보고서나 인보이스를 생성하는 데 사용할 수 있습니까?

예, StreamJsonRpc와 PDF 생성 라이브러리를 통합함으로써 JSON-RPC 요청에 대한 응답으로 보고서 또는 인보이스에 대한 PDF를 동적으로 생성할 수 있으며, 이는 문서 중심 애플리케이션에 이상적입니다.

StreamJsonRpc는 어떤 전송 프로토콜을 지원합니까?

StreamJsonRpc는 전송 계층에 독립적이며, HTTP, 네임드 파이프, TCP/IP와 같은 다양한 전송 프로토콜을 지원하여 개발자들이 애플리케이션의 특정 요구 사항에 따라 선택할 수 있도록 합니다.

PDF 라이브러리는 C#에서 문서 조작을 어떻게 용이하게 합니까?

C#의 PDF 라이브러리는 PDF를 생성, 읽기 및 편집할 수 있도록 하여 문서 조작을 용이하게 합니다. 이는 HTML, CSS, JavaScript를 PDF로 변환하는 것을 지원하며, 헤더, 푸터 추가 및 분할, 병합 등의 작업을 수행할 수 있습니다.

StreamJsonRpc에서 비동기 작업을 사용하는 이점은 무엇입니까?

StreamJsonRpc의 비동기 작업은 .NET 이벤트를 사용하여 들어오는 요청과 응답을 효율적으로 처리함으로써 애플리케이션의 응답성과 확장성을 향상시킵니다.

StreamJsonRpc는 어떻게 신뢰할 수 있는 오류 처리를 보장합니까?

StreamJsonRpc는 원격 메서드 호출 중 발생하는 예외와 문제를 관리하기 위한 포괄적인 기능을 제공하여 분산 시스템의 회복성을 유지함으로써 신뢰할 수 있는 오류 처리를 보장합니다.

제이콥 멜러, 팀 아이언 최고기술책임자
최고기술책임자

제이콥 멜러는 Iron Software의 최고 기술 책임자(CTO)이자 C# PDF 기술을 개척한 선구적인 엔지니어입니다. Iron Software의 핵심 코드베이스를 최초로 개발한 그는 창립 초기부터 회사의 제품 아키텍처를 설계해 왔으며, CEO인 캐머런 리밍턴과 함께 회사를 NASA, 테슬라, 그리고 전 세계 정부 기관에 서비스를 제공하는 50명 이상의 직원을 보유한 기업으로 성장시켰습니다.

제이콥은 맨체스터 대학교에서 토목공학 학사 학위(BEng)를 최우등으로 취득했습니다(1998~2001). 1999년 런던에서 첫 소프트웨어 회사를 설립하고 2005년 첫 .NET 컴포넌트를 개발한 후, 마이크로소프트 생태계 전반에 걸쳐 복잡한 문제를 해결하는 데 전문성을 발휘해 왔습니다.

그의 대표 제품인 IronPDF 및 Iron Suite .NET 라이브러리는 전 세계적으로 3천만 건 이상의 NuGet 설치 수를 기록했으며, 그의 핵심 코드는 전 세계 개발자들이 사용하는 다양한 도구에 지속적으로 활용되고 있습니다. 25년의 실무 경험과 41년의 코딩 전문성을 바탕으로, 제이콥은 차세대 기술 리더들을 양성하는 동시에 기업 수준의 C#, Java, Python PDF 기술 혁신을 주도하는 데 주력하고 있습니다.

아이언 서포트 팀

저희는 주 5일, 24시간 온라인으로 운영합니다.
채팅
이메일
전화해