ZayniFramework.Middle.Service.Client
2.0.1
See the version list below for details.
dotnet add package ZayniFramework.Middle.Service.Client --version 2.0.1
NuGet\Install-Package ZayniFramework.Middle.Service.Client -Version 2.0.1
<PackageReference Include="ZayniFramework.Middle.Service.Client" Version="2.0.1" />
<PackageVersion Include="ZayniFramework.Middle.Service.Client" Version="2.0.1" />
<PackageReference Include="ZayniFramework.Middle.Service.Client" />
paket add ZayniFramework.Middle.Service.Client --version 2.0.1
#r "nuget: ZayniFramework.Middle.Service.Client, 2.0.1"
#:package ZayniFramework.Middle.Service.Client@2.0.1
#addin nuget:?package=ZayniFramework.Middle.Service.Client&version=2.0.1
#tool nuget:?package=ZayniFramework.Middle.Service.Client&version=2.0.1
Middleware ServiceHost.Client example.
You have define your own business logic service by using Middle.ServiceHost module. Now you can use Middle.ServiceHost.Client module to request your service action or trigger a service event to publish a message to your service action.
First, add a serviceClientConfig.json in your client-side app project.
{
"serviceClients": [
{
"serviceClientName": "PaymentServiceProxy",
"remoteServiceName": "PaymentService",
"remoteHostType": "TCPSocket",
"remoteClient": "GCP-Production",
"enableActionLogToDB": true
},
{
"serviceClientName": "OrderServiceProxy",
"remoteServiceName": "OrderService",
"remoteHostType": "RabbitMQ",
"remoteClient": "GCP-Production",
"enableActionLogToDB": true
}
],
"rabbitMQProtocol": {
"defaultRemoteClient": "GCP-Production",
"remoteClients": [
{
"name": "GCP-Production",
"mbHost": "XXX",
"mbPort": 5672,
"mbUserId": "XXX",
"mbPassword": "XXX",
"mbVHost": "SomeHost",
"defaultExchange": "Middle.Test.Topic",
"rpc": {
"exchange": "Middle.Test.Topic",
"routingKey": "RPC.Server.",
"rpcReplyQueue": "Middle.Server.RPC.Res",
"rcpResponseTimeout": 5
},
"publish": {
"exchange": "Middle.Test.Topic",
"routingKey": "Event.Client."
},
"listen": {
"msgQueue": "Middle.Client.ListenServer.Msg",
"msgRoutingKey": "Event.Server."
}
},
{
"name": "Azure-Production",
"mbHost": "XXX",
"mbPort": 5672,
"mbUserId": "XXX",
"mbPassword": "XXX",
"mbVHost": "SomeHost",
"defaultExchange": "Middle.Test.Topic",
"rpc": {
"exchange": "Middle.Test.Topic",
"routingKey": "RPC.Server.",
"rpcReplyQueue": "Middle.Server.RPC.Res",
"rcpResponseTimeout": 5
},
"publish": {
"exchange": "Middle.Test.Topic",
"routingKey": "Event.Client."
},
"listen": {
"msgQueue": "Middle.Client.ListenServer.Msg",
"msgRoutingKey": "Event.Server."
}
}
]
},
"tcpSocketProtocol": {
"defaultRemoteClient": "GCP-Production",
"remoteClients": [
{
"name": "GCP-Production",
"tcpServerHost": "XXX",
"tcpServerPort": 5590,
"tcpSendBufferSize": 5,
"tcpReceiveBufferSize": 10,
"connectionTimeout": 1,
"tcpResponseTimeout": 5
},
{
"name": "Azure-Production",
"tcpServerHost": "XXX",
"tcpServerPort": 5590,
"tcpSendBufferSize": 5,
"tcpReceiveBufferSize": 5,
"connectionTimeout": 2,
"tcpResponseTimeout": 5
}
]
},
"webSocketProtocol": {
"defaultRemoteClient": "GCP-Production",
"remoteClients": [
{
"name": "GCP-Production",
"webSocketHostBaseUrl": "ws://XXX.XXX.XXX.XXX:5580",
"wsResponseTimeout": 5
},
{
"name": "Azure-Production",
"webSocketHostBaseUrl": "ws://XXX.XXX.XXX.XXX:5580",
"wsResponseTimeout": 5
}
]
}
}
Write your ClientProxy class and extends RemoteProxy class.<br/> Add namespace using.
using ZayniFramework.Common;
using ZayniFramework.Middle.Service.Client;
/// <summary>Some client proxy.
/// </summary>
public class PaymentProxy : RemoteProxy
Write your constructor and pass the service client name to base class.
/// <summary>預設建構子
/// </summary>
public PaymentProxy() : base( "PaymentServiceProxy" )
{
// pass
}
/// <summary>多載建構子
/// </summary>
/// <param name="path">服務客戶端 serviceClientConfig.json 設定檔的路徑</param>
public PaymentProxy( string path = "./serviceClientConfig.json" ) : base( serviceClientName: "PaymentServiceProxy", configPath: "./serviceClientConfig.json" )
{
// pass
}
Then, you can use the RemoteProxy base methods, you can send a RPC request or publish message to your Middle.ServiceHost service action.
/// <summary>執行遠端服務動作的測試
/// </summary>
public new Result<TResDTO> Execute<TReqDTO, TResDTO>( string actionName, TReqDTO request ) => base.Execute<TReqDTO, TResDTO>( actionName, request );
/// <summary>發佈 ServiceEvent 服務事件訊息的測試
/// </summary>
public new Result Publish<TMsgDTO>( string actionName, TMsgDTO dto ) => base.Publish<TMsgDTO>( actionName, dto );
Finally, you can use your own Client Proxy object to send RPC request or publish message.
var paymentProxy = new PaymentProxy( "./serviceClientConfig.json" );
var reqDTO = new SomethingDTO()
{
SomeMessage = "This is a message from masOS or linux.",
SomeDate = DateTime.Now,
SomeMagicNumber = 24.52D,
LuckyNumber = 333,
IsSuperMan = true
};
// Send a RPC request to the ServiceHost server-side.
var r = paymentProxy.Execute<SomethingDTO, MagicDTO>( "MagicTestAction", reqDTO );
More detail sample code. You can go to Test/ServieHostTest/ServiceHost.Client.App directory to see the complete sample code.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 11.0.2)
- RabbitMQ.Client (>= 5.1.0)
- RestSharp (>= 106.3.1)
- websocketsharp.core (>= 1.0.0)
- ZayniFramework.Common (>= 2.0.1)
- ZayniFramework.DataAccess (>= 2.0.1)
- ZayniFramework.Logging (>= 2.0.1)
- ZayniFramework.Middle.Service.Entity (>= 2.0.1)
- ZayniFramework.RabbitMQ.Msg.Client (>= 1.0.1)
- ZayniFramework.Serialization (>= 2.0.1)
- ZayniFramework.Validation (>= 2.0.1)
- ZeroFormatter (>= 1.6.4)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ZayniFramework.Middle.Service.Client:
| Package | Downloads |
|---|---|
|
ZayniFramework.Middle.Service.Grpc.Client
This is an extension module for Zayni Framework's Middle.Service.Client module. This extension module provide the gRPC RemoteClient implementation for Middle.Service.Client module. GitLab Repository: https://gitlab.com/ponylin1985/zayniframework |
|
|
ZayniFramework.Middle.Service.HttpCore.Client
This is an extension module for Zayni Framework's Middle.Service.Client module. This extension module provide the Http RemoteClient implementation for Middle.Service.Client module. GitLab Repository: https://gitlab.com/ponylin1985/zayniframework |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.0.142 | 360 | 3/19/2024 |
| 8.0.141 | 345 | 1/4/2024 |
| 8.0.140 | 364 | 12/17/2023 |
| 6.0.138 | 394 | 3/19/2024 |
| 6.0.137 | 550 | 9/20/2023 |
| 6.0.136 | 539 | 9/14/2023 |
| 6.0.135 | 590 | 9/10/2023 |
| 6.0.134 | 598 | 7/12/2023 |
| 6.0.133 | 622 | 7/10/2023 |
| 6.0.132 | 618 | 7/7/2023 |
| 6.0.131 | 609 | 6/19/2023 |
| 6.0.130 | 650 | 6/19/2023 |
| 3.1.137 | 925 | 9/20/2023 |
| 3.1.136 | 834 | 9/14/2023 |
| 3.1.135 | 861 | 9/10/2023 |
| 3.1.134 | 963 | 7/12/2023 |
| 3.1.133 | 973 | 7/11/2023 |
| 3.1.132 | 977 | 7/8/2023 |
| 3.1.131 | 904 | 6/19/2023 |
| 2.0.1 | 1,971 | 11/6/2018 |