You need to sign in to do that
Don't have an account?
dasari123
how to call webservices from vfpage
Hi iam having two fields (serial number,product number) and a button submit in a vfpage, when give the sno,pno and click on the submit it has to call the external webservice and get response as productnumber,productdescription in a table or grid ,the out put has to be shown on the same vfpage..
iam having a wsdl from that i generated the apexclasses then how to get the response from externalwebservices
iam having a wsdl from that i generated the apexclasses then how to get the response from externalwebservices
Here's an example of calling a web service to get postage rates:
public PageReference makePostageLabel() {
EnvmgrLabelService.LabelRequest labelRequest = new EnvmgrLabelService.LabelRequest();
labelRequest.RequesterID = 'abcd';
labelRequest.AccountID = '123456';
labelRequest.MailClass = mailClass; // Controller properties - bound to fields in VF page
labelRequest.MailpieceShape = mailpieceShape;
// etc
// Get the SOAP service
EnvmgrLabelService.EwsLabelServiceSoap service = new EnvmgrLabelService.EwsLabelServiceSoap();
// Call the web service
EnvmgrLabelService.LabelRequestResponse labelResponse = service.GetPostageLabel(labelRequest);
// See what happened - status, postageLabel, finalPostage can also be bound to fields in a VF page
if ( labelResponse.Status == 0 ) {
status = 'Label created';
postageLabel = labelResponse.Base64LabelImage;
} else {
status = labelResponse.ErrorMessage;
postageLabel = blank;
}
List<String> format = new String[]{'0','number','###,###,##0.00'};
finalPostage = String.format(labelResponse.FinalPostage.format(), format);
// Return null to stay on the same page and show the result. Could also send the status etc to
// another page - set parameters on the PageReference
return null;
}