Hi,
I am using CXF 2.4.0 in a Tomcat 7.0.14 container.
I have it set up to do both JAX-WS and JAX-RS. I am using a beans.xml to
register the serivices:
beans.xml snippit:
<jaxrs:server id="goldenKey_rest" address="/rest">
<jaxrs:serviceBeans>
<ref bean="goldenKey_bean" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="dateProvider" />
<ref bean="exceptionMapper" />
</jaxrs:providers>
</jaxrs:server>
<jaxws:endpoint xmlns:s="http://com.upmc.tdc.server"
serviceName="s:GoldenKey"
endpointName="s:GoldenKeyPort"
id="goldenKey_soap"
implementor="#goldenKey_bean"
address="/soap" />
I am trying to capture the client ip address for both REST and SOAP. It
works perfectly with REST but not SOAP.
here is the code that i am using to get the HttpServletReqeust object (this
is in my service implementation class):
@Resource
private HttpServletRequest request = null;
@Resource
public void setContext(WebServiceContext context) {
if (context != null && context.getMessageContext() != null &&
context.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST) !=
null) {
this.request = (HttpServletRequest)
context.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
}
}
As i said, REST works great. But when i try to use SOAP the request object
returns null as soon as i do a getRemoteAddr().
The soap request it being submitted using Apache HttpClient.
here is some CXF output about the request:
INFO: Inbound Message
----------------------------
ID: 1
Address: http://localhost:8080/GoldenKey/svc/soap
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml; charset=utf-8
Headers: {connection=[Keep-Alive], Content-Length=[387],
content-type=[text/xml; charset=utf-8], host=[localhost:8080],
user-agent=[Apache-HttpClient/4.1 (java 1.5)], x-forwarded-for=[This is my
ip address: 127.0.0.1]}
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getAddressTypes
xmlns:ns2="http://com.upmc.tdc.server"><ns2:Application><applicationId>2a24907c-59c2-4415-b944-a5d1148544d1</applicationId></ns2:Application><ns2:User><username>myerscb</username></ns2:User><ns2:DataSourceType>EPCD</ns2:DataSourceType></ns2:getAddressTypes></soap:Body></soap:Envelope>
--------------------------------------
it certainly looks like the headers are there, even one that I inserted
(x-forwarded-for). But, when I attempt to try and access the headers
through the request object, i get a null pointer exception.
I am wondering what i am missing? is there a different way to get header
information for a soap request?
Thanks for your help,
Chris
--
View this message in context:
http://cxf.547215.n5.nabble.com/Getting-the-IP-Address-of-SOAP-Clients-works-for-REST-clients-but-not-for-SOAP-clients-tp4476334p4476334.html
Sent from the cxf-user mailing list archive at Nabble.com.