1 16 17 package samples.security; 18 19 import org.apache.axis.MessageContext; 20 import org.apache.axis.client.Call; 21 import org.apache.axis.client.Service; 22 import org.apache.axis.message.SOAPBodyElement; 23 import org.apache.axis.message.SOAPEnvelope; 24 import org.apache.axis.utils.Options; 25 import org.apache.axis.utils.XMLUtils; 26 27 public class Client { 28 public static void main(String [] args) throws Exception { 29 try { 30 Options opts = new Options(args); 31 32 Service service = new Service(); 33 Call call = (Call) service.createCall(); 34 call.setTargetEndpointAddress(new java.net.URL (opts.getURL())); 35 36 SOAPEnvelope env = new SOAPEnvelope(); 37 SOAPBodyElement sbe = new SOAPBodyElement(XMLUtils.StringToElement("http://localhost:8080/LogTestService", "testMethod", "")); 38 env.addBodyElement(sbe); 39 40 env = new SignedSOAPEnvelope(env, "http://xml-security"); 41 42 System.out.println("\n============= Request =============="); 43 XMLUtils.PrettyElementToStream(env.getAsDOM(), System.out); 44 45 call.invoke(env); 46 47 MessageContext mc = call.getMessageContext(); 48 System.out.println("\n============= Response =============="); 49 XMLUtils.PrettyElementToStream(mc.getResponseMessage().getSOAPEnvelope().getAsDOM(), System.out); 50 } 51 catch (Exception e) { 52 e.printStackTrace(); 53 } 54 } 55 } 56 | Popular Tags |