01: package org.objectweb.celtix.systest.ws.addressing;
02:
03: import java.net.URL;
04: import java.util.List;
05: import java.util.logging.Level;
06: import java.util.logging.Logger;
07:
08: import javax.xml.ws.Endpoint;
09: import javax.xml.ws.handler.Handler;
10:
11: import org.objectweb.celtix.systest.common.TestServerBase;
12:
13: public class Server extends TestServerBase implements VerificationCache {
14:
15: private String verified;
16:
17: protected void run() {
18: GreeterImpl implementor = new GreeterImpl();
19: implementor.verificationCache = this ;
20: String address = "http://localhost:9008/SoapContext/SoapPort";
21: URL url = getClass().getResource("client.xml");
22: assertNotNull("cannot find test resource", url);
23: String configFileName = url.toString();
24: if (configFileName != null) {
25: System.setProperty("celtix.config.file", configFileName);
26: }
27: Endpoint endpoint = Endpoint.publish(address, implementor);
28: List<Handler> handlerChain = endpoint.getBinding()
29: .getHandlerChain();
30: for (Object h : handlerChain) {
31: if (h instanceof MAPVerifier) {
32: ((MAPVerifier) h).verificationCache = this ;
33: } else if (h instanceof HeaderVerifier) {
34: ((HeaderVerifier) h).verificationCache = this ;
35: }
36: }
37: }
38:
39: public static void main(String[] args) {
40: try {
41: Server s = new Server();
42: s.start();
43: } catch (Exception ex) {
44: ex.printStackTrace();
45: System.exit(-1);
46: } finally {
47: System.out.println("done!");
48: }
49: }
50:
51: public void put(String verification) {
52: if (verification != null) {
53: verified = verified == null ? verification : verified
54: + "; " + verification;
55: }
56: }
57:
58: /**
59: * Used to facilitate assertions on server-side behaviour.
60: *
61: * @param log logger to use for diagnostics if assertions fail
62: * @return true if assertions hold
63: */
64: protected boolean verify(Logger log) {
65: if (verified != null) {
66: log.log(Level.WARNING,
67: "MAP/Header verification failed: {0}", verified);
68: }
69: return verified == null;
70: }
71: }
|