You need to sign in to do that
Don't have an account?
p1erre
Visualforce: how to call external web service?
I have following issue:
when I create a new Account I first would like to fetch the Account data from an external web service
and populate the Account with the result of my web service call. My idea is to add a button (GetAccountData) that would trigger the
web service (with a Controller ?), get the response and display the data on the Account Tab.
is there a way in Visualforce to add such a functionality ?
when I create a new Account I first would like to fetch the Account data from an external web service
and populate the Account with the result of my web service call. My idea is to add a button (GetAccountData) that would trigger the
web service (with a Controller ?), get the response and display the data on the Account Tab.
is there a way in Visualforce to add such a functionality ?
The sample apex page
<apex:page controller="Temperature">
<apex:form>
<h1>Congratulations</h1>
This is your new Page
<apex:commandButton action="{!recordReplicator}" value="Next"/>
The output webservice is {!output}
</apex:form>
</apex:page>
Controller
public class Temperature
{
Double output;
public void recordReplicator()
{
webservicesDaehostingComTemperature.TemperatureConversionsSoap stub = new webservicesDaehostingComTemperature.TemperatureConversionsSoap();
Double nFahrenheit=129;
Double nWindSpeed=20;
System.debug('In temperature Trigger');
output= stub.WindChillInFahrenheit(nFahrenheit,nWindSpeed);
System.Debug('output'+output);
}
public double getOutput()
{
return output;
}
}
This call an external webservice the apex class is
webservicesDaehostingComTemperature
thanks very much for your sample code.
I have copied the classes and the page and could compile them successfully.
Now, when i press the NEXT button i get following visualforce error:
IO Exception: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = http://webservices.daehosting.com/services/TemperatureConversions.wso
Do i have to do define some settings within salesforce to enable the access to the external called web service?ok, after having defined the web service in Remote Site Setting as follows it worked!!
Thanks a lot for your quick and very detailed response
/p1erre
OR, you could also generate it from the source code view page (Click on Generate WSDL in the Apex code view page).
Hi Reshma,
Where is the web services of this example?
Hello Reshma
I am new to VF ... i have copied your code and even use the wsdl2apex method .... but it is generating this error
Error: Compile Error: Method does not exist or incorrect signature: WebServiceCallout.invoke(webservicesDaehostingComTemperature.TemperatureConversionsSoap, webservicesDaehostingComTemperature.WindChillInFahrenheit_element, MAP<String,webservicesDaehostingComTemperature.WindChillInFahrenheitResponse_element>, LIST<String>) at line 52 column 13
Kindly help me ...