Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 855d7b3

Browse files
committed
9_2_HW8_MTOM
1 parent 27522d6 commit 855d7b3

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

services/common-ws/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161
</exclusions>
6262
</dependency>
6363

64+
<dependency>
65+
<groupId>org.jvnet.mimepull</groupId>
66+
<artifactId>mimepull</artifactId>
67+
<version>1.9.7</version>
68+
</dependency>
69+
6470
<dependency>
6571
<groupId>javax.servlet</groupId>
6672
<artifactId>javax.servlet-api</artifactId>

services/common-ws/src/main/java/ru/javaops/masterjava/web/WsClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import javax.xml.namespace.QName;
88
import javax.xml.ws.BindingProvider;
99
import javax.xml.ws.Service;
10+
import javax.xml.ws.WebServiceFeature;
1011
import java.net.URL;
1112
import java.util.Map;
1213

@@ -31,8 +32,8 @@ public void init(String host, String endpointAddress) {
3132
}
3233

3334
// Post is not thread-safe (http://stackoverflow.com/a/10601916/548473)
34-
public T getPort() {
35-
T port = service.getPort(serviceClass);
35+
public T getPort(WebServiceFeature... features) {
36+
T port = service.getPort(serviceClass, features);
3637
BindingProvider bp = (BindingProvider) port;
3738
Map<String, Object> requestContext = bp.getRequestContext();
3839
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);

services/mail-api/src/main/java/ru/javaops/masterjava/service/mail/MailWSClient.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import ru.javaops.masterjava.web.WsClient;
1010

1111
import javax.xml.namespace.QName;
12+
import javax.xml.ws.soap.MTOMFeature;
1213
import java.util.List;
1314
import java.util.Set;
1415

@@ -27,18 +28,22 @@ public class MailWSClient {
2728

2829
public static String sendToGroup(final Set<Addressee> to, final Set<Addressee> cc, final String subject, final String body, List<Attachment> attachments) throws WebStateException {
2930
log.info("Send to group to '" + to + "' cc '" + cc + "' subject '" + subject + (log.isDebugEnabled() ? "\nbody=" + body : ""));
30-
String status = WS_CLIENT.getPort().sendToGroup(to, cc, subject, body, attachments);
31+
String status = getPort().sendToGroup(to, cc, subject, body, attachments);
3132
log.info("Send to group with status: " + status);
3233
return status;
3334
}
3435

3536
public static GroupResult sendBulk(final Set<Addressee> to, final String subject, final String body, List<Attachment> attachments) throws WebStateException {
3637
log.info("Send bulk to '" + to + "' subject '" + subject + (log.isDebugEnabled() ? "\nbody=" + body : ""));
37-
GroupResult result = WS_CLIENT.getPort().sendBulk(to, subject, body, attachments);
38+
GroupResult result = getPort().sendBulk(to, subject, body, attachments);
3839
log.info("Sent bulk with result: " + result);
3940
return result;
4041
}
4142

43+
private static MailService getPort() {
44+
return WS_CLIENT.getPort(new MTOMFeature(1024));
45+
}
46+
4247
public static Set<Addressee> split(String addressees) {
4348
Iterable<String> split = Splitter.on(',').trimResults().omitEmptyStrings().split(addressees);
4449
return ImmutableSet.copyOf(Iterables.transform(split, Addressee::new));

services/mail-service/src/main/java/ru/javaops/masterjava/service/mail/MailServiceImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import ru.javaops.masterjava.web.WebStateException;
44

55
import javax.jws.WebService;
6+
import javax.xml.ws.soap.MTOM;
67
import java.util.List;
78
import java.util.Set;
89

910
@WebService(endpointInterface = "ru.javaops.masterjava.service.mail.MailService", targetNamespace = "http://mail.javaops.ru/"
1011
// , wsdlLocation = "WEB-INF/wsdl/mailService.wsdl"
1112
)
13+
//@StreamingAttachment(parseEagerly=true, memoryThreshold=40000L)
14+
@MTOM
1215
public class MailServiceImpl implements MailService {
1316
public String sendToGroup(Set<Addressee> to, Set<Addressee> cc, String subject, String body, List<Attachment> attachments) throws WebStateException {
1417
return MailSender.sendToGroup(to, cc, subject, body);

0 commit comments

Comments
 (0)