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