aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications/src/main/java/com/juick/components/MPNSClient.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-10-23 12:59:54 +0300
committerGravatar Vitaly Takmazov2017-10-23 13:10:55 +0300
commit93590870e14413f9a10fc3e607b4eb2800c7eda3 (patch)
treecfc552bfdf1c2193927bfec8060bbdc9ecfa2a6d /juick-notifications/src/main/java/com/juick/components/MPNSClient.java
parentbd1af631b03569c99675970403b2047aa3a6f21c (diff)
notifications: mpns encoding
Diffstat (limited to 'juick-notifications/src/main/java/com/juick/components/MPNSClient.java')
-rw-r--r--juick-notifications/src/main/java/com/juick/components/MPNSClient.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/juick-notifications/src/main/java/com/juick/components/MPNSClient.java b/juick-notifications/src/main/java/com/juick/components/MPNSClient.java
index 646c7f93..21286258 100644
--- a/juick-notifications/src/main/java/com/juick/components/MPNSClient.java
+++ b/juick-notifications/src/main/java/com/juick/components/MPNSClient.java
@@ -8,6 +8,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
+import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpClientErrorException;
@@ -17,6 +18,7 @@ import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
/**
@@ -49,6 +51,7 @@ public class MPNSClient {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
wnsService = new RestTemplate();
+ wnsService.getMessageConverters().add(new StringHttpMessageConverter(StandardCharsets.UTF_8));
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(form, httpHeaders);
ResponseEntity<String> response = wnsService.exchange(url, HttpMethod.POST, entity, String.class);
String responseBody = response.getBody();
@@ -67,7 +70,7 @@ public class MPNSClient {
void sendNotification(final String url, final String xml) throws IOException {
HttpHeaders httpHeaders = new HttpHeaders();
- httpHeaders.setContentType(MediaType.TEXT_XML);
+ httpHeaders.setContentType(new MediaType("text", "xml", StandardCharsets.UTF_8));
httpHeaders.set("Authorization", accessToken);
httpHeaders.set("X-WNS-Type", "wns/toast");
HttpEntity<String> requestEntity = new HttpEntity<>(xml, httpHeaders);