Guest User

Untitled

a guest
Nov 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. public String sendRequest() throws Exception{
  2. StringBuilder builder = new StringBuilder();
  3. String request ;
  4. request = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sup="http://support.xxxxxxxx.ru">n" +
  5. " <soapenv:Header/>n" +
  6. " <soapenv:Body>n" +
  7. " <sup:DSPersonFindByIDReq>n" +
  8. " <!--Optional:-->n" +
  9. " <sup:CodePasspDepartment></sup:CodePasspDepartment>n" +
  10. " <!--Optional:-->n" +
  11. " <sup:DetailFlag></sup:DetailFlag>n" +
  12. " <!--Optional:-->n" +
  13. " <sup:PersonID>10000031788</sup:PersonID>n" +
  14. " </sup:DSPersonFindByIDReq>n" +
  15. " </soapenv:Body>n" +
  16. "</soapenv:Envelope>";
  17.  
  18.  
  19. try {
  20. URL obj = new URL(Config.getProperty("url_crmws"));
  21. HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  22.  
  23. String encoding = Base64.getEncoder().encodeToString((Config.getProperty("ws_login")+":"+Config.getProperty("ws_password")).getBytes("UTF-8"));
  24.  
  25. //подготовка
  26. con.setRequestMethod("POST"); //передавать постом
  27. con.setDoInput(true); //передача запроса на сервер
  28. con.setDoOutput(true); //прием ответа
  29. con.setUseCaches(false); //без кэширования
  30. con.addRequestProperty("Content-Type", "application/xml; charset=utf-8"); //кодировка
  31. con.addRequestProperty("Cache-Control", "no-cache");
  32. con.addRequestProperty("Cache-Control", "no-store");
  33. con.setRequestProperty("Content-Length", //con.setRequestProperty("Authorization", "Basic " + encoding);
  34.  
  35.  
  36. //отправка
  37. OutputStream os = con.getOutputStream();
  38.  
  39.  
  40. os.write(request.getBytes());
  41. os.flush();
  42. os.close();
  43.  
  44. con.addRequestProperty("Content-Type", "text/xml; charset=utf-8");
Add Comment
Please, Sign In to add comment