Advertisement
Guest User

Untitled

a guest
Aug 8th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. if (outboundProperty.booleanValue()) {
  2.  
  3. SOAPMessage message = smc.getMessage();
  4.  
  5. try {
  6.  
  7. SOAPEnvelope envelope = smc.getMessage().getSOAPPart().getEnvelope();
  8. SOAPHeader header = envelope.addHeader();
  9.  
  10. if (header == null){
  11. header = envelope.addHeader();
  12. }
  13.  
  14. SOAPFactory soapFactory = SOAPFactory.newInstance();
  15.  
  16. final SOAPElement security = header.addChildElement("Security", "o", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
  17. SOAPElement usernameToken = security.addChildElement("UsernameToken", "o");
  18. SOAPElement username = usernameToken.addChildElement("Username", "o");
  19. username.addTextNode("Test");
  20. SOAPElement password =usernameToken.addChildElement("Password", "o");
  21. password.addTextNode("password");
  22.  
  23. //Print out the outbound SOAP message to System.out
  24. message.writeTo(System.out);
  25. System.out.println("==============================");
  26.  
  27. } catch (Exception e) {
  28. e.printStackTrace();
  29. }
  30.  
  31. } else {
  32. try {
  33. //This handler does nothing with the response from the Web Service so
  34. //we just print out the SOAP message.
  35. SOAPMessage message = smc.getMessage();
  36. message.writeTo(System.out);
  37. System.out.println("");
  38. } catch (Exception ex) {
  39. ex.printStackTrace();
  40. }
  41. }
  42.  
  43.  
  44. return outboundProperty;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement