Apache camel 如何在基于ApacheCamel的SpringWS-EIP流中获取HttpServletRequest

Apache camel 如何在基于ApacheCamel的SpringWS-EIP流中获取HttpServletRequest,apache-camel,spring-ws,Apache Camel,Spring Ws,我有一个简单的apachecamel EIP流,其中入口点是springws-web服务。如何访问服务请求的HttpServletRequest对象 from("spring-ws:uri:http://localhost:8080/test-ws-1.0/ws/TestService?endpointMapping=#endpointMapping") .log("body is:\n${body}") .process(new HttpRequestParserProcessor()) 我

我有一个简单的apachecamel EIP流,其中入口点是springws-web服务。如何访问服务请求的HttpServletRequest对象

from("spring-ws:uri:http://localhost:8080/test-ws-1.0/ws/TestService?endpointMapping=#endpointMapping")
.log("body is:\n${body}")
.process(new HttpRequestParserProcessor())
我希望能够从HttpRequestParserProcessor中获取请求的用户主体名称和请求的远程IP地址。调试处理器时,Exchange的in对象显示为SpringWebserviceMessage对象

提前感谢,, 下午.

来自:

或者使用CXF而不是Spring WS。CXF和Camel来自同一个厨房,因此可以更好地集成。使用CXF,您可以访问以下
ServletRequest
(请参阅):


对于HTTP组件,这是有效的:
HttpServletRequest-request=exchange.getIn().getBody(HttpServletRequest.class)。也许你可以试一试。嗨@Peter,在我的例子中,主体是一个SpringWebserviceMessage对象,如果我尝试像你建议的那样进行调用,我得到的请求为空。对不起,我之前的评论是错误的。在调试时,exchange.getIn()是SpringWebserviceMessage对象,exchange.getIn().getBody()是DOMSource对象。使用CXF,您可以尝试
org.apache.CXF.message.message cxfMessage=in.getHeader(CxfConstants.CAMEL\u CXF\message,org.apache.CXF.message.message.class)
ServletRequest-request=(ServletRequest)cxfMessage.get(“HTTP.request”),请参阅我为您的问题添加了一个答案,其中包括我找到的SpringWebService解决方案。常量在此类中声明:
org.apache.cxf.transport.http.AbstractHTTPDestination
公共静态最终字符串http\u REQUEST=“http.REQUEST”
TransportContext context = TransportContextHolder.getTransportContext();
HttpServletConnection connection = (HttpServletConnection )context.getConnection();
HttpServletRequest request = connection.getHttpServletRequest();
String ipAddress = request.getRemoteAddr();
org.apache.cxf.message.Message cxfMessage = in.getHeader(CxfConstants.CAMEL_CXF_MESSAGE, org.apache.cxf.message.Message.class);
ServletRequest request = (ServletRequest)cxfMessage.get("HTTP.REQUEST");