Implementation
This section presents some of the key files that implement
the stock quotes EJB and its Web Service endpoint interface. You can also view
the Java files online.
| File |
Description |
| StockQuoteService.java |
Endpoint interface. |
| StockQuoteBean.java |
Bean implementation. |
| ejb-jar.xml |
Describes the EJBs in this application. |
| webservices.xml |
Describes the Web Services provided by this
application. |
| mapping.xml |
Associates a Java package with the URI used
in the WSDL file. |
| FBSStockQuoteService.wsdl |
Provides data required by clients to access
the Stock Quote service. |
| InvokeQuoteService.jsp |
Provides a client-side UI for accessing the
Stock Quote service. |
| QuoteServiceResults.jsp |
Displays results returned by the Stock Quote
service. |
ejb-jar.xml
As defined in the EJB 2.1 specification, only a stateless
session bean can expose a service endpoint.
<?xml version='1.0' encoding='UTF-8'?> <ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"> <enterprise-beans> <session> <description>Stock Quote Session Bean ( Stateless )</description> <display-name>StockQuoteEJB</display-name> <ejb-name>StockQuoteEJB</ejb-name> <service-endpoint>oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService</service-endpoint> <ejb-class>oracle.otnsamples.ibfbs.admin.ejb.StockQuoteBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <security-identity> <use-caller-identity/> </security-identity> </session> </enterprise-beans> </ejb-jar>
webservices.xml
The container uses this file to find the other files that
expose an endpoint interface to the StockQuote bean.
<?xml version='1.0' encoding='UTF-8'?> <webservices version="1.1" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd" > <description> Stock Quote Web Service </description> <webservice-description> <webservice-description-name>StockQuoteEJB</webservice-description-name> <wsdl-file>META-INF/FBSStockQuoteService.wsdl</wsdl-file> <jaxrpc-mapping-file>META-INF/mapping.xml</jaxrpc-mapping-file> <port-component> <port-component-name>StockQuoteServicePort</port-component-name> <wsdl-port> <namespaceURI>urn:oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService</namespaceURI> <localpart>StockQuoteServicePort</localpart> </wsdl-port> <service-endpoint-interface> oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService </service-endpoint-interface> <service-impl-bean> <ejb-link>StockQuoteEJB</ejb-link> </service-impl-bean> </port-component> </webservice-description> </webservices>
mapping.xml
This file is used by the container to associate a Java package
with the URI used in the WSDL file that describes the service.
<?xml version='1.0' encoding='UTF-8'?> <java-wsdl-mapping version="1.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd"> <package-mapping> <package-type>oracle.otnsamples.ibfbs.admin.ejb</package-type> <namespaceURI>urn:oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService</namespaceURI> </package-mapping> </java-wsdl-mapping>
FBSStockQuoteService.wsdl
This file provides the data a client requires to find a service
and call its methods. The highlighted lines show where the code uses data that
corresponds to entries in the mapping.xml file.
<definitions name="StockQuoteService" targetNamespace="urn:oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService" xmlns:tns="urn:oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/"> <types> <schema targetNamespace="urn:oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService" xmlns:tns="urn:oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ArrayOfstring"> <complexContent> <restriction base="soap-enc:Array"> <attribute ref="soap-enc:arrayType" wsdl:arrayType="string[]"/> </restriction> </complexContent> </complexType> <complexType name="ArrayOffloat"> <complexContent> <restriction base="soap-enc:Array"> <attribute ref="soap-enc:arrayType" wsdl:arrayType="soap-enc:float[]"/> </restriction> </complexContent> </complexType> </schema> </types> <message name="StockQuoteService_getStockQuote"> <part name="arrayOfString_1" type="tns:ArrayOfstring"/> </message> <message name="StockQuoteService_getStockQuoteResponse"> <part name="result" type="tns:ArrayOffloat"/> </message>
<portType name="StockQuoteService"> <operation name="getStockQuote" parameterOrder="arrayOfString_1"> <input message="tns:StockQuoteService_getStockQuote"/> <output message="tns:StockQuoteService_getStockQuoteResponse"/> </operation> </portType> <binding name="StockQuoteServiceBinding" type="tns:StockQuoteService"> <operation name="getStockQuote"> <input> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService"/> </input> <output> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:oracle.otnsamples.ibfbs.admin.ejb.StockQuoteService"/> </output> <soap:operation soapAction=""/> </operation>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> </binding> <service name="StockQuoteService"> <port name="StockQuoteServicePort" binding="tns:StockQuoteServiceBinding"> <soap:address location="CONTAINER_WILL_REPLACE_WITH_ACTUAL_URL_WHEN_DEPLOYED"/> </port> </service> </definitions>
 |
 |
|