<sca:service name="QuoteService" promote="StockService/QuoteService"> <http:binding.http> <selector:operationSelector operationName="getPrice"/> <http:contextPath>http-binding/quote</http:contextPath> </http:binding.http> </sca:service>
The HTTP component in SwitchYard provides HTTP-based binding support for services and references in SwitchYard.
Composite-level services can be exposed as a HTTP-based service using the <binding.http> binding definition. The following configuration options are available for binding.rest when binding services:
operationSelector : specification of the operation to use for the message exchange. See Operation Selector for more details.
contextPath : A context path for the HTTP endpoint.
Here's an example of what a HTTP service binding looks like:
<sca:service name="QuoteService" promote="StockService/QuoteService"> <http:binding.http> <selector:operationSelector operationName="getPrice"/> <http:contextPath>http-binding/quote</http:contextPath> </http:binding.http> </sca:service>
Binding a reference with HTTP can be used to make HTTP-based services available to SwitchYard services. The following configuration options are available for binding.http when binding references:
address : A URL that points to the HTTP endpoint. It is optional and if not specified will default to http://127.0.0.1:8080/.
method : The HTTP method used for invoking the endpoint. Default is GET.
timeout : The request's time-out value in milliseconds.
contentType : The HTTP Content-Type header that needs to be set on the request.
proxy : HTTP Proxy settings for the endpoint.
basic/ntlm : authentication configuration for the endpoint.
Here's an example of what a HTTP reference binding looks like:
<sca:reference name="Symbol" promote="StockService/SymbolService" multiplicity="1..1"> <http:binding.http> <http:address>http://localhost:8080/http-binding/symbol</http:address> <http:method>POST</http:method> <http:contentType>text/plain</http:contentType> </http:binding.http> </sca:reference>
If the HTTP reference needs to pass through a proxy server then the proxy server configuration can be provided using the proxy element. The following configuration options are available:
host : The proxy host.
port : The proxy port (optional).
user : The proxy user (optional).
password : The proxy password (optional).
<sca:reference name="Symbol" promote="StockService/SymbolService" multiplicity="1..1"> <http:binding.http> <http:address>http://localhost:8080/http-binding/symbol</http:address> <http:proxy> <http:host>host</http:host> <http:port>8090</http:port> <http:user>Beal</http:user> <http:password>conjecture</http:password> </http:proxy> </http:binding.http> </sca:reference>
If the HTTP reference endpoint is secured using BASIC/NTLM, then the authentication configuration can be provided using the basic or ntlm elements. The following configuration options are available:
user : The authentication user.
password : The authentication password.
realm/domain : The authentication realm or the Windows domain.
A sample BASIC authentication configuration:
<sca:reference name="Symbol" promote="StockService/SymbolService" multiplicity="1..1"> <http:binding.http> <http:address>http://localhost:8080/http-binding/symbol</http:address> <http:basic> <http:user>Beal</http:user> <http:password>conjecture</http:password> <http:realm>Any</http:realm> </http:basic> </http:binding.http> </sca:reference>