PrG_SOAPenable_Queries.xml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
  4. <sect1 id="SOAP-enabling_Queries">
  5. <title><emphasis role="bold">SOAP-enabling Queries</emphasis></title>
  6. <para>Queries destined for use in Roxie are SOAP-enabled first. The required
  7. ECL code to accomplish this is the STORED workflow service. Roxie queries
  8. may be contained in the FUNCTION structure or may simply be an executable
  9. query.</para>
  10. <sect2 id="The_ECL_Key_to_SOAP">
  11. <title>The ECL Key to SOAP</title>
  12. <para>The ECL code requirement for SOAP-enabled input parameters is the
  13. use of the STORED workflow service. Each SOAP parameter name must be the
  14. STORED name for an ECL definition. The STORED workflow service creates a
  15. data storage space in the workunit that the SOAP interface uses to
  16. populate the “passed” data. The ECL code simply uses those STORED
  17. definitions to determine whether data was passed from that “parameter” and
  18. what that data is. The data type of the passed SOAP parameter is implied
  19. by the STORED definition.</para>
  20. <para>For the following code example, you must create two definitions with
  21. STORED names duplicating the SOAP parameter name, like this:</para>
  22. <programlisting>STRING30 lname_value := '' : STORED('LastName');
  23. STRING30 fname_value := '' : STORED('FirstName');
  24. </programlisting>
  25. <para>These default to blank and the STORED workflow service opens a space
  26. in the workunit to store the value. The Enterprise Service Platform (ESP)
  27. handles the SOAP interface chores by plugging in the appropriate values
  28. into the storage space created by STORED. Therefore, the ECL code only
  29. needs to use the definitions (in this case, Lname and Fname) to accomplish
  30. the query. This makes the ECL side of the equation very simple.</para>
  31. </sect2>
  32. <sect2 id="Putting_It_All_Together">
  33. <title>Putting It All Together</title>
  34. <para>Once you understand the requirements, a SOAP-enabled query would
  35. look like this (contained in SOAPenabling.ECL):</para>
  36. <programlisting>IMPORT ProgrammersGuide.DeclareData AS ProgGuide;
  37. EXPORT SOAPenabling() := FUNCTION
  38. STRING30 lname_value := '' : STORED('LastName');
  39. STRING30 fname_value := '' : STORED('FirstName');
  40. IDX := ProgGuide.IDX__Person_LastName_FirstName;
  41. Base := ProgGuide.Person.FilePlus;
  42. Fetched := IF(fname_value = '',
  43. FETCH(Base,IDX(LastName=lname_value),RIGHT.RecPos),
  44. FETCH(Base,IDX(LastName=lname_value,
  45. FirstName=fname_value),RIGHT.RecPos));
  46. RETURN OUTPUT(CHOOSEN(Fetched,2000));
  47. END;</programlisting>
  48. <para></para>
  49. </sect2>
  50. </sect1>