Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. public with sharing class Invoke_Webservice {
  2.  
  3. public void invokeService(){
  4.  
  5. try{
  6.  
  7. String username='email';
  8. String password='pass';
  9. HttpRequest req = new HttpRequest();
  10. req.setEndpoint('http://999.999.999.999:80/SFSAP');
  11. req.setMethod('GET');
  12. Blob headerValue = Blob.valueOf(username + ':' + password);
  13. String authorizationHeader = 'Basic '+
  14. EncodingUtil.base64Encode(headerValue);
  15. req.setHeader('Authorization', authorizationHeader);
  16. req.setHeader('Content-Type', 'application/soap+xml');
  17. req.setTimeout(80000);
  18.  
  19. //wsdl2apex class calling
  20.  
  21. wwwApprouterComConnectorsWsdl.Provide_ServicePort test = new wwwApprouterComConnectorsWsdl.Provide_ServicePort();
  22. wwwApprouterComConnectorsResponse4.Product_element result;
  23. result = test.Provide_Service('OAOM-PUMP','Sample','100-200','HALB','M');
  24. System.debug(result);
  25.  
  26. Http http = new Http();
  27. HttpResponse res = http.send(req);
  28. System.debug(res);
  29. }
  30. catch(Exception e){
  31. System.debug(e);
  32. }
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement