<commit_before>[[serviceCall-eip]]
= Service Call EIP
*Available as of Camel 2.18*

The Service Call EIP allows to call remote services in a distributed system.
The service to call is looked up in a service registry of some sorts such as Kubernetes, Consul, Etcd, Zookeeper, DNS.
The EIP separates the configuration of the service registry from the calling of the service.

When calling a service you may just refer to the name of the service in the EIP as shown below:

[source,java]
----
from("direct:start")
    .serviceCall("foo")
    .to("mock:result");
----

[source,xml]
----
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="direct:start"/>
    <serviceCall name="foo"/>
    <to uri="mock:result"/>
  </route>
</camelContext>
----

Camel will then:

* search for a service call configuration from the Camel context and registry
* lookup a service with the name ```foo``` from an external service registry
* filter the servers
* select the server to use
* build a Camel URI using the chosen server info

By default the Service Call EIP uses camel-http so assuming that the selected service instance runs on host ```myhost.com``` on port ```80```, the computed Camel URI will be:

[source]
----
http:myhost.com:80
----

== Service Name to Camel URI Examples

It is often needed to build more complex Camel URI which may include options or paths which is possible through different options:name: value

The *service name* supports a limited uri like syntax, here some examples

[width="100%",cols="25%a,75%a",options="header"]
|===
|Name |Resolution

|foo | http4://host:port
|foo/path | http4://host:port/path
|foo/path?foo=bar | http4://host:port/path?foo=bar
|===

[source,java]
----
from("direct:start")
    .serviceCall("foo/hello")
    .to("mock:result");
----

If you want to have more control over the uri construction, you can use the *uri* directive:

[width="100%",cols="25%a,40%a,35%a",options="header"]
|===
|Name | URI | Resolution

|foo | undertow:http://foo/hello | undertow:http://host:port/hello
|foo | undertow:http://foo.host:foo.port/hello | undertow:http://host:port/hello
|===

[source,java]
----<commit_msg>CAMEL-13792 - Rename components to default names, Camel-http4 to Camel-http - Fixed service-call eip docs<commit_after>[[serviceCall-eip]]
= Service Call EIP
*Available as of Camel 2.18*

The Service Call EIP allows to call remote services in a distributed system.
The service to call is looked up in a service registry of some sorts such as Kubernetes, Consul, Etcd, Zookeeper, DNS.
The EIP separates the configuration of the service registry from the calling of the service.

When calling a service you may just refer to the name of the service in the EIP as shown below:

[source,java]
----
from("direct:start")
    .serviceCall("foo")
    .to("mock:result");
----

[source,xml]
----
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="direct:start"/>
    <serviceCall name="foo"/>
    <to uri="mock:result"/>
  </route>
</camelContext>
----

Camel will then:

* search for a service call configuration from the Camel context and registry
* lookup a service with the name ```foo``` from an external service registry
* filter the servers
* select the server to use
* build a Camel URI using the chosen server info

By default the Service Call EIP uses camel-http so assuming that the selected service instance runs on host ```myhost.com``` on port ```80```, the computed Camel URI will be:

[source]
----
http:myhost.com:80
----

== Service Name to Camel URI Examples

It is often needed to build more complex Camel URI which may include options or paths which is possible through different options:name: value

The *service name* supports a limited uri like syntax, here some examples

[width="100%",cols="25%a,75%a",options="header"]
|===
|Name |Resolution

|foo | http://host:port
|foo/path | http://host:port/path
|foo/path?foo=bar | http://host:port/path?foo=bar
|===

[source,java]
----
from("direct:start")
    .serviceCall("foo/hello")
    .to("mock:result");
----

If you want to have more control over the uri construction, you can use the *uri* directive:

[width="100%",cols="25%a,40%a,35%a",options="header"]
|===
|Name | URI | Resolution

|foo | undertow:http://foo/hello | undertow:http://host:port/hello
|foo | undertow:http://foo.host:foo.port/hello | undertow:http://host:port/hello
|===

[source,java]
----
{'fraction_non_alphanumeric': 0.13737875028197608, 'fraction_numerical': 0.01240694789081886, 'mean_word_length': 4.247337278106509, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4666050', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1343, 'n_words': 512}