Create a Stock Quote Web Service
You can create a Stock Quote Web service in Sterling B2B Integrator.
To create a
Stock Quote Web service:
- Create an input schema that takes a stock symbol as input
by placing the following schema in a file named
stockQuoteInput.xsd
:<?xml version="1.0" encoding="utf-8" ?> <xs:schema elementFormDefault="qualified" targetNamespace= "http://www.webservice.stockquotein" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="GetQuote"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="1" name="symbol" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
For this input schema, Sterling B2B Integrator expects a SOAP Request similar to the following:<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.ditasoap.org/soap/envelope/"> <soap:Body> <GetQuote xmlns=" http://www.webservice.stockquotein"> <symbol>string</symbol> </GetQuote> </soap:Body> </soap:Envelope>
- Create an output schema that gives the output as price
by placing the following schema in a file named
stockQuoteOutput.xsd
:<?xml version="1.0" encoding="utf-8" ?> <xs:schema elementFormDefault="qualified" targetNamespace="http://www.webservice.stockquoteout" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="GetQuoteResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="1" name="GetQuoteResult" type= "xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
The SOAP response sent from Sterling B2B Integrator using this output schema looks like the following:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.ditasoap.org/soap/envelope/"> <soap:Body> <GetQuoteResponse xmlns="http://www.webservice.stockquoteout"> <GetQuoteResult>string</GetQuoteResult> </GetQuoteResponse> </soap:Body> </soap:Envelope>
-
From the Administration menu, select Deployment
>Schemas and check in these schemas.
Do not modify the target Namespace.
- Add the following to
namespaces.properties
file to create the namespaces for use in the input and output schemas.stockout=http://www.webservice.stockquoteout stockin=http://www.webservice.stockquotein
- Create a simple business process such as the following
in Sterling B2B Integrator to
handle the stock quote service functionality. It must return a price
as the response by creating the output XML and assigning it to WebservicesResponseNode.
Check in the business process into Sterling B2B Integrator as StockQuoteBP.
<process name="StockQuoteBP"> <sequence name="AssignSequence"> <assign to="stockout:GetQuoteResult">120.35</assign> <assign to="stockout:GetQuoteResponse" from="//*[namespace-uri()='http://www.webservice.stockquoteout' and local-name()='GetQuoteResult']"/> <assign to="WebservicesResponseNode" from="//*[namespace-uri()='http://www.webservice.stockquoteout' and local-name()='GetQuoteResponse']"/> </sequence> </process>
- From the Administration menu, select Deployment >
Web Services > Schema Mappings, create a new business
process schema mapping.
- Select
StockQuoteBP
from the Business Process drop-down list. - Select
stockQuoteInput.xsd
from the Input Schema drop-down list. - Select
stockQuoteOutput.xsd
from the Output Schema drop-down list. - Select the check box next to
Validate with Input Schema
andValidate with Output Schema
.
- Select
- Create a Web service,
StockQuoteWebservice
, in Sterling B2B Integrator that includes this business process.- Clear the
Use Legacy Settings
check box. - Assign
StockQuoteBP
as the business process. - Use default settings in all other pages.
- Clear the
- Generate the WSDL for the Web service as shown in the following
example:
<?xml version=”1.0” encoding=”UTF-8”?> <wsdl:definitions name=”StockQuoteWebservice” targetNamespace=”http://www.sterlingcommerce.com/mesa” xmlns:mesa=”http://www.sterlingcommerce.com/mesa” xmlns:mesa_xsd=”http://www.sterlingcommerce.com/mesa” xmlns:mime=”http://schemas.ditasoap.org/wsdl/mime/” xmlns:soap=”http://schemas.ditasoap.org/wsdl/soap/” xmlns:tns0=”http://www.webservice.stockquotein” xmlns:tns1=”http://www.webservice.stockquoteout” xmlns:wsdl=”http://schemas.ditasoap.org/wsdl/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”> <wsdl:types> <xs:schema attributeFormDefault=”unqualified” elementFormDefault=”qualified” targetNamespace=”http://www.sterlingcommerce.com/mesa” xmlns=”http://www.sterlingcommerce.com/mesa” xmlns:tns=”http://www.sterlingcommerce.com/mesa” xmlns:xs=”http://www.w3.org/2001/XMLSchema”> <xs:complexType name=”Binary”> <xs:simpleContent> <xs:extension base=”xs:base64Binary”> <xs:attribute name=”href” type=”xs:anyURI”/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:element name=”attachment” type=”tns:Binary”/> <xs:element name=”inlineAttachment” type=”xs:base64Binary”/> <xs:complexType name=”ProcessData”> <xs:sequence> <xs:any/> </xs:sequence> </xs:complexType> <xs:element name=”mesaFault” type=”tns:MESAFault”/> <xs:complexType name=”MESAFault”> <xs:sequence> <xs:element name=”code”/> <xs:element name=”message”/> <xs:element name=”statusReport”/> </xs:sequence> </xs:complexType> <xs:element name=”processData” type=”tns:ProcessData”/> <xs:element name=”documents”> <xs:complexType> <xs:sequence> <xs:element maxOccurs=”unbounded” ref=”tns:attachment”/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> <xs:schema elementFormDefault=”qualified” targetNamespace=”http://www.webservice.stockquotein” xmlns=”http://www.webservice.stockquotein” xmlns:tns0=”http://www.webservice.stockquotein” xmlns:xs=”http://www.w3.org/2001/XMLSchema”> <xs:element name=”GetQuote”> <xs:complexType> <xs:sequence> <xs:element maxOccurs=”1” minOccurs=”0” name=”symbol” type= ”xs:string”/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> <xs:schema elementFormDefault=”qualified” targetNamespace=”http://www.webservice.stockquoteout” xmlns=”http://www.webservice.stockquoteout” xmlns:tns1=”http://www.webservice.stockquoteout” xmlns:xs=”http://www.w3.org/2001/XMLSchema”> <xs:element name=”GetQuoteResponse”> <xs:complexType> <xs:sequence> <xs:element maxOccurs=”1” minOccurs=”0” name=”GetQuoteResult” type=”xs:string”/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name=”MESAResponse”> <wsdl:part element=”mesa:processData” name=”parameters”/> </wsdl:message> <wsdl:message name=”StockQuoteBP”> <wsdl:part element=”tns0:GetQuote” name=”parameters”/> </wsdl:message> <wsdl:message name=”MESAFault”> <wsdl:part element=”mesa:mesaFault” name=”parameters”/> </wsdl:message> <wsdl:message name=”GISGeneric”> <wsdl:part element=”mesa:processData” name=”parameters”/> </wsdl:message> <wsdl:message name=”StockQuoteBPOutput”> <wsdl:part element=”tns1:GetQuoteResponse” name=”parameters”/> </wsdl:message> <wsdl:portType name=”GISPortType”> <wsdl:operation name=”executeStockQuoteBP”> <wsdl:input message=”mesa:StockQuoteBP”/> <wsdl:output message=”mesa:StockQuoteBPOutput”/> </wsdl:operation> </wsdl:portType> <wsdl:binding name=”GISBinding” type=”mesa:GISPortType”> <soap:binding style=”document” transport=”http://schemas.ditasoap.org/soap/http”/> <wsdl:operation name=”executeStockQuoteBP”> <soap:operation soapAction=”sii:StockQuoteBP” style=”document”/> <wsdl:input> <soap:body parts=”parameters” use=”literal”/> </wsdl:input> <wsdl:output> <soap:body use=”literal”/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name=”StockQuoteWebservice”> <wsdl:port binding=”mesa:GISBinding” name=”GISPort”> <soap:address location=”http://10.30.2.249:46940/soap-new?service= StockQuoteWebservice”/> </wsdl:port> </wsdl:service> </wsdl:definitions>
- Check in the WSDL and enable it for business processes.
- Export the WSDL to a location accessible to the consumer, or send an XML file.