pip_services3_rpc 1.2.5 copy "pip_services3_rpc: ^1.2.5" to clipboard
pip_services3_rpc: ^1.2.5 copied to clipboard

This framework is a part of the [Pip.Services] project. It provides the following synchronous communication components over HTTP RPC

example/main.dart

import 'package:pip_services3_commons/pip_services3_commons.dart';
import './Dummy.dart';
import './DummyController.dart';
import './DummyCommandableHttpService.dart';
import './DummyCommandableHttpClient.dart';

void main() async {
  var restConfig = ConfigParams.fromTuples([
    'connection.protocol',
    'http',
    'connection.host',
    'localhost',
    'connection.port',
    3000
  ]);

  DummyCommandableHttpService service;
  DummyCommandableHttpClient client;

  var ctrl = DummyController();

  service = DummyCommandableHttpService();
  service.configure(restConfig);

  var references = References.fromTuples([
    Descriptor(
        'pip-services-dummies', 'controller', 'default', 'default', '1.0'),
    ctrl,
    Descriptor('pip-services-dummies', 'service', 'http', 'default', '1.0'),
    service
  ]);
  service.setReferences(references);

  await service.open(null);

  client = DummyCommandableHttpClient();

  client.configure(restConfig);
  client.setReferences(References());
  await client.open(null);

  var dummy1 = Dummy.from(null, 'Key 1', 'Content 1');
  var dummy2 = Dummy.from(null, 'Key 2', 'Content 2');

  // Create one dummy
  try {
    var dummy = await client.createDummy(null, dummy1);
    // work with created item

    dummy1 = dummy!;
  } catch (err) {
    // error processing
  }

  // Create another dummy
  try {
    var dummy = await client.createDummy(null, dummy2);
    // work with second created item
    dummy2 = dummy!;
  } catch (err) {
    // error processing
  }

  // Get all dummies
  try {
    var dummies = await client.getDummies(
        null, FilterParams(), PagingParams(0, 5, false));
    // processing recived items
  } catch (err) {
    // error processing
  }

  // Update the dummy
  try {
    dummy1.content = 'Updated Content 1';
    var dummy = await client.updateDummy(null, dummy1);
    // processing with updated item
    dummy1 = dummy!;
  } catch (err) {
    // error processing
  }

  // Delete dummy
  try {
    await client.deleteDummy(null, dummy1.id!);
  } catch (err) {
    // error processing
  }

  // Try to get delete dummy
  try {
    var dummy = await client.getDummyById(null, dummy1.id!);
    // work with deleted item
  } catch (err) {
    // error processing
  }
  // close service and client
  await client.close(null);
  await service.close(null);
}
0
likes
105
pub points
2%
popularity

Publisher

verified publisherentinco.com

This framework is a part of the [Pip.Services] project. It provides the following synchronous communication components over HTTP RPC

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

http, pip_services3_commons, pip_services3_components, shelf, shelf_router

More

Packages that depend on pip_services3_rpc