Add arguments and a return type to an inbound web service to utilize an RPC-style web service; otherwise, for a document-style web service, which passes and returns a W3C XML Document, specify no arguments or return type. The interface with an XML Document argument and return type set is automatically generated for each operation, as illustrated in Adding Arguments and Return Types to Inbound Web Service Operations.
When adding arguments and return types to RPC-style inbound web service operations this is done in the same manner as with process and facade classes as documented in Working with the Cram Model in Rational Software Architect.
public interface DOWSXMLDocTestBPO { public org.w3c.dom.Document processDocument (org.w3c.dom.Document xmlMessage) throws curam.util.exception.AppException, curam.util.exception.InformationalException; public org.w3c.dom.Document echoDocument (org.w3c.dom.Document xmlMessage) throws curam.util.exception.AppException, curam.util.exception.InformationalException; }
To specify a schema in the Curam properties tab for the WebService class (where you've set property XML_Document):
Schema files must be stored in the appropriate build structure folder: <SERVER_DIR>/components/custom/webservices/. Each component may have its own set of web services, so in the above path custom should be the name of the component for which the web service is being deployed. For example:
<SERVER_DIR>/components/testComponent/webservices/sampleSchema.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ws.curam/FinancialUpdateWS" xmlns:cns="http://ws.curam/FinancialUpdateWS" elementFormDefault="qualified"> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element minOccurs="1" maxOccurs="1" ref="cns:msgT_financialUpdate"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="msgT_financialUpdate"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" ref="cns:row"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="row"> <xs:complexType> <xs:sequence> <xs:element minOccurs="1" maxOccurs="1" ref="cns:EXTERNALILIID"/> <xs:element minOccurs="1" maxOccurs="1" ref="cns:DOCUMENTSTATUSCODE"/> <xs:element minOccurs="1" maxOccurs="1" ref="cns:OPENAMOUNT"/> <xs:element minOccurs="0" maxOccurs="1" ref="cns:EXTERNALINVOICEID"/> <xs:element minOccurs="0" maxOccurs="1" ref="cns:EXTERNALPAYMENTLIST"/> <xs:element minOccurs="0" maxOccurs="1" ref="cns:LOCKLIST"/> <xs:element minOccurs="1" maxOccurs="1" ref="cns:TIMESTAMP"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="EXTERNALILIID" type="xs:integer"/> <xs:element name="DOCUMENTSTATUSCODE" type="xs:string"/> <xs:element name="OPENAMOUNT" type="xs:double"/> <xs:element name="EXTERNALINVOICEID" type="xs:integer"/> <xs:element name="EXTERNALPAYMENTLIST"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="unbounded" ref="cns:EXTERNALPAYMENTID"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="EXTERNALPAYMENTID" type="xs:integer"/> <xs:element name="LOCKLIST"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="unbounded" ref="cns:LOCKREASON"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="LOCKREASON" type="xs:string"/> <xs:element name="TIMESTAMP" type="xs:integer"/> </xs:schema>
An example of an XML document that conforms to the schema in Figure 2:
<msgT_financialUpdate xmlns="http://ws.curam/FinancialUpdateWS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ws.curam/FinancialUpdateWS FinancialUpdate.xsd"> <row> <EXTERNALILIID>1</EXTERNALILIID> <DOCUMENTSTATUSCODE>C04</DOCUMENTSTATUSCODE> <OPENAMOUNT>0</OPENAMOUNT> <EXTERNALINVOICEID>000000000000</EXTERNALINVOICEID> <EXTERNALPAYMENTLIST> <EXTERNALPAYMENTID>233</EXTERNALPAYMENTID> </EXTERNALPAYMENTLIST> <TIMESTAMP>20080229094755</TIMESTAMP> </row> <row> <EXTERNALILIID>2</EXTERNALILIID> <DOCUMENTSTATUSCODE>C05</DOCUMENTSTATUSCODE> <OPENAMOUNT>0</OPENAMOUNT> <EXTERNALINVOICEID>000000000000</EXTERNALINVOICEID> <EXTERNALPAYMENTLIST> <EXTERNALPAYMENTID>3455</EXTERNALPAYMENTID> </EXTERNALPAYMENTLIST> <TIMESTAMP>20080229094744</TIMESTAMP> </row> </msgT_financialUpdate>
<?xml version="1.0"?> <!-- root element, namespace and form definitions --> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bt="businesstypesURI" xmlns:dt="determinationURI" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="determinationURI"> <!-- import the businesstypes schema --> <xs:import namespace="businesstypesURI" schemaLocation="businesstypes.xsd" /> <...> </xs:schema>
The schema " businesstypes.xsd ", which is imported in " Determination.xsd " above:
<?xml version="1.0" encoding="UTF-8"?> <!-- The contents of this file are fixed, by the SDEJ. It could easily be shipped with the SDEJ --> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="curamtypesURI"> <xs:simpleType name="date"> <xs:annotation> <xs:documentation>Cram builtin type date. </xs:documentation> </xs:annotation> <xs:restriction base="xs:date"/> </xs:simpleType> <...> </xs:schema>
When calling a web service having a validation schema which imports another schema as shown in the example above an error " src-resolve: Cannot resolve the name <...> to a type definition component " will be thrown.
There are two workarounds to solve this issue:
<?xml version="1.0"?> <!-- root element, namespace and form definitions --> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dt="determinationURI" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="determinationURI"> <!-- import the businesstypes schema --> <!-- BEGIN businesstypes.xsd --> <xs:simpleType name="date"> <xs:annotation> <xs:documentation> Curam builtin type date. </xs:documentation> </xs:annotation> <xs:restriction base="xs:date"/> </xs:simpleType> <...> <!-- END businesstypes.xsd --> <...> </xs:schema>
Adding Arguments and Return Types to Inbound Web Service Operations illustrates a skeleton implementation. This simple example shows an implementation of class DOWSXMLDocTestBPO that consists of two operations, echoDocument and processDocument, which are exposed as two web services that echo and process the request SOAP body XML message respectively.
package webservice.impl; import curam.util.exception.AppException; import curam.util.exception.InformationalException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; public class DOWSXMLDocTestBPO extends webservice.base.DOWSXMLDocTestBPO { /** * Sample method for echoing an XML message. * * @param xmlMessage The request message * @return the response message. * * @throws AppException * @throws InformationalException */ public Document echoDocument (final Document xmlMessage) throws AppException, InformationalException { Document responseMessage = null; try { responseMessage = xmlMessage; } catch (Exception ex) { ..... } return responseMessage; } /** * Sample method for processing an XML message. * * @param xmlMessage The request message * @return the response message. * * @throws AppException * @throws InformationalException */ public Document processDocument (final Document xmlMessage) throws AppException, InformationalException { Document responseMessage = null; try { responseMessage = doXMLDocumentProcessing(xmlMessage); } catch (Exception ex) { .... } return responseMessage; } /** * Do processing of XML and return an XML message. * @param bodyXML The message to be processed. * @return The processed message. */ private Document doXMLDocumentProcessing (final Document bodyXML) { final Document doc = bodyXML; /** business logic implemented here... **/ return doc; } }