The Tuscany Java SCA runtime supports Web services by using the <binding.ws> SCDL extension. New Web service endpoints can be provided by using <binding.ws> within a SCA <service>, existing Web services can be invoked by using <binding.ws> within a SCA <reference>.
The Web service binding is one of the SCA extensions which is being formalized in the OASIS Open Composite Services Architecture with a published specifications document.
The Web service binding SCDL has the following format:
<binding.ws name="NCName"? uri="xs:anyURI"? wsdlElement="xs:anyURI"? wsdli:wsdlLocation="list of xs:anyURI"? >
All the attributes and elements of the Web service binding are optional, so the simplest way to use it is to use all the defaults:
With that simplest form the endpoint which will be used is derived from the names of the component and binding. This works well for services but for references its likely not what you want, so with references the following is a more useful simplest form:
The wsdlElement attribute indicates that a WSDL document exists which should be used and it points to the element within that WSDL to use. The value of the wsdlElement attribute can have one of the following four forms:
In this case, all the endpoints in the WSDL Service that have equivalent PortTypes with the SCA service or reference must be available to the SCA service or reference.
- Port (WSDL 1.1):
In this case, the identified port in the WSDL 1.1 Service must have an equivalent PortType with the SCA service or reference.
- Endpoint (WSDL 2.0):
In this case, the identified endpoint in the WSDL 2.0 Service must have an equivalent PortType with the SCA service or reference.
In this case, the identified WSDL binding must have an equivalent PortType with the SCA service or reference. In this case the endpoint address URI for the SCA service or reference must be provided via the URI attribute on the binding.
|What will the endpoint be?|
The actual Web service endpoint used depends on whether or not a WSDL port is being used, if the EndpointReference element or the uri attribute of the <binding.ws> has been specified, and the names of the component and binding. The actual alogrythim defined in the Web service binding specification is:
- Either the URIs in the endpoint(s) of the referenced WSDL
or the URI specified by the wsa:Address element of the wsa:EndpointReference
- The explicitly stated URI in the "uri" attribute of the binding.ws element, which may be relative,
- The implicit URI as defined by the Assembly specification
The URI in the WSDL endpoint or in the wsa:Address of an EPR may be a relative URI, in which case it is relative to the URI defined in (2) or (3). The wsa:Address element can be the empty relative URI, in which case it uses the URI defined in (2) or (3) directly. This allows the EPR writer to specify reference parameters, metadata and other EPR contents while allowing the URI to be chosen by the deployer. To reference a WSDL document and also specify an EPR, the wsdlElement attribute must refer to a binding element in the WSDL and not an endpoint or service.
The wsdlLocation attribute enables defining the location of the WSDL document to be used. Using wsdlLocation is not normally necessary as the Tuscany contrabution service will have discovered all the WSDL documents within a deployed SCA contrabution.
This attribute enables using a WS-Addressing EndpointReference that specifies the endpoint for the service or reference, or any WSA reference parameters, metadata and other EPR contents to be used.
This example shows making a HelloWorld component available as a Web service endpoint. All the Web service binding defaults are used so the endpoint of the Web service will be http://localhost:8080/HelloWorldComponent.
<service name="HelloWorldService" promote="HelloWorldComponent">
<interface.java interface="helloworld.HelloWorldService" />
<implementation.java class="helloworld.HelloWorldImpl" />