You need to sign in to do that
Don't have an account?
ritswaney007
Invoking external webservice from Contacts Tab
3 days old (new) to salesforce!
i need to invoke a webservice from a tab like contacts when a button is clicked.
i understand i can add a custom button, but how do i write the code behind it, which will be triggered upon clicking.
the code behind the buttons needs to invoke this webservice, passing some details from the screen such as customer name and postcode, and the response that is received should be displayed on the screen.
please help people !
i need to invoke a webservice from a tab like contacts when a button is clicked.
i understand i can add a custom button, but how do i write the code behind it, which will be triggered upon clicking.
the code behind the buttons needs to invoke this webservice, passing some details from the screen such as customer name and postcode, and the response that is received should be displayed on the screen.
please help people !
you could break up the wsdl into separate wsdl's and parse each one?
do you need every method in the wsdl that you are using?
All Answers
The controller will make a webservice.invoke() or http() callout to get the data, then refresh the page with the controller providing the updated data.
There is a bit of Apex Code required to perform this type of callout, an example is documented in the Apex Developer Guide
is the service you are using a WebService or REST?
Many thanks for your response.
Here's what I tried out today. I added a custom button to the Account tab, which on click, invoked an s-control. The s-control invoked an Apex class which had code to callout another Apex class, which I generated from a wsdl.
Since I am very new to SFDC, I would greatly appreciate it, if you could tell me how different/advantageous using a Visualforce page with controller would be to using the s-control approach.
Also, I am new to webservices, so not sure if the one we intend using is Rest or Soap. Its the Experian Credit Check interface in the UK, which we are trying to use as a web service.
Would it be possible to have your email address for further communication / advice.
Thanks for your time.
Ritesh
Visualforce would be easier to customize the UI of the rest of the page, using an scontrol under a button may work just fine for you.
When you render the result, that operation may be fairly simple using Visualforce and some outputtext components.
to output the same info in an scontrol you would need to construct the required html on your own, in javascript.
it sounds like your service is a webservice
Thanks a ton for the guidance.
I have kinda managed to try that out. Now I'm trying to generated the Apex classes from the WSDL.
However, it can generate two classes out of the the three it tries to generate, the third one fails with the following error. Just wondering how to get around it.
The following generated class(es) have compilation errors:
Error: schemaUkExperianComExperianCemsMsg
Error: Script too large: //Generated by wsdl2apex
public class schemaUkExperianComExperianCemsMsg {
public class Special... at -1:-1
Cheers,
Ritesh
EG - I have multiple salesforce orgs. and wish to exchange data between the systems using SF webservices - however sadly when I try to process a salesforce generated wsdl - in another instance of salesforce - it gives the same error (too large)...
Is is just me - or does this seem a little ridiculous!!!!
:)
Well, I think the Apex developer guide clearly mentions that organisatin wide wsdl's cannot be convert to apex classes by the wsdl-to-apex converter, and in particular mentions that its not possible to convert SalesForce wsdl's to Apex.
Cheers
Ritesh
P.S. > Ron, my unanswered question is just above Mr Ingram's question ! :)
you could break up the wsdl into separate wsdl's and parse each one?
do you need every method in the wsdl that you are using?
Hope you had a good weekend :)
Well, there is only one method (operation) in the WSDL, the rest of it is type and message definitions.
:(
Ritesh
or post the wsdl?
note: not all WSDL's are parse-able by the tools we have today.
Apologies for the delay.
Salesforce manages to parse the WSDL alright I think, it manages to generate classes pertaining to two schemas, however on the third schema, which contains the "types", it fails saying script too long.
It is a webservice provided by Experian UK, which is a credit check bureau.
Its too long to paste on here, I'm wondering if you can provide an email address, where I could forward this to you. Mine is ritesh.aswaney@capgemini.com
I even tried trimming the extraneous fields in the WSDL and brought it down to 1/3 rd the size, but it still wont import, I'm wondering what to do next.
Cheers,
Ritesh
Does Apex support Secure Web Services. I need to consume an external WS, for one which need to be authenticated.
Authentication is via another WS, which accepts a X509 cert in the request and returns a Binary Security Token in the response.
This token needs to be embedded in all further requests, like this
<soap:Header>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-2b27a32b-ca9c-4405-b377-4444f63c8f29">
<wsu:Created>2007-02-20T16:36:54Z</wsu:Created>
<wsu:Expires>2007-02-20T16:41:54Z</wsu:Expires>
</wsu:Timestamp>
<wsse:BinarySecurityToken
ValueType="ExperianWASP"
EncodingType="wsse:Base64Binary"
wsu:Id="SecurityToken-f64439f9-c12c-4d09-ac3d-fc478ad19775">
MjAtRTctQ0YtMTUtN0EtODEtNTk...
</wsse:BinarySecurityToken>
In .NET , this can be written as
AuthPlusWS.InteractiveWSWse service = new AuthPlusWS.InteractiveWSWse();
// Add the secure token to the secured service
service.RequestSoapContext.Security.MustUnderstand = false;
service.RequestSoapContext.Security.Tokens.Add(wt);
Is there a way to do this in apex ?
Cheers,
Ritesh
The apex language reference is available at
www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf
Chapter 8 in that has a section titled
SOAP Services: Defining a Class from a WSDL Document
That should do it for you.
Cheers,
Ritesh
Dear Ritesh
Many thanks for you prompt response.
However we could already create the apex client using the same reference as mentioned in your mail. But I am not too sure what is the best option for creating the UI.
It would be great if you can provide me any pointer on the same.
Thanks & regards
Sanghamitra
ui for the Apex Client
If you are invoking the webservice on a button click from a standard tab such as Accounts, that will serve as the UI for you?
If, however, you intend writing your own UI, you would have to use VisualForce to create VisualForce pages.
It is similar to a jsp tag-lib with a variety of functions already provided.
You can refer to the salesforce_pages_developers_guide.pdf for information on how to use VisualForce.
It is basically modelled on the MVC type, where the VisualForce Page is the View, and a Controller class can be written, which is associated with teh VF Page.
You can read sections pertaining to custom controllers in the guide mentioned above.
I'm quite new to salesforce myself, but hope this is of assistance to you.
Cheers,
Ritesh
Hi Ritesh,
Many thanks for your reply !
>> If you are invoking the webservice on a button click from a standard tab such as Accounts, that will serve as the UI for you?
yes that would serve my purpose.
1. Generated a Apex Class from the WSDL of the Web Service.
(Ref : Chapter 8 of salesforce_apex_language_reference.pdf)
Here's the code of the apex class generated from my WSDL.
2. We then created a button which would invoke the method of the Apex Class
generated from the WSDL.
(Ref : Chapter 7 of Salesforce_platform_cookbook.pdf)
On-Click Java Script :
. Add the button to the Account List view LayoutOn Click of the button the input prompt are appearing to accept the input value
However finally it is showing the following errors:
fault code : 'Soapenv.client',
Faultstring : 'No Service available for the class wwwWebServiceNet.ConvertTemperatureSOAP'
Hi,
As per your suggestion We added another class which is calling the Apex Class generated from the WSDL:
the code is:
global class HelloWorld {
WebService static Double ConvertTemp()
{
String ToUnit = 'degreeCelsius';
String FromUnit = 'degreeFahrenheit';
Double Temperature = 123;
wwwWebservicexNet.ConvertTemperatureSoap stub = new wwwWebservicexNet.ConvertTemperatureSoap();
Double result = stub.ConvertTemp(Temperature,ToUnit, FromUnit );
return(result);
}
}
When I am invoking it from the Accounts tab I am getting a HelloWorld button .this button is calling the ConvertTemp method.
i am getting the Following error:
A problem with OnClick JavaScript for this button or link was encountered :
{faultcode:'soapenv:Client',faultstring:'System.CalloutException:IO Exception: Unauthorized endpoint, please check Setup->Security->Remote site settings.endpoint = http://www.webservicex.net/ConvertTemperature.asmx
Class.wwwWebservicexNet.ConvertTemperatureSoap.ConvertTemp:line 19, column 13
Class.HelloWorld.Converttemp: line 16 column 17',}
Kindly Help me for the same .
Here is the URL of the WSDL for your Refrence:
http://www.webservicex.net/ConvertTemperature.asmx?WSDL
Thankx
Message Edited by soa on 08-21-2008 10:04 PM
The actual reason I tried to copy the manual is I tried to access our own web service first and could not get that to work either!. I've also tried the Feed s-control that comes with Dev and that does not work (I did add a remote site for the URL...).
Any help or pointers here would be most appreciated as I need to get this working so I can test our new product integration woth SF:)
Thanks,
Andy.
{faultcode:'soapenv:Client',faultstring:'System.CalloutException:IO Exception: Unauthorized endpoint, please check Setup->Security->Remote site settings.endpoint = Link:
I'm getting the same error when I'm trying to attach a pdf file rendered through a vf page to the respective opportunity it's rendered from. I can SEE the file when I put in the URL but then it gives me that error when I actually run
How can this be? I'm working entierly within salesforce so how can it give me an external entry error? Anyone?