Implementing a Web Service

The Web services connector lets you import data from external Web services. To get data from an external Web service, you must implement the IDataImporter interface and create a new Web service.
Add “IDataImporterTemplate.wsdl” as a service reference to get interface definition from http://<<AppServerHostName>>/CCS_Web/ IDataImporterTemplate.wsdl.
For example, a code snippet from the service interface generated using the IDataImporterTemplate.wsdl:
[ServiceContract] public interface IDataImporter { [OperationContract] string GetParameterInformation(); [OperationContract] string GetSchema(); [OperationContract] string GetDataPage(string parameterXML, string PageInformation); [OperationContract] void TestConnection(); }
You must implement the following four methods provided by the IDataImporter interface. These methods transform data coming from external data services into .xml format. CCS uses these methods to fetch data from the external Web service:
  • GetParameterInformation:
    Implement this method to get information about the parameters to be passed to the Web service. You can use the parameters to scope or filter the information received from external data systems.
    • Syntax:
      string GetParameterInformation()
    • Input Parameters:
      This method does not require any input parameters.
    • Return Values:
      This method returns the parameter xml which is used to scope and filter external data. The parameters in the xml are displayed on the CCS user interface where you can pass values to those parameters. You have to implement the GetDataPage method to use those values to get filtered data.
      Following is a sample xsd for the return value xml format for GetParameterInformation.
      <?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.symantec.com/schemas/ 2011/WebServiceConnector/ParametersSchema"> <xs:element name="parameters"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="parameter"> <xs:complexType> <xs:sequence> <xs:element name="selectionlist" minOccurs="0" > <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="value" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="valuelist" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="value" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="name" type="xs:string" use="required"/> <xs:attribute name="description" type="xs:string" /> <xs:attribute name="dataType" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Integer"/> <xs:enumeration value="String"/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="isMandatory" type="xs:boolean" /> <xs:attribute name="isMultiValued" type="xs:boolean" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
      Following is a sample xml generated using the above xsd.
      <?xml version="1.0" encoding="utf-8"?> <parameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.symantec.com/schemas/ 2011/WebServiceConnector/ParametersSchema"> <parameter name="Status" description="This is state of vulnerability reported at an instance of time" dataType="String" isMandatory="false" isMultiValued="true"> <selectionlist> <value>Vulanrable</value> <value>Not Vulnerable</value> <value>Unknown</value> </selectionlist> <valuelist> <value>Vulanrable</value> <value>Not Vulnerable</value> </valuelist> </parameter> </parameters>
  • GetSchema:
    Implement this method to get the data schema which contains fields and data types for external data. This method returns the schema in .xml format.
    • Syntax:
      string GetSchema()
    • Input Parameters:
      This method does not require any input parameters.
    • Return Values:
      This method returns the schema of the external data which is used for creating new data schema through the CCS user interface.
      Following is a sample xsd for the return value xml format for GetSchema.
      <?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.symantec.com/schemas/ 2011/WebServiceConnector/SchemaXMLSchema"> <xs:element name="schemaXML"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="field"> <xs:complexType> <xs:attribute name="name" type="xs:string" use="required" /> <xs:attribute name="dataType" use="required" > <xsd:simpleType> <xsd:restriction base="xs:string"> <xsd:enumeration value="Boolean"/> <xsd:enumeration value="DateTime"/> <xsd:enumeration value="Decimal"/> <xsd:enumeration value="Guid"/> <xsd:enumeration value="Integer"/> <xsd:enumeration value="String"/> </xsd:restriction> </xsd:simpleType> </xs:attribute> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
      Following is a sample xml generated using the above xsd.
      <?xml version="1.0" encoding="utf-8" ?> <schemaXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.symantec.com/schemas/ 2011/WebServiceConnector/SchemaXMLSchema"> <field name="InsidentId" dataType="Integer" /> <field name="InsidentGuid" dataType="Guid" /> <field name="OwnerId" dataType="Integer" /> <field name="MachineName" dataType="String" /> <field name="IP" dataType="String" /> <field name="OS" dataType="String" /> <field name="Department" dataType="String" /> <field name="CreatedDate" dataType="DateTime" /> <field name="CreatedBy" dataType="Integer" /> <field name="LastModifiedDate" dataType="DateTime" /> <field name="LastModifiedBy" dataType="Integer" /> <field name="CheckId" dataType="String" /> <field name="CheckName" dataType="String" /> <field name="Status" dataType="String" /> </schemaXML>
  • GetDataPage:
    Implement this method to get data from external application.
    • Description:
    • Syntax:
      string GetDataPage(string parameterXML, string PageInformation)
    • Input Parameters:
      The following table describes the input parameters that the API requires:
      parameterXML
      Parameter xml is used to scope and filter the external data. The parameter values that you provide on the CCS user interface are passed as a part of the parameter xml. You must implement this method to use those values to get filtered data.
      If you have defined the evaluation date field for the EDI system then the parameter xml also contains the following parameter:
      CCS_MaxEvaluationDate
      This parameter contains the latest evaluation date up to the last successful import of records.
      If the evaluation date field is not defined or if latest evaluation date is not saved for the corresponding data connection, the evaluation date parameter is not added to the parameter xml.
      The evaluation date value is in UTC. The following format is used to specify the date-time value: ('yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff'Z)
      You can use this parameter to filter out the data that has the evaluation date that is prior to the CCS_MaxEvaluationDate value. Hence, only the most recent data is imported into CCS.
      PageInformation
      This information is used to retrieve the current data page of the data schema.
      Following is a sample xml containing the CCS_MaxEvaluationDate parameter in the parameterXML for GetDataPage:
      • <?xml version="1.0" encoding="utf-8"?> <parameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.symantec.com/schemas/ 2011/WebServiceConnector/ParametersSchema"> <parameter name="Status" description="This is state of vulnerability reported at an instance of time" dataType="String" isMandatory="false" isMultiValued="true"> <selectionlist> <value> Vulnerable </value> <value>Not Vulnerable</value> <value>Unknown</value> </selectionlist> <valuelist> <value>Vulanrable</value> <value>Not Vulnerable</value> </valuelist> </parameter> <parameter name="CCS_MaxEvaluationDate" description="Maximum evaluation date up to the last successful import" dataType="String" isMandatory="false" isMultiValued="false"> <valuelist> <value>2013-09-05T16:31:38.4900000Z</value> </valuelist> </parameter> </parameters>
    • Return Values:
      This method gets the data from the external application. The data is fetched in pages. You must implement the method in such a way that external data is divided into pages and the method returns a single page at time. The method must return the data in xml format.
      Following is a sample xsd for the return value xml format for GetDataPage.
      <?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.symantec.com/schemas/ 2011/WebServiceConnector/DataSetSchema"> <xs:element name="dataset"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="row"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="field"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="name" type="xs:string" use="required" /> <xs:attribute name="dataType" use="required" > <xsd:simpleType> <xsd:restriction base="xs:string"> <xsd:enumeration value="Boolean"/> <xsd:enumeration value="DateTime"/> <xsd:enumeration value="Decimal"/> <xsd:enumeration value="Guid"/> <xsd:enumeration value="Integer"/> <xsd:enumeration value="String"/> </xsd:restriction> </xsd:simpleType> </xs:attribute> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="currentPage" type="xs:string" use="required" /> <xs:attribute name="nextPage" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:schema>
      Following is a sample xml generated using the above xsd.
      <?xml version="1.0" encoding="utf-8"?> <dataset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" currentPage="1" nextPage="" xmlns="http://www.symantec.com/schemas/ 2011/WebServiceConnector/DataSetSchema"> <row> <field name="InsidentId" dataType="Integer">1</field> <field name="InsidentGuid" dataType="Guid">766ce3a5-e720-4926-91a5-213753b09ee5</field> <field name="OwnerId" dataType="Integer">1</field> <field name="MachineName" dataType="String">Symantec2</field> <field name="IP" dataType="String">111.111.111.111</field> <field name="OS" dataType="String">Win2K8</field> <field name="Department" dataType="String">Account</field> <field name="CreatedDate" dataType="DateTime">2011-03-23T16:57:55.000Z</field> <field name="CreatedBy" dataType="Integer">1</field> <field name="LastModifiedDate" dataType="DateTime">2011-03-23T18:07:37.000Z</field> <field name="LastModifiedBy" dataType="Integer">1</field> <field name="CheckId" dataType="String">Check-1</field> <field name="CheckName" dataType="String">SecurityPatchUpdate</field> <field name="Status" dataType="String">Pass</field> </row> <row> <field name="InsidentId" dataType="Integer">2</field> <field name="InsidentGuid" dataType="Guid">766ce3a5-e720-4926-91a5-213753b09ee6</field> <field name="OwnerId" dataType="Integer">2</field> <field name="MachineName" dataType="String">score</field> <field name="IP" dataType="String">111.111.111.112</field> <field name="OS" dataType="String">Win2K8-R2</field> <field name="Department" dataType="String">Store</field> <field name="CreatedDate" dataType="DateTime">2011-03-23T18:13:07.000Z</field> <field name="CreatedBy" dataType="Integer">2</field> <field name="LastModifiedDate" dataType="DateTime">2011-03-23T19:52:37.000Z</field> <field name="LastModifiedBy" dataType="Integer">2</field> <field name="CheckId" dataType="String">Check-3</field> <field name="CheckName" dataType="String">IEPatchUpdate</field> <field name="Status" dataType="String">Fail</field> </row> </dataset>
  • TestConnection:
    Implement this method to test the connection to the Web service. This method does not require any code definition.
    • Syntax:
      void TestConnection()
    • Input Parameters
      This method does not require any input parameters.
    • Return Values:
      This method does not return any value.