我试图向第三方网络服务发出AJAX POST请求。由于我发布到外部资源,因此我使用的是PHP代理,因为我不拥有该服务,无法让它们实现CORS或JSONP。
该服务使用我尝试使用beforesend set request header和ajaxsetup方法在AJAX请求中设置的基本授权。
当我在chrome和firefox的网络选项卡中检查时,我可以在请求中看到Authorization标头集。但是服务器返回500错误并且缺少授权异常。
感谢您的时间 欢呼声。
我已粘贴下面的回复
Apache Tomcat / 7.0.22 - 错误报告
类型异常报告
消息
描述服务器遇到内部错误(),导致服务器无法完成此请求。
异常
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public com.valuescentre.insight.api.model.BasicResponse com.valuescentre.insight.api.controller.PVAWebService.request(java.lang.String,java.lang.String,java.lang.String,com.valuescentre.insight.api.model.PVARequest,javax.servlet.http.HttpServletRequest) throws java.lang.Exception]; nested exception is java.lang.IllegalStateException: Missing header 'Authorization' of type [java.lang.String] org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) javax.servlet.http.HttpServlet.service(HttpServlet.java:641) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
根本原因
org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public com.valuescentre.insight.api.model.BasicResponse com.valuescentre.insight.api.controller.PVAWebService.request(java.lang.String,java.lang.String,java.lang.String,com.valuescentre.insight.api.model.PVARequest,javax.servlet.http.HttpServletRequest) throws java.lang.Exception]; nested exception is java.lang.IllegalStateException: Missing header 'Authorization' of type [java.lang.String] org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:181) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) javax.servlet.http.HttpServlet.service(HttpServlet.java:641) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
根本原因
java.lang.IllegalStateException: Missing header 'Authorization' of type [java.lang.String] org.springframework.web.bind.annotation.support.HandlerMethodInvoker.raiseMissingHeaderException(HandlerMethodInvoker.java:784) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestHeader(HandlerMethodInvoker.java:554) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:343) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) javax.servlet.http.HttpServlet.service(HttpServlet.java:641) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
答案 0 :(得分:0)
我把原因指向我正在使用的proxy.php脚本。我似乎无法找到一个有效的PHP代理脚本。 干杯