I'm trying to call a webservice that returns JSON data and am using the WSDLDataBindingSample.java from the Showcase as a starting point. If I use service.getFetchDS("getRamReport", null), it actually invokes the WSDL's getRamReport method correctly and outputs JSON. However, I would like to use my own datasource called ramDS, but when I do this it never calls the WSDL's getRamReport method. Am I putting the Webservice method in the correct place ? fetch.setWsOperation("getRamReport") ??
Here's the Entry class:
Here's my custom Datasource:
Here's the Entry class:
Code:
public Canvas callJSONWebservice() {
final Canvas canvas = new Canvas();
canvas.setWidth100();
canvas.setHeight100();
final String wsdlURL = "http://localhost:8080/pmTools/services/FormWebService?wsdl";
SC.showPrompt("Loading WSDL from: " + wsdlURL);
XMLTools.loadWSDL(wsdlURL, new WSDLLoadCallback() {
public void execute(WebService service) {
if (service == null) {
SC.warn("WSDL not currently available from Google (tried "
+ wsdlURL + ")", new BooleanCallback() {
public void execute(Boolean value) {
}
});
return;
}
final DynamicForm searchForm = new DynamicForm();
searchForm.setNumCols(4);
searchForm.setWidth(500);
// WebService method and params being invoked
searchForm.setDataSource(service.getInputDS("getRamReport"));
searchForm.setValue("applicationId", "39202583-F898-E769-6512-25B888108E39");
searchForm.setValue("program", "0BXY");
//DataSource resultDS = service.getFetchDS("getRamReport", null);
DataSource ramDS = RAMJsonDS.getInstance();
// create Grid
final ListGrid lreGrid = new ListGrid();
lreGrid.setWidth100();
lreGrid.setDataSource(ramDS);
lreGrid.setAutoFetchData(true);
lreGrid.setFields(
new ListGridField("wbsNum", "WBS Num"),
new ListGridField("controlAccountNum", "Pre LRE($K)")
);
IButton searchButton = new IButton("Search");
searchButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
lreGrid.fetchData(searchForm.getValuesAsCriteria());
}
});
// create layout
VLayout layout = new VLayout(20);
layout.setWidth100();
layout.setHeight100();
layout.setLayoutMargin(40);
layout.addMember(searchForm);
layout.addMember(searchButton);
layout.addMember(lreGrid);
canvas.addChild(layout);
canvas.draw();
SC.clearPrompt();
}
});
return canvas;
}
Code:
public class RAMJsonDS extends DataSource {
private static RAMJsonDS instance = null;
public static RAMJsonDS getInstance() {
if (instance == null) {
instance = new RAMJsonDS("ramDS");
}
return instance;
}
final String wsdlURL = "http://localhost:8080/pmTools/services/FormWebService?wsdl";
public RAMJsonDS(String id) {
setID(id);
setRecordXPath("rows");
setDataFormat(DSDataFormat.JSON);
setDataURL(wsdlURL);
//jsonDS.setServiceNamespace("http://form.workflow.pmtools.com");
DataSourceField wbsNum = new DataSourceField("wbsNum", FieldType.TEXT);
DataSourceField controlAccountNum = new DataSourceField("controlAccountNum", FieldType.TEXT);
setFields(wbsNum, controlAccountNum);
OperationBinding fetch = new OperationBinding();
fetch.setOperationType(DSOperationType.FETCH);
fetch.setDataProtocol(DSProtocol.POSTPARAMS);
DSRequest fetchRequest = new DSRequest();
fetchRequest.setHttpMethod("GET");
fetch.setRequestProperties(fetchRequest);
fetch.setDataURL(wsdlURL);
fetch.setWsOperation("getRamReport");
setOperationBindings(fetch);
}
}
Comment