Hello again everyone, I have had a couple of people including a colleague of mine ask me if I had created a blog about creating a web service based application using the SAP NetWeaver Visual Composer. I mentioned I had created one but hadn't blogged about it yet so here we go.
One of the coolest and most extensible parts of the Visual Composer is the capability to easily link to and consume a web service from within the SAP NetWeaver Visual Composer storyboard. Curious how to do this? Read on...
Ok, Let's Begin!
1/ The first thing we have to do is login to the Visual Composer.
Figure 1.1
2/ Once logged into the Visual Composer create a new model call it Weather Information.
3/ Drag and drop an iView into the Visual Composer work area, name the iView: Weather Application
4/ Now we need to create a web service system to build the Weather application so first select the Define Web service system option from the Tools menu.
5/ Next enter the WSDL, a name and system alias for this new system being created. Name the system WeatherSystem use the same name for the alias as well. The WSDL to use for the Web service URL entry is http://www.webservicex.net/WeatherForecast.asmx?WSDL. Once finished hit the Create button.
6/ Now that we have created our Web Services system, navigate to the Find Data tab and choose the system WeatherSystem. Display all services available for this system.
7/ Drag both of the data services into the Visual Composer work area.
8/ From the input port drag and drop a form into the work area
9/ Give the form the title Enter a City or Zip Code
10/ We are now going to add a field to the form ZIP CODE.
11/ Navigate to the Layout tab, right click on the PlaceName Field and change the label to City. Repeat this step for the ZIPCODE Field and change the label to Zip Code.
12/ Drag & Drop the input of the zipcode specific web service to the output port of the form. Map the ZIPCODE from the form to the ZipCode of the Web Service. The single input form will control both of the web service calls.
13/ Drag a table view out from the top output port of the two web services. Name the table views Weather by City & Weather by Zip Code respectively.
14/ Navigate to the Layout tab of the Visual Composer and stack the input form, the Weather by City and Weather by Zip Code views on top of one another.
15/ Make sure that in our table views we are only displaying the:
16/ Deploy the model
17/ Launch the iView
18/ View the Results
We have now completed the beginner portion of the exercise... For the advanced portion, which utilizes more features within the Visual Composer read on!
19/ Now we are going to modify our existing application and make it a lot more user friendly. Re-open the model we have created thus far.
20/ The first thing we will do is enforce that the user entry screen is populated correctly by using guard conditions. We only want our users to populate only the ZIP code or the city not both. So we need to click on the submit connector to the web service Getweatherbyplacename.
21/ Open the guard condition by double clicking on the fx in the right hand corner of the input field.
22/ The submit event should be invoked when only the placeName is populated and not the zip code.
Enter the following expression into the Guard Condition:
23/ We now have to set up the guard conditions for the other web service. Click on the submit link to the Getweatherbyzipcode web service and open the guard condition.
Enter the following expression into the Guard Condition:
24/ If only one of the Web services is invoked either the Getweatherbyplacename or Getweatherbyzipcode logic would dictate that we only want to see the resulting output of the web service we invoked. To make sure that just one of the table views is visible at a time we need to utilize the visibility conditions of the table views.
25/ We need to create a datastore variable and call it cityorzip.
26/ Click on the new field button and create the variable
27/ Navigate back to the Weather by City table view and double click on the Visibility condition as seen in step 24.
28/ Enter the following condition for visibility:
29/ Double click on the Weather by Zip Code table view.
30/ Double click on the Visibility condition and enter the following expression:
31/ We now need to update the data store so that it reflects the correct value for the datastore variable CITYORZIP.
32/ Right click on the the link to the datastore just generated and click the Event Selector button. Choose the submit event and hit the OK button.
33/ Map a blank value to the datastore.
34/ Drag and drop from the output port of the Getweatherbyplacename service and choose the Data Store option from the context menu.
35/ Select the link just generated and map the value CITY to the datastore variable CITYORZIP.
36/ Connect the Getweatherbyzipcode service to the already existing datastore object and map the value ZIP to the datastore variable CITYORZIP.
37/ Navigate to the layout tab of the Visual Composer storyboard and overlay the two table views so they are sitting one right on top of the other.
38/ Whats an analytical app without some chart visualization so:
39/ Configure the chart as seen on the right
40/ Add the following two data series to the chart
41/ Once the data series have been setup set the visibility condition for the chart view just as you did for the Weather by City table view.
Set the expression to:
42/ Set the transition effect to Fade In/Out
43/ Create a chart view for the Getweatherbyzipcode service as well.
44/ Configure the chart as can be seen on the right
45/ Create two data series just as was performed in step 40.
46/ Navigate to the visibility condition of the newly created chart view and set it up just as the Weather by Zip code table view is set up.
47/ Set the Transition effect to Fade In/Out
48/ Navigate to the layout tab and associate the two chart views one on top of the other to the right of the initial entry form.
49/ Navigate back to the design tab and drag and drop an HTML view onto the work area. Name the HTML View Weather Image.
50/ Map both the Weather by City output port and the Weather by Zip Code output ports to the Weather Image input port. Map the url of the input port to the value @WeatherImage coming from both output ports.
51/ Select the Weather Image HTML View and double click on the Visibility condition. Set the Visibility condition to the following expression:
52/ Navigate to the Layout tab and place the Weather Image HTML View to the right of the two overlayed chart views. Save your work.
53/ Deploy your iView
54/ Launch the iView
55/ View your completed application in the portal!
You have now completed building an Advanced Web Application in Visual Composer utilizing Web Services!!