1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.test.server;
18
19 import java.io.IOException;
20 import javax.xml.transform.Source;
21
22 import org.springframework.core.io.Resource;
23 import org.springframework.util.Assert;
24 import org.springframework.ws.WebServiceMessage;
25 import org.springframework.ws.WebServiceMessageFactory;
26 import org.springframework.ws.test.support.creator.PayloadMessageCreator;
27 import org.springframework.ws.test.support.creator.SoapEnvelopeMessageCreator;
28 import org.springframework.ws.test.support.creator.WebServiceMessageCreator;
29 import org.springframework.xml.transform.ResourceSource;
30
31
32
33
34
35
36
37
38 public abstract class RequestCreators {
39
40 private RequestCreators() {
41 }
42
43
44
45
46
47
48
49
50
51 public static RequestCreator withPayload(Source payload) {
52 Assert.notNull(payload, "'payload' must not be null");
53 return new WebServiceMessageCreatorAdapter(new PayloadMessageCreator(payload));
54 }
55
56
57
58
59
60
61
62 public static RequestCreator withPayload(Resource payload) throws IOException {
63 Assert.notNull(payload, "'payload' must not be null");
64 return withPayload(new ResourceSource(payload));
65 }
66
67
68
69
70
71
72
73
74
75
76 public static RequestCreator withSoapEnvelope(Source soapEnvelope) {
77 Assert.notNull(soapEnvelope, "'soapEnvelope' must not be null");
78 return new WebServiceMessageCreatorAdapter(new SoapEnvelopeMessageCreator(soapEnvelope));
79 }
80
81
82
83
84
85
86
87
88 public static RequestCreator withSoapEnvelope(Resource soapEnvelope) throws IOException {
89 Assert.notNull(soapEnvelope, "'soapEnvelope' must not be null");
90 return withSoapEnvelope(new ResourceSource(soapEnvelope));
91 }
92
93
94
95
96 private static class WebServiceMessageCreatorAdapter implements RequestCreator {
97
98 private final WebServiceMessageCreator adaptee;
99
100 private WebServiceMessageCreatorAdapter(WebServiceMessageCreator adaptee) {
101 this.adaptee = adaptee;
102 }
103
104 public WebServiceMessage createRequest(WebServiceMessageFactory messageFactory) throws IOException {
105 return adaptee.createMessage(messageFactory);
106 }
107 }
108
109
110 }