Skip to content

Expose a REST API

Publish an HTTP or HTTPS endpoint that accepts requests, runs your integration logic and returns a structured response.

Choose a host component

HttpHost WebServiceHost APIHost
Exposes HTTP/HTTPS endpoints SOAP web services (.asmx) REST endpoints with named routes
Request handling The request flows to the next component on the canvas Each web method writes to an MSMQ request queue and waits on a response queue Optional C# pre-processing, then an MSMQ request queue
Best for Simple endpoints handled within one interface SOAP callers that need typed methods and classes High-throughput REST APIs processed by background workers
Reference This page This page APIHost

Build an endpoint with HttpHost

  1. Add the host
    Drag HttpHost onto the canvas, set its EndPoint to Source, and set: Prefixes: one or more listening addresses, for example https://+:8443/api/orders/ ValidIpAddresses: the client addresses allowed to connect UpdateMessageStore: True to put the request parameters in the Message Store
  2. Validate the request
    Link the host to a Csharp component that checks the payload and stores the values you need.
  3. Do the work
    Link to SqlProcedure, SqlQuery or a client component such as RESTfulService or WebService.
  4. Return the response
    Set the last component's EndPoint to Server. Its result travels back along the chain as the reply to the caller. Components such as SqlProcedure can return errors on the reply path with ReturnError and ErrorPrefix.
  5. Secure it
    Use HTTPS and bind a certificate to the port. See Security.

Host a SOAP web service with WebServiceHost

WebServiceHost publishes an .asmx service whose methods hand requests to message queues, so other interfaces process them.

Property Purpose
Prefixes, Virtual Path, Name Where the service listens. A prefix of http://+:8000/ serves http://server:8000/<Name>.asmx.
Physical Path Folder for the generated .asmx and web.config files
Namespace The service namespace, for example http://tempuri.org/
Additional Classes Custom types, each with a class name and typed properties (optionally arrays)
WebServices One entry per web method: Name, typed Arguments, ReturnType, RequestQueue, ResponseQueue and TimeOut
AutoGenerateCall, PreCallCode, PostCallCode Optional C# that shapes the request, or turns the queue reply (answer) into the return type

Response format

Use a consistent response contract so callers can handle every outcome the same way. i-Con doesn't impose a format, but this pattern for delimited responses works well and is used on many i-Con projects:

Outcome Format
Success R00\|<Status>\|<ReferenceNo>\|<Payload>
Failure R01\|<ErrorMessage>\|<ReferenceNo>\|<ErrorCode>

For JSON APIs, return an object with status, message, timestamp and data fields. The APIHost has an example.

Keep request handling fast

If the work takes longer than about 2.5 seconds, queue it, return a reference straight away and notify the caller when it finishes. See Asynchronous queue processing.