Topic
  • 4 replies
  • Latest Post - ‏2014-05-05T21:11:12Z by ChrisDawes(IBM)
DivyaN23
DivyaN23
5 Posts

Pinned topic How to populate data using REST web service

‏2014-04-28T13:11:04Z |

Hello,

 

I am a newbie to FEB. I have a requirement to populate the form with the data from the web-service and I need to provide username and simple token(encoded string of " My Portal "+ currentDate) as input params to the web service.

 

I ahave the placed the xml attached under C:\IBM\Forms\ServiceCatalog\1 (I have created the folders ServiceCatalog\1 as it doesnot exist). Just for testing I have given the full url and not sure how to privide the input parameters.  I cant find the Web service though form the events tab. Highly appreciate any help with this.

Thanks in advance!

Attachments

Updated on 2014-04-29T12:31:29Z at 2014-04-29T12:31:29Z by DivyaN23
  • ChrisDawes(IBM)
    ChrisDawes(IBM)
    844 Posts

    Re: How to pulate data using REST web service

    ‏2014-04-29T04:12:46Z  

    If you had to create the ServiceCatalog/1 directory then you must restart the server, otherwise the xml file will not be detected.  You will not have to restart the server when adding new xml files or making changes to existing ones (its only if you create the directory after the server was already running).

    I reviewed your file and it is not very complete and also has params that I would not have expected you to add (but they might be specific to your web service).  I would recommend that you take a look at my article on creating service descriptions for REST APIs.

    http://www-10.lotus.com/ldd/lfwiki.nsf/dx/Create_Service_Description_for_REST_API

  • DivyaN23
    DivyaN23
    5 Posts

    Re: How to populate data using REST web service

    ‏2014-04-29T09:36:14Z  

    If you had to create the ServiceCatalog/1 directory then you must restart the server, otherwise the xml file will not be detected.  You will not have to restart the server when adding new xml files or making changes to existing ones (its only if you create the directory after the server was already running).

    I reviewed your file and it is not very complete and also has params that I would not have expected you to add (but they might be specific to your web service).  I would recommend that you take a look at my article on creating service descriptions for REST APIs.

    http://www-10.lotus.com/ldd/lfwiki.nsf/dx/Create_Service_Description_for_REST_API

    I have restarted and modified the xml. I don't see any error in the server.out but still I cannot find the web service as the first screenshot in your article. I am able to Get Countries By Region web service though which i haven't added. I wasn't able to see it yesterday though.

    I am not sure what to give for <transportId> though. The webservice returns an xml tree structure which i want to display in the form or atleast a child element value, so can you please brief me on how to accomplish this.

    Thanks for your time!

    Attachments

    Updated on 2014-04-29T12:31:47Z at 2014-04-29T12:31:47Z by DivyaN23
  • DivyaN23
    DivyaN23
    5 Posts

    Re: How to populate data using REST web service

    ‏2014-04-29T12:17:39Z  
    • DivyaN23
    • ‏2014-04-29T09:36:14Z

    I have restarted and modified the xml. I don't see any error in the server.out but still I cannot find the web service as the first screenshot in your article. I am able to Get Countries By Region web service though which i haven't added. I wasn't able to see it yesterday though.

    I am not sure what to give for <transportId> though. The webservice returns an xml tree structure which i want to display in the form or atleast a child element value, so can you please brief me on how to accomplish this.

    Thanks for your time!

    I am able to view te webservice and and retieve application/xml as in the screenshot but sure how to retrieve the security token. I have attached the sample output response.xml and I want to retieve the fields of the xml tree.

    Also please suggest how to pass  the encoded token of current date and logged in user's userName parameters to the URL as they are dynamic values and not hardcoded ones.

    http://servicebroker.ac.uk/WebServicesLIVE/Secured/UserInfo/{0}/{1}/Portal?format=xml

    {0} - Encoded value of Date

    { 1} - Logged in user's name

    Attachments

    Updated on 2014-04-29T12:32:05Z at 2014-04-29T12:32:05Z by DivyaN23
  • ChrisDawes(IBM)
    ChrisDawes(IBM)
    844 Posts

    Re: How to populate data using REST web service

    ‏2014-05-05T21:11:12Z  
    • DivyaN23
    • ‏2014-04-29T12:17:39Z

    I am able to view te webservice and and retieve application/xml as in the screenshot but sure how to retrieve the security token. I have attached the sample output response.xml and I want to retieve the fields of the xml tree.

    Also please suggest how to pass  the encoded token of current date and logged in user's userName parameters to the URL as they are dynamic values and not hardcoded ones.

    http://servicebroker.ac.uk/WebServicesLIVE/Secured/UserInfo/{0}/{1}/Portal?format=xml

    {0} - Encoded value of Date

    { 1} - Logged in user's name

    The items that you have marked as {0} and {1} would have to come from the form.  In your XML file you need to define input parameters so that form can pass the information to the service.  Something like:

    <inbound>
         <parameters>
            <parameter>
                    <id>encodedDate</id>
                    <name xml:lang="en">Encoded Date</name>
                    <description xml:lang="en"/>
                    <mandatory>false</mandatory>
                    <type>STRING</type>
                    </parameter>                 
                <parameter>
                    <id>currentUser</id>
                    <name xml:lang="en">Current User</name>
                    <description xml:lang="en"/>
                    <mandatory>false</mandatory>
                    <type>STRING</type>
                     </parameter>           
            </parameters>
        <serviceMapping>

    ...

    </inbound>

    Your form will have to pass the encoded date string, which you should be able to build using JavaScript.  And you can pass the current user information as well.  Each of these will need to appear in a single line entry which can be linked as inputs to the service.

    Then you have to make sure these are properly added to the URL in the ServiceMapping section.  So it might look something like this:

    <serviceMapping>
            <constants>
                <constant>
                    <id>request-url</id>
                    <value>http://servicebroker.ac.uk/WebServicesLIVE/Secured/UserInfo/</value>
                </constant>
                <constant>
                    <id>request-method</id>
                    <value>GET</value>
                </constant>
                <constant>
                    <id>finalStr</id>
                    <value>/Portal?format=xml</value>
                </constant>
                <constant>
                    <id>slash</id>
                    <value>/</value>
                </constant>
            </constants>
            <mapping>
                  <mapping target="transport:request-url" source="constant:request-url" sourceType="string" targetType="string"/>
                  <mapping target="transport:request-url-postfix-0" source="parameter:encodedDate" sourceType="string" targetType="string"/>
                  <mapping target="transport:request-url-postfix-1" source="constant:slash" sourceType="string" targetType="string"/>
                  <mapping target="transport:request-url-postfix-2" source="parameter:currentUser" sourceType="string" targetType="string"/>
                  <mapping target="transport:request-url-postfix-3" source="constant:finalStr" sourceType="string" targetType="string"/>
                  <mapping target="transport:request-method" source="constant:request-method" sourceType="NOOP" targetType="STRING"/>
              </mapping>
        </serviceMapping>

    Note how I am now building up the URL based on the parameters/constants defined.

    Updated on 2014-05-05T21:12:29Z at 2014-05-05T21:12:29Z by ChrisDawes(IBM)