/**
* Create and return a new HttpPost request to the destination EPR
* @return the HttpRequest to be sent out
*/
public HttpRequest getRequest() throws IOException {
HttpEntityEnclosingRequest httpRequest = new BasicHttpEntityEnclosingRequest(
"POST",
epr.getAddress());
httpRequest.setEntity(new BasicHttpEntity());
// set any transport headers
Object o = msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (o != null && o instanceof Map) {
Map headers = (Map) o;
Iterator iter = headers.keySet().iterator();
while (iter.hasNext()) {
Object header = iter.next();
Object value = headers.get(header);
if (header instanceof String && value != null && value instanceof String) {
httpRequest.setHeader((String) header, (String) value);
}
}
}
// if the message is SOAP 11 (for which a SOAPAction is *required*), and
// the msg context has a SOAPAction or a WSA-Action (give pref to SOAPAction)
// use that over any transport header that may be available
String soapAction = msgContext.getSoapAction();
if (soapAction == null) {
soapAction = msgContext.getWSAAction();
}
if (soapAction == null) {
msgContext.getAxisOperation().getSoapAction();
}
if (msgContext.isSOAP11() && soapAction != null &&
soapAction.length() > 0) {
Header existingHeader =
httpRequest.getFirstHeader(HTTPConstants.HEADER_SOAP_ACTION);
if (existingHeader != null) {
httpRequest.removeHeader(existingHeader);
}
httpRequest.setHeader(HTTPConstants.HEADER_SOAP_ACTION,
soapAction);
}
httpRequest.setHeader(
HTTP.CONTENT_TYPE,
messageFormatter.getContentType(msgContext, format, msgContext.getSoapAction()));
return httpRequest;
}