Working with SOAP Web Services
Lesson 4: Structs as parameters
Continuing from the last lesson, a new function will be added that takes a struct as a parameter.
- Starting again from WsCookbook.wo…
- Add a new function that will ultimately add recipes to the existing “Recipe” table. Make sure publish the function, and to add a description. Include code to validate the data. Add a new struct at the top of the code as well.
{Published = True}
{Description = “Adds a new recipe to the cookbook”}
Function AddNewREcipe tRecipeIn oRecipe Returns Boolean
Boolean bErr
Send Clear of oRecipe_DD
Set Field_Changed_Value of oRecipe_DD Field Recipe.Name to oRecipe.sName
Set Field_Changed_Value of oRecipe_DD Field Recipe.Name to oRecipe.sName
Set Field_Changed_Value of oRecipe_DD Field Recipe.Name to oRecipe.sName
Set Field_Changed_Value of oRecipe_DD Field Recipe.Name to oRecipe.sName
Get Request_Validate of oRecipe_DD to bErr
If (not(bErr)) Begin
Send Request_Save of oRecipeDD
Function_Return True
End
Function_Return False
End_Function

- Add a new struct at the top of the code as well.
Struct tRecipeIn
String sName
Integer iKitchenID
String sHowToMake
Integer iPrepTime
End_Struct

- Select run icon from the top toolbar.
- The web browser page now shows all four functions.

- Selecting “AddNewRecipe” calls the new function.
- The resulting page will state that we cannot test this. Continue on to Lesson 5, Calling SOAP WebServices – the basics, of this series to learn how to call on a web service, and how to call on this specific function from the DataFlex program.
