1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2026-05-06 21:04:14 +02:00
Files
OpenIntegrations/docs/en/md/GRPC/Common-methods/Execute-method.mdx
T

189 lines
5.5 KiB
Plaintext
Vendored

---
sidebar_position: 4
description: Invoke method and other functions to work with GRPC in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, GRPC]
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Invoke method
Performs a unary request to the selected service
`Function ExecuteMethod(Val Connection, Val Service, Val Method, Val Request = Undefined, Val Timeout = 10000, Val Tls = Undefined) Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Connection | --conn | Arbitrary | ✔ | Existing connection or connection parameters |
| Service | --service | String | ✔ | Service name |
| Method | --method | String | ✔ | Method name |
| Request | --data | Structure Of KeyAndValue | ✖ | Request data |
| Timeout | --tout | Number | ✖ | Timeout (in ms) |
| Tls | --tls | Structure Of KeyAndValue | ✖ | TLS settings, if necessary. See GetTlsSettings |
Returns: Map Of KeyAndValue - Processing result
```bsl title="1C:Enterprise/OneScript code example"
Address = "https://grpcb.in:9001";
Proto1 = "https://hut.openintegrations.dev/test_data/grpcbin_with_import.proto"; // String, path to file or URL
Proto2 = "https://hut.openintegrations.dev/test_data/mt.proto"; // String, path to file or URL
Scheme = New Map;
Scheme.Insert("main.proto" , Proto1); // Primary
Scheme.Insert("my_types.proto", Proto2); // For import in primary
Meta = New Structure("somekey", "somevalue");
Parameters = OPI_GRPC.GetConnectionParameters(Address, Scheme, Meta);
Tls = OPI_GRPC.GetTlsSettings(True);
Service = "grpcbin.GRPCBin";
Method = "DummyUnary";
StingsArray = New Array;
StingsArray.Add("one");
StingsArray.Add("two");
StingsArray.Add("three");
NumberArray = New Array;
NumberArray.Add(1);
NumberArray.Add(10);
NumberArray.Add(100);
StructuresArray = New Array;
StructuresArray.Add(New Structure("f_string", "Nested value 1"));
StructuresArray.Add(New Structure("f_string", "Nested value 2"));
BoolArray = New Array;
BoolArray.Add(True);
BoolArray.Add(False);
File = "https://hut.openintegrations.dev/test_data/document.docx";
OPI_TypeConversion.GetBinaryData(File);
TFN = GetTempFileName();
File.Write(TFN);
BinaryDataArray = New Array;
BinaryDataArray.Add(File); // How Data
BinaryDataArray.Add(TFN); // How path to file
Data = New Map;
Data.Insert("f_string" , "Test message");
Data.Insert("f_int32" , 123);
Data.Insert("f_int64" , 123);
Data.Insert("f_float" , 123.22000122070312);
Data.Insert("f_bool" , True);
Data.Insert("f_enum" , "ENUM_1");
Data.Insert("f_bytes" , File);
Data.Insert("f_sub" , New Structure("f_string" , "Nested value"));
Data.Insert("f_strings", StingsArray);
Data.Insert("f_int32s" , NumberArray);
Data.Insert("f_int64s" , NumberArray);
Data.Insert("f_floats" , NumberArray);
Data.Insert("f_bytess" , BinaryDataArray);
Data.Insert("f_subs" , StructuresArray);
Data.Insert("f_bools" , BoolArray);
Data.Insert("f_enums" , StrSplit("ENUM_1,ENUM_2" , ","));
Result = OPI_GRPC.ExecuteMethod(Parameters, Service, Method, Data, , Tls);
```
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
# JSON data can also be passed as a path to a .json file
oint grpc ExecuteMethod \
--conn "{'address':'https://grpcb.in:9001','metadata':{'somekey':'***'},'proto':{'main.proto':'https://hut.openintegrations.dev/test_data/grpcbin_with_import.proto','my_types.proto':'https://hut.openintegrations.dev/test_data/mt.proto'}}" \
--service "grpcbin.GRPCBin" \
--method "HeadersUnary" \
--tls "{'use_tls':true,'accept_invalid_certs':true}"
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
:: JSON data can also be passed as a path to a .json file
oint grpc ExecuteMethod ^
--conn "{'address':'https://grpcb.in:9001','metadata':{'somekey':'***'},'proto':{'main.proto':'https://hut.openintegrations.dev/test_data/grpcbin_with_import.proto','my_types.proto':'https://hut.openintegrations.dev/test_data/mt.proto'}}" ^
--service "grpcbin.GRPCBin" ^
--method "HeadersUnary" ^
--tls "{'use_tls':true,'accept_invalid_certs':true}"
```
</TabItem>
</Tabs>
```json title="Result"
{
"data": {
"f_bool": true,
"f_bools": [
true,
false
],
"f_bytes": {
"BYTES": "UEsDBBQABgAIAAAAIQAykW9XZgEAAKUFAAATAAgCW0..."
},
"f_bytess": [
{
"BYTES": "UEsDBBQABgAIAAAAIQAykW9XZgEAAKUFAAATAAgCW0..."
},
{
"BYTES": "UEsDBBQABgAIAAAAIQAykW9XZgEAAKUFAAATAAgCW0..."
}
],
"f_enum": "ENUM_1",
"f_enums": [
"ENUM_1",
"ENUM_2"
],
"f_float": 123.220001220703,
"f_floats": [
1,
10,
100
],
"f_int32": 123,
"f_int32s": [
1,
10,
100
],
"f_int64": 123,
"f_int64s": [
1,
10,
100
],
"f_string": "Test message",
"f_strings": [
"one",
"two",
"three"
],
"f_sub": {
"f_string": "Nested value"
},
"f_subs": [
{
"f_string": "Nested value 1"
},
{
"f_string": "Nested value 2"
}
]
},
"result": true
}
```