Guest User

Untitled

a guest
Jul 27th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. public class Calloutcontroller1 {
  2. public List<consolewrap1> ConsoleWrapperList{get;set;}
  3. public List<consolewrap1> getperformcallout(){
  4. ConsoleWrapperList = new List<consolewrap1>();
  5. HttpRequest req = new HttpRequest();
  6. HttpResponse res = new HttpResponse();
  7. Http http = new Http();
  8. req.setEndpoint('http://************************/sap/opu/odata/SAP/ZORDERS_INFO_SRV/ZORDERN_ETSet');
  9. req.setMethod('GET');
  10.  
  11. String username = '******';
  12. String password = '*********';
  13.  
  14. Blob headerValue = Blob.valueOf(username + ':' + password);
  15. String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
  16. req.setHeader('Authorization', authorizationHeader);
  17. req.setHeader('x-csrf-token', 'Fetch');
  18. req.setHeader('Accept', 'application/json');
  19.  
  20. res = http.send(req);
  21.  
  22. if(res.getstatusCode() == 200 && res.getbody() != null){
  23. ConsoleWrapperList=(List<consolewrap1>)json.deserialize(res.getbody(),List<consolewrap1>.class);
  24. }
  25. return consolewrapperlist;
  26. }
  27.  
  28. <apex:page controller="Calloutcontroller1" title="JSON table" >
  29. <apex:form >
  30. <apex:pageBlock >
  31. <apex:pageBlockTable value="{!performcallout}" var="wrap" width="100%">
  32. <apex:column headerValue="Order" value="{!wrap.Orderid}"/>
  33. <apex:column headerValue="Customer" value="{!wrap.Customerid}"/>
  34.  
  35. <apex:column headerValue="Ship via" value="{!wrap.Shipvia}"/>
  36. <apex:column headerValue="Ship Name" value="{!wrap.Shipname}"/>
  37. <apex:column headerValue="Ship Address" value="{!wrap.Shipaddress}"/>
  38. <apex:column headerValue="Ship City" value="{!wrap.Shipcity}"/>
  39. <apex:column headerValue="Ship Region" value="{!wrap.Shipregion}"/>
  40.  
  41. <apex:column headerValue="Returnprd Code" value="{!wrap.Returnprdcode}"/>
  42. <apex:column headerValue="Returnprd Qty" value="{!wrap.Returnprdqty}"/>
  43. <apex:column headerValue="Replaceprd Code" value="{!wrap.Replaceprdcode}"/>
  44. <apex:column headerValue="Replaceprd Qty" value="{!wrap.Replaceprdqty}"/>
  45. </apex:pageBlockTable>
  46. </apex:pageBlock>
  47. </apex:form>
  48.  
  49. public class Consolewrap1 {
  50. public String Orderid{get;set;}
  51. public String Customerid{get;set;}
  52.  
  53. public String Shipvia{get;set;}
  54. public String Shipname{get;set;}
  55. public String Shipaddress{get;set;}
  56. public String Shipcity{get;set;}
  57. public String Shipregion{get;set;}
  58.  
  59. public String Returnprdcode{get;set;}
  60. public String Returnprdqty{get;set;}
  61. public String Replaceprdcode{get;set;}
  62. public String Replaceprdqty{get;set;}
Add Comment
Please, Sign In to add comment