0
を投げ、私はWebサービスからXMLを取得しようとしたが、それはコードの下に実行した後InvalidMediaTypeExceptionを投げています:春RestTemplate私は春の休憩に新しいですInvalidMediaTypeException
restTemplate.getForObject("http://www.dictionaryapi.com/api/v1/references/learners/xml/{word}?key={key}",String.class,uriVariables);
Webサービスは、XMLドキュメントを返す、と私は思いましたまず問題があるかもしれないが、別のWebService(urlにはパスとして 'xml'が含まれていない)がうまく動作する。
スタックトレース:
Exception in thread "main" org.springframework.http.InvalidMediaTypeException: Invalid mime type "xml": does not contain '/'
at org.springframework.http.MediaType.parseMediaType(MediaType.java:385)
at org.springframework.http.HttpHeaders.getContentType(HttpHeaders.java:722)
at org.springframework.web.client.HttpMessageConverterExtractor.getContentType(HttpMessageConverterExtractor.java:114)
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:85)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:835)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:819)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:599)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:384)
それでは、どのように私は彼らのURLパスに単語 "XML" が含まれているWebサービスとデータを交換することができます。
私は思っていますが、私は間違っているかもしれません、あなたが得るスタックはURIの "xml"によって引き起こされない、我々は "webService"メソッドを見ることができますか? –
突然、サードパーティのWebServiceなので、http://www.dictionaryapi.com/api/v1/references/learners/xml/apple?key=4d0a2da0-791e-4616-986f-2b26da530f04でリクエストを行うと、私はこの結果を受け取ります。例えば、 "http://www.thomas-bayer.com/sqlrest/CUSTOMER/"のリクエストは有効です。 –
URLパラメータのxmlはここでは問題にはならないかもしれません。 uri変数で渡すサービスやデータに問題があるはずです – Nimesh