Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Using HttpConnector programmatically to get data from file remotely

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");
        }

0 votes


Accepted answer

Permanent link
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

1 vote

Comments

Thanks for sharing Alicia!

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,927
× 24

Question asked: Jul 19 '12, 4:43 p.m.

Question was seen: 4,607 times

Last updated: Jul 31 '12, 12:00 p.m.

Confirmation Cancel Confirm