forward SOAP request

Hi!

I need to forward a SOAP request from a a servlet to a web service, I do it using response.sendRedirect but I notice that the header information is being moidfied thus preventing the service from answering properly, why is that? How should I do it?

Thanks,

A.

Servlet request

HEADER NAME user-agent

HEADER VALUE BEA WLW 8.1

HEADER NAME content-type

HEADER VALUE text/xml; charset=UTF-8

HEADER NAME soapaction

HEADER VALUE ""

HEADER NAME accept

HEADER VALUE application/soap+xml, text/xml, application/xml, */*

HEADER NAME host

HEADER VALUE localhost:8080

HEADER NAME connection

HEADER VALUE Keep-Alive

HEADER NAME content-length

HEADER VALUE 494

QUERY STRING null

CONTENT TYPE text/xml; charset=UTF-8

after forwarding to another servlet or web service

EADER NAME user-agent

HEADER VALUE Java1.4.2_05

HEADER NAME host

HEADER VALUE localhost:8080

HEADER NAME accept

HEADER VALUE text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

HEADER NAME connection

HEADER VALUE Keep-Alive

QUERY STRING null

CONTENT TYPE null

[1209 byte] By [iggya] at [2007-11-27 8:09:16]
# 1
Because a redirect creates a *new* request. So it is only logical that the headers are changed.If you do not want to change the request, you need to do a forward.
gimbal2a at 2007-7-12 19:52:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
how would I do that?
iggya at 2007-7-12 19:52:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
I can't useRequestDispatcher rd;rd = getServletContext().getRequestDispatcher("pathToServlet");rd.forward(req, res);since the service is on another machine.
iggya at 2007-7-12 19:52:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

You are right, you are not going to forward to a different machine or a different context even, because it is not possible, and a redirect also does not work because this creates a new request.

So, two options that I see:

1. can't you call the webservice from your servlet using jax-ws and let the servlet generate a proper response?

2. why do you need a servlet to forward the request to a webservice? Can't the resource that is calling the servlet call the webservice directly?

gimbal2a at 2007-7-12 19:52:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

hi again,

yes, I could let the servlet call the web service but then I need to parse the request in order to get the SOAP message and then build th new request, then I need to get the reply and transform it and return it to the caller... seems a lot of work.

What I am trying to do is a sort of primitive ESB, all calls to services have to go via the servlet, that will be logging information like caller, method, parameters etc and then forward the request to the right service.

Maybe ther is a better way but I can't think of one...

Thanks,

A.

iggya at 2007-7-12 19:52:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...