VPVI10 Vantagepoint Xtend Web Services Alexander Ng Deltek
VPVI-10: Vantagepoint Xtend Web Services Alexander Ng, Deltek
Agenda CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 2
Agenda 1. What is a Web Service? 2. What Vantagepoint applications can be Xtended via Web Service? 3. Why Have A Vantagepoint Xtend Web Service? 4. Building Your First Web Service 5. Publishing The Web Service CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 3
Agenda 6. How To Make Vantagepoint Call The Web Service? 7. What Is Passed Into The Web Service? 8. How To Parse The XML? 9. What Should The Web Service Return? 10. Questions & Contact CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 4
1 What is a Web Service? CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 5
What is a Web Service? » Application programming interface (API) which can be accessed over a network and executed on a remote system hosting the requested services. » Prominent web services are Google Maps API, Weather Channel API, Face. Book API, Twitter API, etc. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 6
What is a Web Service? » In the context of Vantagepoint, web services are used to extend the business logic of the Vantagepoint application without having to customize Vantagepoint’s standard core files. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 7
2 What Vantagepoint applications can be Xtended via a Web Service? CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 8
What Vantagepoint applications can be Xtended via a Web Service? » Vantagepoint supports web services extension for Expense Reports, Item Requests, Purchase Orders, Purchase Requisitions, Request for Price Quotes, Timesheets, Transaction Entry, and Transaction Posting. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 9
What Vantagepoint applications can be Xtended via a Web Service? » Vantagepoint’s Web Services Module is located under ‘SettingsWorkflowWeb Services’. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 10
3 Why Have A Vantagepoint Xtend Web Service? CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 11
Why Have A Vantagepoint Xtend Web Service? » The main purpose of a Vantagepoint Xtend Web Service is to establish a set of custom validation rules before the application being extended is allowed to be saved. Example Timesheet Rules: » Employee must work 8 regular hours before entering overtime. » An Employee cannot charge overtime until 40 regular hours have been worked. » An Employee cannot charge time to both a Vacation project and a Regular project on the same day. » Messages are returned as errors or warnings, and those messages are displayed within the Application. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 12
Why Have A Vantagepoint Xtend Web Service? » All of the custom data validation rules can be encapsulated in one single web service. » You can do some data update whether within Vantagepoint or outside of Vantagepoint when the application being extended is submitted. For example, maybe you want to update some outside database you have to track a timesheet audit when the timesheet is saved. » You can send some emails out when the application being extended is submitted. For example, maybe you want to email the Requisitioner’s supervisor when a Purchase Requisition is submitted. » The web service can be used to launch other events and services that are outside and independent of Vantagepoint. For example, it could be possible to call another web service and pass the Vantagepoint Timesheet data to it. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 13
4 Building Your First Web Service CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 14
Building Your First Web Service » Using Visual Studio 2017 click on ‘File / New Project…’ CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 15
Building Your First Web Service » Under your preferred programming language select WCF / WCF Service Application » Make sure to target the correct. NET Framework version for the product you are writing the Web Service for: » Vision 7. 6: . NET Framework 4. 5. 2 » Vantagepoint 1. x: . NET Framework 4. 6. 2 » Vantagepoint 2. x: . NET Framework 4. 7. 2 CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 16
Building Your First Web Service CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 17
Building Your First Web Service » Give the Project a meaningful name: Web. Services. Extensions » Then click “OK” CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 18
Building Your First Web Service » The newly created project should look as follow: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 19
Building Your First Web Service » Open IService 1. vb and add the following line above the “IService 1” Public Interface: <Xml. Serializer. Format(Use: =Operation. Format. Use. Encoded, Style: =Operation. Format. Style. Rpc)> CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 20
Building Your First Web Service » Comment out (or delete) the sample code headers and add the header(s) for your own code CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 21
Building Your First Web Service » Open Service 1. svc (Service 1. svc. vb) and comment out (or delete) the sample code that implements Operation. Contracts from IService 1. vb CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 22
Building Your First Web Service » Add in your own code and save. Note: for Visual Basic you need to explicitly specify which header in IService 1. vb your are implementing. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 23
Building Your First Web Service » Once your code is in place, build your solution to compile the project (Build/Build Solution) CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 24
Building Your First Web Service » Configure the WCF Web Service so that it is SOAP compatible. Right click on Web. Config and select “Edit WCF Configuration” CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 25
Building Your First Web Service » Expand/drill down Advanced/Service Behaviors to the “Empty Name” service behavior and give it a name CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 26
Building Your First Web Service » Expand Service. Behavior (or whatever name was given to the Empty Name service behavior) and check that » service. Metadata/Http. Get. Enabled = True » service. Debug/include. Exception. Detail. In. Faults = False CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 27
Building Your First Web Service » Create a New Service under Services (Services/Create a New Service…) CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 28
Building Your First Web Service » Browse for the compiled DLL (normally under the bin folder) CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 29
Building Your First Web Service » Open it down to the class level (. Service 1) » Then click next CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 30
Building Your First Web Service » Specify the contract for the service (it is usually the name of the interface that you define the code) then click next CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 31
Building Your First Web Service » Select HTTP as the communication mode and click next CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 32
Building Your First Web Service » Select “Basic Web Services interoperability” as the method of interoperability and click next CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 33
Building Your First Web Service » Blank out the address for the endpoint and click next » You will get a warning that an empty address in config will require you to define the address in code. Click Yes to continue CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 34
Building Your First Web Service » Click Finish to create the service configuration CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 35
Building Your First Web Service » Select the service configuration that was just created and attached the service behavior we defined earlier to the Behavior. Configuration property CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 36
Building Your First Web Service » Click on the dialog’s X button (upper right corner) and you will be prompted to save changes. Click on Yes and your Web Service is ready for deployment. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 37
5 Publishing The Web Service CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 38
Publishing The Web Service » Click on ‘Build / Publish Web. Service. Extensions’ (Name of your project): CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 39
Publishing The Web Service » First time publishing, click on ‘Folder’ then the ‘Publish’ button CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 40
Publishing The Web Service » Published folder to IT to configure in IIS to be hosted CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 41
Publishing The Web Service » Notes to keep in mind when configuring IIS/Server to host your Web Service: » The Web Service is added as an Application to a Web Site in IIS CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 42
Publishing The Web Service » Make sure that the Application Pool used by your Web Service Application targets the same version as your Web Service CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 43
Publishing The Web Service » Deltek Cloud does not host Web Services. Setup your own IIS Server or use cloud services like Windows Azure or Amazon Web Services (AWS) to host your Web Service. » If you are on Deltek Cloud, expose Web Service to be accessible externally via HTTPS (SSL) CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 44
6 How To Make Vantagepoint Call The Web Service? CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 45
How To Make Vantagepoint Call The Web Service? » In the Web Application, expand ‘SettingsWorkflow’ then click on “Web Services” CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 46
How To Make Vantagepoint Call The Web Service? » Click “+ Add Web Service” and choose “Timesheets” under Application: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 47
How To Make Vantagepoint Call The Web Service? » Enter a Description and the Web Service Location. The web service location should be followed by ‘? wsdl’. WSDL means Web Service Definition Language. For example: https: //localhost/Web. Services. Extensions/Service 1. svc? wsdl CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 48
How To Make Vantagepoint Call The Web Service? » Once the web service location has been entered then the drop down for ‘Web Service Method’ should be populated with a method: » In case you have multiple methods in your web service, check to make sure it is the desired method you want to call. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 49
How To Make Vantagepoint Call The Web Service? » Verify that the web service is running correctly by opening the ‘Timesheet’ module, entering some data and saving the timesheet. » As the timesheet is being saved, the warning message from the Web Service should be displayed within the Application: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 50
7 What Is Passed Into The Web Service? CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 51
What Is Passed Into The Web Service? » The web service should expect a string as its only parameter: » That string is in XML format. » Thus, it is possible to load that string into an XML Dom and start parsing it. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 52
What Is Passed Into The Web Service? » Code snippet to save XML string into a file: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 53
What Is Passed Into The Web Service? » Using the Timesheet application as example, the following is the XML passed into the function “timesheet. Val” (in. Data): CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 54
What Is Passed Into The Web Service? » The ‘tk. Master’ node contains one child node called ‘ROW’ and that child node contains multiple children: » Each of the ‘ROW’ child nodes represents a column in the Vantagepoint “tk. Master” table. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 55
What Is Passed Into The Web Service? » The tk. Master table is the master table for Timesheets. » The primary keys in the tk. Master table are End. Date and Employee. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 56
What Is Passed Into The Web Service? » The ‘tk. Detail’ node consists of many child nodes. Each child node represents a row in the tk. Detail table: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 57
What Is Passed Into The Web Service? » The tk. Detail table is the table that contains the Timesheets detail data to the tk. Master table. » The primary keys in the tk. Detail are End. Date, Employee, Seq and Trans. Date. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 58
What Is Passed Into The Web Service? » Given a timesheet with two rows of projects, each with two days of data. The XML that is sent to the web service is then built reading the Timesheet from the first row, reading each date in the first row that has value and then continues reading the second row from left to right. The following is the XML string that is then passed to the web service: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 59
What Is Passed Into The Web Service? » If we open up the first tk. Detail node the value of the “WBS 1” node will be 2002005. 00 and the value of the “Trans. Date” node will be “ 09/03/2018”. » If we open up the second tk. Detail node the value of the “WBS 1” node will be 2002005. 00 and the value of the “Trans. Date” node will be “ 09/04/2018”. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 60
What Is Passed Into The Web Service? » If we open up the third tk. Detail node the value of the “WBS 1” node will be 1998001. 00 and the value of the “Trans. Date” node will be “ 09/03/2018”. » If we open up the fourth tk. Detail node the value of the “WBS 1” node will be 1998001. 00 and the value of the “Trans. Date” node will be “ 09/04/2018”. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 61
8 How To Parse The XML? CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 62
How To Parse The XML? » The basic form of the XML string that is passed into the web service is: <ROOT><tk. Master><ROW></tk. Master><tk. Detail></tk. Detail>…</ROOT> » First, use an Xml. Document object to load the XML string: » Next, to read the values from the “tk. Master” node we can use the following code: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 63
How To Parse The XML? » Now we can read the values from the “tk. Master” node as follows: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 64
How To Parse The XML? » To read the values from the “tk. Detail” nodes we can use similar code: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 65
9 What Should The Web Service Return? CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 66
What Should The Web Service Return? » In its most basic form the web service should either return an empty string (“”) or “<errors></errors>” if no errors are found. » Any error that is to be displayed to the user should be enclosed in an error node (<error></error>). CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 67
What Should The Web Service Return? » For example, if an employee cannot enter overtime then the return error string should be as follow: <errors><error>Overtime is not allowed</error></errors> The user will be presented with this error message: » Passing back such an error string will prevent the Timesheet from being saved CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 68
What Should The Web Service Return? » To only display a warning and allow the Timesheet to be saved add the “warning” attribute to the “errors” node. <errors warning='Y'><error>Warning: Less than 40 hours submitted</error></errors> CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 69
What Should The Web Service Return? » If there are two errors then the error string would appear similar to the following: <errors> <error>Overtime is not allowed </error> <error>Special overtime is not allowed</error> </errors> » Each error is wrapped in its own “<error>” node within its parent “<errors>”. CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 70
What Should The Web Service Return? » The error would appear as follows: CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 71
What Should The Web Service Return? » You can also add formatting like a carriage return and/or line feed, dashes, etc. to make your messages more readable: “<errors><error>”&Chr(13)&Chr(10)&“-Overtime is not allowed</error> <error>”&Chr(13)&Chr(10)&“-Special overtime is not allowed</error></errors>” CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 72
What Should The Web Service Return? » It is also possible to have a global error string and add errors to it as they occur. » Thus, instead of having multiple error nodes add one error node that has one or more errors separated by the carriage return and line feed characters. » Main program CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 73
What Should The Web Service Return? » Displayed error message CONFIDENTIAL © Deltek, Inc. All Rights Reserved. 74
Questions & Contact Alexander Ng Alex. Ng@deltek. com Source code on Git. Hub: https: //github. com/Cyber. Ng/Deltek. Insight 2019 Thank you!
- Slides: 76