function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Implementing Apex callouts



I am trying to implement a Apex callout to a websrvice. For this i have so far performed the following procedure.

Generating the WSDL class and setting up Endpoint URL in the remote settings. So now i am stuck with how to call the service method from Apex and test if the connection is made.



Service method: GAPNetworkImages()


Thanks in Advance.


nothing different than normal


you used the remote services WSDL to create the APEX class.

setup->develop->apex class-> generate from WSDL


then you write some other apex code, you get an instance of that class  classname serv_object= new classname();

then you call the method in the classname thru the object.. server_object.method(parms)..


here is that section from one of my apps.. note that this is from a trigger, and you have to do some special re-coding in the wsdl created code

to add an @future method, as the web service takes too long to run on the trigger thread.


wwwRtcdefectNew4.RTCDefect ws = new wwwRtcdefectNew4.RTCDefect();

                        User u = [select id, pmfkey__c from user where id=:changedObjectNew.owner__c];
                        Product2 p = [select id, name from product2 where id=:changedObjectNew.product__c];                        
                        system.debug('calling create web service for problem='' product=''" for user='+u.pmfkey__c);

                        String rc = ws.CreateItem(






Thank you so much for your response. 


The process i have performed till now is  i have a .net webserivce that we use for our application named Ajax.asmx. so i generated a WSDL  Apex class from this webservice.  Now my task is i have a method in this service which is trying to check for the existence of certain image files from our newtowrk and if they dont we need to update certain fields in SFDC.


What should my Apex class be like after i query a list of people, i would have to pass this list to the service and check for the images existence.


Please suggest.







can u be a little more clear..


what is a 'list of people'? SFDC 'users', or account 'contacts'.


what does 'list' mean..


in the service i showed, the wsdl said there was an array of 0..n, items, this then turns into an array of that object.

what does your wsdl say?


mine says

<xsd:element maxOccurs="unbounded" minOccurs="1" name="cases" type="dft:wsCase"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="comments" type="dft:wsComment"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="attachments" type="dft:wsAttachment"/>



the wsdl definition of the wsCommewnt object looks like this

      <xsd:complexType name="wsComment">
              <xsd:element maxOccurs="1" minOccurs="1" name="creationdate" type="xsd:dateTime"/>
              <xsd:element maxOccurs="1" minOccurs="1" name="creator" type="xsd:string"/>
              <xsd:element maxOccurs="1" minOccurs="1" name="content" type="xsd:string"/>
              <xsd:element maxOccurs="1" minOccurs="1" name="uuid" type="xsd:string"/>



so the api takes an array of those objects.


in apex that is

wsComent[] list_of_comments;


I modified the apex wsdl class to create a method to find the comments, and build a 'list' object,

which the wsdl marshalls into an array for you


                  request_x.cases = caseList(problem); 
                  request_x.comments = commentList(problem);                 
                  request_x.attachments = attachmentlist(problem); 



private static List<wwwCaComRtcdefectNew4.wsComment> commentList(String problem_number)
          List<wwwCaComRtcdefectNew4.wsComment> notelist = new List<wwwRtcdefectNew4.wsComment>();
          integer i = 1;         
          for (Comment__C n:[select Body__c, Created__c,name, isDeleted, UUid__c  from Comment__c where     related_Problem__c    =:[select id from Problem__c where name=:problem_number ].id  and isDeleted = false order by CreatedDate asc])
               wwwRtcdefectNew4.wsComment c= new wwwRtcdefectNew4.wsComment();
               c.content = n.body__c;
               c.creationdate= n.created__c;
               c.UUid = n.uuid__c;
          return notelist;

 my web service handler processes that parameter as a list of wsComments
private static String CommentstoList(WsComment[] comments, boolean create);