diff options
author | Vitaly Takmazov | 2017-10-23 12:59:54 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-23 13:10:55 +0300 |
commit | 93590870e14413f9a10fc3e607b4eb2800c7eda3 (patch) | |
tree | cfc552bfdf1c2193927bfec8060bbdc9ecfa2a6d | |
parent | bd1af631b03569c99675970403b2047aa3a6f21c (diff) |
notifications: mpns encoding
-rw-r--r-- | juick-notifications/src/main/java/com/juick/components/MPNSClient.java | 5 |
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); |