01: /*
02: * Copyright 2001-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
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
35: .getURL()));
36:
37: SOAPEnvelope env = new SOAPEnvelope();
38: SOAPBodyElement sbe = new SOAPBodyElement(XMLUtils
39: .StringToElement(
40: "http://localhost:8080/LogTestService",
41: "testMethod", ""));
42: env.addBodyElement(sbe);
43:
44: env = new SignedSOAPEnvelope(env, "http://xml-security");
45:
46: System.out
47: .println("\n============= Request ==============");
48: XMLUtils.PrettyElementToStream(env.getAsDOM(), System.out);
49:
50: call.invoke(env);
51:
52: MessageContext mc = call.getMessageContext();
53: System.out
54: .println("\n============= Response ==============");
55: XMLUtils.PrettyElementToStream(mc.getResponseMessage()
56: .getSOAPEnvelope().getAsDOM(), System.out);
57: } catch (Exception e) {
58: e.printStackTrace();
59: }
60: }
61: }
|