aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications
diff options
context:
space:
mode:
Diffstat (limited to 'juick-notifications')
-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);