IntelliJ 2017.1.2の2つのインスタンスから2つのサービスをデバッグしています。サービスAは、サービスBにjson要求を送信します。どちらのサービスも、REST呼び出しを使用するSpring-Bootです。Intellijを実行中にJSON応答/要求を表示
サービスAはポストを行います(私は経由を確認している
@RequestMapping(value = "/office/{officeId}/invoice", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity createInvoice(@RequestBody InvoiceRequest invoiceRequest, @PathVariable("officeId") long officeId) {
...}
しかし、私は、要求をインターセプトJWTフィルタを取得し、正常に処理された:
ResponseEntity<InvoiceResponse> response =
restTemplate.postForEntity(invoiceUrl, request, InvoiceResponse.class);
サービスBは、エンドポイントを持っていましたブレークポイント):
public class JwtAuthenticationTokenFilter extends GenericFilterBean {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String authToken = httpRequest.getHeader(this.tokenHeader);
String username = jwtTokenUtil.getUsernameFromToken(authToken);
if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
UserDetails userDetails = this.userDetailsService.loadUserByUsername(username);
if (jwtTokenUtil.validateToken(authToken, userDetails)) {
UsernamePasswordAuthenticationToken
authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpRequest));
SecurityContextHolder.getContext().setAuthentication(authentication);
}
}
chain.doFilter(request, response);
}
これはログにエラーが表示されないため、正常に終了しているようです。
文書を読み取れませんでした:認識されないトークンが「行方不明」:しかし、IntelliJのでのサービスAは、メッセージが表示さ のjava:[ソースで (「真」、「偽」または「ヌル」)期待していました。 [email protected];[Missing]:期待していた( 'true'、 'false'、または 'null')。 PushbackInputStream @ 7d005eb;行:1、列:9]
私はスタックトレースを持たず、コードをステップ実行することで問題が表示されません。私は、JSONがサービスBの出入りを調べる方法を見つけようとしているので、使用されているものがジャクソンに問題を引き起こしているように見えます。 IntelliJでこれを表示するにはどうしますか? JSONがサービスAから送信されるようにすることができれば、私はPostmanからの呼び出しを再作成することができますが、実際のJSONをサービスAからも追跡することはできません。
それが重要ならば、私はUPDATE
OS X上で春のブート1.3.5とJava 8を使用しています: :
私はパトリック・ベイの提案あたりのサービスAに以下を追加しました
@Bean
public CommonsRequestLoggingFilter requestLoggingFilter() {
CommonsRequestLoggingFilter loggingFilter = new CommonsRequestLoggingFilter();
loggingFilter.setIncludeClientInfo(true);
loggingFilter.setIncludeQueryString(true);
loggingFilter.setIncludePayload(true);
return loggingFilter;
}
しかし、私はまだ私は私の要求と間違っているものを見るのを助けるために、任意のJSONが表示されない:
DEBUG 74188 --- [nio-8081-exec-3] osweb.client.RestTemplate
[application/json; charset = UTF-8] として[[email protected]] [org.springfr[email protected]610fefeb] DEBUG 74188 --- [NIO-8081-EXEC-3] osweb.client.RestTemplate
使用: "http://localhost:8998/office/1/invoice" のPOST要求するで をもたらし200(null)DEBUG 74188 --- [nio-8081-exec-3] osweb.client.RestTemplate: [org。 springfr[email protected]610fefeb] ERROR 74188 --- [nio-8081-exec-3] c.finance。コネクタ: 読取原稿ませんでした:認識されないトークン「行方不明」:
( 「偽」または「ヌル」、「真」)期待していた私も自分のサービスB JwtAuthenticationTokenFilterでのHttpRequestを検査しようとしました。私はそれを介してナビゲートしようとしましたが、私は実際に送信しているボディが表示されません。要求に正しいURLが表示されますが、フィルタBが成功すると、サービスBが爆発するので実際のエンドポイント( "/ office/1/invoice")には到達しません。
。 –
また、この質問をチェックアウトする価値があるhttps://stackoverflow.com/questions/7952154/spring-resttemplate-how-to-enable-full-debugging-logging-of-requests-responses –
これは実際に私にjsonを表示しません要求または応答。ジャクソンのマッピングが間違っているのがわかります。 – sonoerin