To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
Structs as parameters

Working with SOAP Web Services

Lesson 3: Returning Structs

Building from the last lesson, this lesson will show how to use structs in a web service.

  1. Create a function from to retrieve a recipe from the “Recipe” table.
  2. From the ‘Table Explorer’ on the left, right click on the “Recipe” table, and select “View Table” to view the available table.

  3. Return to the WsCookbook.wo tab.
  4. Add a function to get the recipe
    Function GetRecipe Integer iRecipeID Returns tRecipe


  5. Define tRecipe by adding the struct to the top of the code including variables used in the Recipe table.
    Struct tRecipe

          Integer iRecipeID

    String sName

    String sKitchen

          String sHowToMake

          Integer iPrepTime

          Integer iRating


  6. Use the existing DDO to retrieve the actual recipe from the table.
  7. To add it to WsCookbook.wo open the ‘DDO Explorer’ by clicking on its tab located on the bottom of the right panel.
  8. Select the Add a New DDO icon.
  9. Highlight “cRecipeDataDictionary,” and choose ‘Select.’
  10. Update the tRecipe function to fetch recipes by ID, publish, and add a description.
    {Published = True}

    {Description = “Gets a recipe by its ID”}

    Function GetRecipe Integer iRecipeID Returns tRecipe

          tRecipe oRecipe

          Send Clear of oRecipe_DD

          Move iRecipeID to Recipe.RecipeID

          Send Find of oRecipe_DD EQ 1

          If (Found) Begin

          Move Recipe.RecipeID to oRecipe.iRecipeID

          Move Recipe.Name to oRecipe.sName

    Move KitchenName to oRecipe.sKitchen

    Move Recipe.Rating to oRecipe.iRating

    Move Recipe.PreparationTime to oRecipe.iPrepTime

    Move Recipe.HowToMake to oRecipe.sHowToMake


  11. Select run icon from the top toolbar.
  12. The web browser page now shows all three functions.
  13. Selecting “GetRecipe” calls the new function.
  14. Entering a Recipe ID value, and clicking invoke will call the corresponding recipe variables translated in XML.