Calling WSDL in Salesforce using HttpRequest and HttpResponse

  sales-block


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

284total visits,2visits today

Leave a Reply

Your email address will not be published. Required fields are marked *