Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 29. Provider Endpoints

Abstract

A provider endpoint sends requests to external endpoints and waits for the response. It is configured using a single XML element that specifies the WSDL document defining the endpoint.
Important
The Java Business Integration components of Red Hat JBoss Fuse are considered deprecated. You should consider migrating any JBI applications to OSGi.

Overview

Provider endpoints play the role of service provider from the vantage point of other endpoints running inside of the ESB. However, from outside of the ESB a provider endpoint plays the role of a consumer. As shown in Figure 29.1, “Provider Endpoint”, provider endpoints make requests on external endpoints. When it receives the response, the provider endpoint returns it back to the NMR.

Figure 29.1. Provider Endpoint

provider endpoint in a message exchange
Important
Because provider endpoint's behave like consumers to external endpoints, you configure the runtime behavior of the transport using the consumer-specific WSDL entries.

Procedure

To configure a provider endpoint do the following:
  1. Add a provider element to your xbean.xml file.
  2. Add a wsdl attribute to the provider element.
  3. If your WSDL defines more than one service, you will need to specify a value for the service attribute.
  4. If the service you choose defines more than one endpoint, you will need to specify a value for the endpoint attribute.
  5. If your endpoint is going to be receiving binary attachments set its mtomEnabled attribute to true.
  6. If your endpoint does not need to process the JBI wrapper set its useJbiWrapper attribute to false.
  7. If you are using any of the advanced features, such as WS-Addressing or WS-Policy, specify a value for the busCfg attribute.
    See ???.

Specifying the WSDL

The wsdl attribute is the only required attribute to configure a provider endpoint. It specifies the location of the WSDL document that defines the endpoint being exposed. The path used is relative to the top-level of the exploded service unit.
Tip
If the WSDL document defines a single service with a single endpoint, then you do not require any additional information to expose a provider endpoint.
Example 29.1, “Minimal Provider Endpoint Configuration” shows the minimal configuration for a provider endpoint.

Example 29.1. Minimal Provider Endpoint Configuration

<beans xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
       ... >
  ...
  <cxfbc:provider wsdl="/wsdl/widget.wsdl" />

  ...
</beans>
For information on creating a WSDL document see ???.

Specifying the endpoint details

If the endpoint's WSDL document defines a single service with a single endpoint, the ESB can easily determine which endpoint to use. It will use the values from the WSDL document to specify the service name, endpoint name and interface name for the instantiated endpoint.
However, if the endpoint's WSDL document defines multiple services or if it defines multiple endpoints for a service, you will need to provide the provider endpoint with additional information so that it can determine the proper definition to use. What information you need to provide depends on the complexity of the WSDL document. You may need to supply values for both the service name and the endpoint name, or you may only have to supply one of these values.
If the WSDL document contains more than one service element you will need to specify a value for the provider's service attribute. The value of the provider's service attribute is the QName of the WSDL service element that defines the desired service in the WSDL document. For example, if you wanted your endpoint to use the WidgetInventoryService in the WSDL shown in Example 29.2, “WSDL with Two Services” you would use the configuration shown in Example 29.3, “Provider Endpoint with a Defined Service Name”.

Example 29.2. WSDL with Two Services

<definitions ...
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             targetNamespace="http://demos.widgetVendor.com" ...>
  ...
  <service name="WidgetSalesService">
    <port binding="WidgetSalesBinding" name="WidgetSalesPort">
      <soap:address location="http://widget.sales.com/index.xml">
    </port>
  </service>

  <service name="WidgetInventoryService">
    <port binding="WidgetInventoryBinding" name="WidgetInventoryPort">
      <soap:address location="http://widget.inventory.com/index.xml">
    </port>
  </service>
  ...
<definitions>

Example 29.3. Provider Endpoint with a Defined Service Name

<beans xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
       xmlns:widgets="http://demos.widgetVendor.com"
       ... >
  ...
  <cxfbc:provider wsdl="/wsdl/widget.wsdl"
                  service="widgets:WidgetInventoryService" />

  ...
</beans>
If the WSDL document's service definition contains more than one endpoint, then you will need to provide a value for the provider's endpoint attribute. The value of the endpoint attribute corresponds to the value of the WSDL port element's name attribute. For example, if you wanted your endpoint to use the WidgetWesternSalesPort in the WSDL shown in Example 29.4, “Service with Two Endpoints” you would use the configuration shown in Example 29.5, “Provider Endpoint with a Defined Endpoint Name”.

Example 29.4. Service with Two Endpoints

<definitions ...
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             targetNamespace="http://demos.widgetVendor.com" ...>
  ...
  <service name="WidgetSalesService">
    <port binding="WidgetSalesBinding" name="WidgetWesternSalesPort">
      <soap:address location="http://widget.sales.com/index.xml">
    </port>
    <port binding="WidgetSalesBinding" name="WidgetEasternSalesPort">
      <jms:address jndiConnectionFactoryName="ConnectionFactory"
                   jndiDestinationName="dynamicQueues/test.Celtix.jmstransport" >
        <jms:JMSNamingProperty name="java.naming.factory.initial"
                               value="org.activemq.jndi.ActiveMQInitialContextFactory" />
        <jms:JMSNamingProperty name="java.naming.provider.url"
                               value="tcp://localhost:61616" />
      </jms:address>
    </port>
  </service>
  ...
<definitions>

Example 29.5. Provider Endpoint with a Defined Endpoint Name

<beans xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
       xmlns:widgets="http://demos.widgetVendor.com"
       ... >
  ...
  <cxfbc:provider wsdl="/wsdl/widget.wsdl"
                  endpoint="WidgetWesternSalesService" />
  ...
</beans>