It's all about the answers!

Ask a question

Using HttpConnector programmatically to get data from file remotely


Alicia McPherson (7131418) | asked Jul 19 '12, 4:43 p.m.
edited Jul 31 '12, 12:00 p.m. by Jared Burns (4.5k29)
How do I initialize the IContext interface variable in RTC 3.0.1.3 to make the following code work for a precondition? I'm unable to declare in in the run method because the run methods is an implementation of the IOperationAdvisor interface.

Thanks!


        //Use HttpConnectorParameters to define variables for Http Lookup
        HttpConnectorParameters params = new HttpConnectorParameters();
        params.url = "URL";
        params.xpath = "//srnumber";
        params.columnXpaths = new String[] {"./nextnumber/@data"};
        params.columnIds = new String[]{"nextnumber"};
       
        IContext context=..................
        IDataConnector connector = context.getDataConnector("HttpConnector");
        IHttpConnector conParams = (IHttpConnector) connector;
       
        try{
           
            IResponse connectorParams = connector.get(params);
           
            String results[];           
            while (connectorParams.hasNext()){
                IResponseEntry entry = connectorParams.next();
                String nextnumber = entry.getById("nextnumber");
            }
        }
        catch(ConnectorException c){
            System.out.println("Unable to connect to webservice");
        }

Accepted answer


permanent link
Alicia McPherson (7131418) | answered Jul 25 '12, 4:34 p.m.
I continued to work on the code above and I was able to get it to work

//Use HttpConnectorParameters to define variables for Http Lookup
        HttpConnectorParameters params = new HttpConnectorParameters();
        params.url = "URL";
        params.xpath = "//srnumber";
        params.columnXpaths = new String[] {"./nextnumber/@data"};
        params.columnIds = new String[]{"nextnumber"};
       
        IDataConnector connector =  IDataConnector connector = workItemCommon.getDataConnector("HttpConnector");
        IHttpConnector conParams = (IHttpConnector) connector;
       
        try{
           
            IResponse connectorParams = connector.get(params);
           
            String results[];           
            while (connectorParams.hasNext()){
                IResponseEntry entry = connectorParams.next();
                String nextnumber = entry.getById("nextnumber");
            }
        }
        catch(ConnectorException c){
            System.out.println("Unable to connect to webservice");
        }
Ralph Schoon selected this answer as the correct answer

Comments
Ralph Schoon commented Jul 26 '12, 2:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Thanks for sharing Alicia!

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.