Tuesday, 1 November 2011

Calling WSDL in Salesforce using HttpRequest and HttpResponce

         String url = 'http://soap.amazon.com/schemas2/AmazonWebServices.wsdl';
         HttpRequest req = new HttpRequest();
         req.setEndpoint(url);
         String sbody = 'username=uname&password=passwd';
         System.debug('Body-'+sbody);
         req.setBody(sbody);
         req.setMethod('POST');
         req.setHeader('content-type', 'application/x-www-form-urlencoded');
         req.setTimeout(120000);
         req.setHeader('Content-Length','1024');
         req.setHeader('Connection','keep-alive');
    
         Http http = new Http();
         HTTPResponse res = http.send(req);
    
        //either use getBody and parse xml manually
         System.debug('Output>>>>'+res.getBody());
         //Using parser we can manually traverse the xml

1 comment:

  1. Its possible that you could explain how to call an operation in a WSDL, im really a newbie and I dont catch it how to do it. Any help will be appreciated.

    Regards
    Jorge
    jorge.najera.t@gmail.com

    ReplyDelete