Using HttpConnector programmatically to get data from file remotely
Alicia McPherson (71●3●14●18)
| asked Jul 19 '12, 4:43 p.m.
edited Jul 31 '12, 12:00 p.m. by Jared Burns (4.5k●2●9)
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
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
|
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.