转 https://blog.csdn.net/quyan2017/article/details/120779994
feign.RetryableException: null executing POST http://xxx
at feign.FeignException.errorExecuting(FeignException.java:132)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:113)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:78)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
at com.sun.proxy.$Proxy204.closeWaybill(Unknown Source)
at com.zrtl.tms.order.service.impl.OrderServiceImpl.cancelOrder(OrderServiceImpl.java:659)
at com.zrtl.tms.order.service.impl.OrderServiceImpl$$FastClassBySpringCGLIB$$4bb84797.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
@PatchMapping(value = “/{orderNo}”)
使用fegin调用其他微服务 post请求
解决方案1:
请求改为 post
解决方案2:
CXF能够正常接入数据,但是接入后调用微服务内部的feign报错
原因webservice客户端请求时,携带了这个header信息:transfer-encoding:chunked
而springcloud会把请求过来的http header信息转嫁给下一次发生调用的feign中,源码详见feign.SynchronousMethodHandler#targetRequest
这样就需要我们定值一个RequestInterceptor去简化一下header
@Component
@Slf4j
public class FeignRequestInterceptor implements RequestInterceptor {
final static String TRANSFER_ENCODING = "transfer-encoding";
@Override
public void apply(RequestTemplate requestTemplate) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if(attributes==null)
return ;
HttpServletRequest request= attributes.getRequest();
Enumeration<String> headerNames = request.getHeaderNames();
if (headerNames != null) {
while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
String values = request.getHeader(name);
if(isOverLapHeader(requestTemplate,name))
requestTemplate.header(name, values);
}
}
}
//是否允许覆盖requestTemplate中的header
private boolean isOverLapHeader(RequestTemplate requestTemplate,String headerName)
{
Map<String, Collection<String>> headers= requestTemplate.headers();
if(headers==null)
{
return true;
}
if (TRANSFER_ENCODING.equalsIgnoreCase(headerName)) {
return false;
}
return true;
}
这样内部的feign调用时就不会有问题了