SynAPI
Synergetic Custom Web Service API - How to create custom web service API
Overview
This document provides information on how to create custom web service APIs in order to communicate with Synergetic Databases.
SynAPI works with SQL Server Stored Procedures- users can create custom stored procedures or utilise existing Synergetic database stored procedures.
SynAPI provides a capability to track version numbers for like web service methods to cater for different parameters and outputs.
Web Service Methods must be reviewed and authorised by Synergetic prior to publishing live to internal users or third party vendors. This is so that inadvertent mistakes can be avoided and best practices observed.
Requirements
Following Synergetic products are required to create Web Service Methods.
- SynAPI – v01.00+ must be using SSL
- Synergetic v65+
- SynWeb 05.00+
User will also need internal Synergetic SQL Server access to create / modify user stored procedures. Please note all web service related stored procedures will be executed under SQL Server Application Role 'SynWebService' and not under user account directly.
Configuring Synergetic.xml file used by SynWeb and SynAPI
The following web service settings are added to the Synergetic.xml file. To modify these settings in Synergetic.xml file please go to SynWeb installation directory -> bin folder -> Run Synergetic.Application.SynWebCreateConfig.exe. Please note if you change settings other than those listed this may result into SynWeb errors.
Setting Name | Description | Default Value |
---|---|---|
| User account used by web services |
|
| Password for web service user account. Encrypted by SynWebCreateConfig.exe | |
| XML Dataset top level node name. Can have multiple Data table xml results |
|
| XML Datatable top level node name. Data tables appear under dataset XML nodes. |
|
| Ignore XML schema information from returned output |
|
| Synergetic authorisation web service URL. Provided by Synergetic | |
| Vendor token issued by Synergetic to connect to Synergetic authorisation web service | |
| Vendor password issued by Synergetic to connect to Synergetic authorisation web service |
Web Service Method Planning
Before you create new web service method, document your requirements:
- Requirement - what's the purpose of this web service method?
- E.g. Get Synergetic community details – name as UGetCommunityDetails
(Name must be prefixed with capital 'U' to distinct user/client web service methods and Synergetic standard web service methods)
- Inputs - what input parameters will be passed when calling?
- E.g. ID, Surname, Given1
- Outputs - what outputs are required?
E.g. ID, Title, Surname, Given1, Preferred, Email Address, Mobile Phone number and Address
You will need to have a least one output value. If not a data set, this may be a unique identifier, a success/fail message, or otherwise something benign to that effect.
- Stored Procedure – can I use existing Synergetic stored procedure or do I need to create my own stored procedure based on custom / existing tables?
- E.g. For above scenario I can use existing stored procedure 'spsCommunitySimple' which accept @CommunityName parameter and I can pass id, surname, given1 or barcode value to search for matching community records.
- Permissions – Finally you will need to grant EXECUTE permission on selected stored procedure SQL Server Application Role 'Synergetic_SynAPI_dbo_ReservedDBRole'
- GRANT EXECUTE ON uspuStaffAddressiChrisHome to Synergetic_SynAPI_dbo_ReservedDBRole
How to create new Web Service Method?
Security Requirements: SYS -> CustomWebServiceMaint
There are three steps involved in creating Web Service Method; all these steps can be done through SynWeb interface.
- Create Web Service Method
- Send Authorisation request to Synergetic
- Test Web Service Method
Create Web Service Method
The following provides details on how to create new web service method which can be accessed by third party vendors. In below documentation we will consider example we used during web service method planning from above details
- Go to SynWeb -> System -> Web Service Maintenance and click 'Create New Web Service' button to start new web service create wizard
- Enter below Web Service details and click Next button
- Method Name (must start with capital 'U')
- Method summary – purpose of this web service for documentation purpose
- Active Flag – active by default, can be marked as inactive if not required in future
- Enter Web Service version details and click Next button
- Version No – by default 1, you can create multiple version for same web service method if you change input / output parameters and you would like to have multiple version of same method
- Database Name – Synergetic database you accessing information from
- Stored Procedure Name – You will see list of stored procedures from the selected database where the 'SynWebService' application role has execute permission to. If you don't see your stored procedure in the dropdown list then possibly you haven't granted execute permission to 'SynWebService' application role or other possibility your stored procedure is created in wrong database.
- Select Web Service parameters and click Next button
- Checkboxes – Check the checkbox for parameter you required. You might see many extra parameters used by Synergetic but you can ignore those and select one relevant to your requirements
- Default Value – You can pass default value for parameter, this value will be applied if web service calling user don't pass parameter.
- Description – Parameter description for documentation purpose. E.g. CommunityName – Enter community ID, Given1 or Surname
- Read Only – You can mark parameter as read only if you don't want end user to pass value externally, generally this is useful when you specify default value and don't want end user to pass value.
- Select Web Service XML Output columns and click Next button
- Checkboxes – Check the checkbox for columns you required. You might see many extra columns but you can ignore those and select one relevant to your requirements
- Checkboxes – Check the checkbox for columns you required. You might see many extra columns but you can ignore those and select one relevant to your requirements
- Review Web Service summary and click Finish button to complete creation process. This will redirect back to Web Service Maintenance page.
- You can edit web service method version details by clicking Edit icon or you can delete by clicking Delete icon from the grid
Send Authorisation request to Synergetic
Once Web Service Method is created then you will need to send it to Synergetic for authorisation purpose. Synergetic will record all web service related data for licensing purpose and will review stored procedure you are using. During authorisation process Synergetic might advise you to change stored procedure if any issues found with code or if SQL best practice is not followed.
For authorisation process Synergetic expose web services APIs, this APIs are already integrated with SynWeb and all process managed seamlessly via interface. Follow below steps to request authorisation from Synergetic.
- Click 'X' button from Web Service Versions grid -> Authorised column as circled in below screen shot. After you sent authorisation request, when you mouse over the 'X' button tooltip will provide information about when you sent authorisation request last time.
Please note if you change any details, you will need to resend authorisation request to Synergetic.
- Wait for Synergetic to approve your request. Once your request is approved, you will receive an email from Synergetic about authorisation status changed. After your request is approved you can click 'Synchronise Authorisation' button to synchronise authorisation details. If not authorised then follow instruction in email about next step. After authorisation details are synchronised with Synergetic icon will changed green ticked
- If you change any details, your web service will be suspended and you will need to resend an authorisation request to Synergetic. Once you resend authorisation request to Synergetic, wait for approval email as per step 2. Warning icon will appear under Authorisation column until you synchronise authorisation details from Synergetic after approval.
Test Web Service Method
Once Web Service is authorised by Synergetic, third party vendor can call your web service. Below information will require when calling web services, it's recorded in SQL table called 'SynergeticTrustedVendors'. Synergetic will provide this information and if multiple third party vendors will be using your web services then please ask Synergetic to enter records for all vendors.
- Web Service Address. E.g. https://synapi.schools.edu.au/SynergeticWcfService.svc
- Vendor Token GUID
- Vendor Password
You can test web service using Web Service Testing tool provided by Synergetic.
- Go to SynWeb -> System -> Test Web Service
- Fill details requested in above points a, b & c
- Select Web Service Method Name and Version No to test
- Fill out value for all Parameters and then click Execute button to get web service response
Developers Guide – API Documentation
Below documentation provides information required by developers who want to call SynAPI to integrate third party products with Synergetic.
Web Service Request and Response parameters
Below Input and Output parameters are available by Synergetic Web Service API. This information will be required by any third party vendor who calls Synergetic web services.
WebServiceInputParameter - Complex type, below values are required
Parameter Name | Data Type | Description |
---|---|---|
VendorTokenGuid | String | Vendor Token to connect to Synergetic web service |
Vendor Password | String | Vendor Password to connect to Synergetic Web Service |
WebServiceMethodName | String | Web Service Method you are calling. E.g. UGetCommunityDetails |
WebServiceMethodVersionNo | Integer | Web Service Method Version you are calling, default value 1 if not provided |
ParameterList | Dictionary<String, Object> | Web Service Method parameters Dictionary |
WebServiceOutputParameter
Parameter Name | Data Type | Description |
ErrorMessage | String | Error details if web service call isn't successful |
XMLOutput | String | Output in XML string format. XML format will contain schema information if 'WebServiceIgnoreXMLSchemaFlag' is set to 0 in Synergetic.xml file. Result top level dataset node and child data table node can be renamed using below settings in Synergetic.xml file 'WebServiceDataSetName' and 'WebServiceDataTableName' |
Available Web Service Methods
Synergetic generate XML level documentation for all custom Web Service Methods created by school. You can use third party custom tools to generate help document in .html or .chm format from xml file.
- Go to SynWeb -> System ->Web Service Maintenance web page and click 'Download Help Document' button.
- Save SynAPIHelp.xml file.
Testing the SynAPI Externally
A good technique to completely test the SynAPI is to use a third party API calling tool (such as SoapUI) and run it on a laptop or a machine that is NOT on the school's network.
Here is an example below of a SoapUI call to a school's SynaPI Web service with some input parameters - and the resultant output from the API
and here is a copy of the soapui project (that can be imported into SoapUI). Please note this SoaupUI won't work and is only for informative/dev assistance purposes (because it refers to a fake school url and does not have correct VendorGuids and VendorPaswords in it):
In soap ui - you can create project:
Choose add WSDL:
And then enter your externally accessible URL here:
This will import all available endpoints
An example payload - please pay attention on the case sensitivity of <a:Key>
param | value |
---|---|
_.wcfsvcurl | SynAPI url |
_.VendorPassword | Trusted Vendor Password (unencrypted) |
_.VendorTokenGuid | Trusted Vendor GUID |
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"> <s:Header> <a:Action s:mustUnderstand="1">https://synapi.synergetic.net.au/66-80-01/ISynergeticWcfService/RunWebServiceMethod</a:Action> <a:MessageID>urn:uuid:5535f22c-47bd-4de1-8e5f-da07893d02c8</a:MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <a:To s:mustUnderstand="1">https://{{ _.wcfsvcurl }}</a:To> </s:Header> <s:Body> <RunWebServiceMethod xmlns="https://synapi.synergetic.net.au/66-80-01"> <inputParameter xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <ParameterList xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <a:KeyValueOfstringanyType> <a:Key>Surname</a:Key> <a:Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">test</a:Value> </a:KeyValueOfstringanyType> </ParameterList> <IncludeOutputXMLSchemaFlag>false</IncludeOutputXMLSchemaFlag> <ForceTransactionRollbackFlag>false</ForceTransactionRollbackFlag> <VendorPassword>{{ _.VendorPassword }}</VendorPassword> <VendorTokenGuid>{{ _.VendorTokenGuid }}</VendorTokenGuid> <WebServiceMethodName>Ujames</WebServiceMethodName> <WebServiceMethodVersionNo>1</WebServiceMethodVersionNo> </inputParameter> </RunWebServiceMethod> </s:Body> </s:Envelope>
Please note some characters may need to escaped (XML wise):
" "
' '
< <
> >
& &