dims 2003/03/06 12:24:21
Modified: java/src/org/apache/axis/transport/http
CommonsHTTPSender.java
Log:
WhiteMesaSoap12AddTestSvcTestCase was failing....Needed to mirror the updates we
made to HTTPSender for SOAP1.2 GET stuff.
Notes:
- With this change i was able to run "ant clean all-tests" with just
CommonsHTTPSender.
Revision Changes Path
1.14 +31 -13
xml-axis/java/src/org/apache/axis/transport/http/CommonsHTTPSender.java
Index: CommonsHTTPSender.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/transport/http/CommonsHTTPSender.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- CommonsHTTPSender.java 6 Mar 2003 18:21:46 -0000 1.13
+++ CommonsHTTPSender.java 6 Mar 2003 20:24:19 -0000 1.14
@@ -58,6 +58,7 @@
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.soap.SOAPConstants;
+import org.apache.axis.soap.SOAP12Constants;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.components.net.TransportClientProperties;
import org.apache.axis.components.net.TransportClientPropertiesFactory;
@@ -71,7 +72,9 @@
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.logging.Log;
import java.io.ByteArrayOutputStream;
@@ -109,7 +112,7 @@
* @throws AxisFault
*/
public void invoke(MessageContext msgContext) throws AxisFault {
- PostMethod method = null;
+ HttpMethodBase method = null;
if (log.isDebugEnabled()) {
log.debug(Messages.getMessage("enter00",
@@ -127,18 +130,31 @@
HostConfiguration hostConfiguration = getHostConfiguration(httpClient,
targetURL);
- method = new PostMethod(targetURL.toString());
+ String webMethod = null;
+ boolean posting = true;
- addContextInfo(method, httpClient, msgContext, targetURL);
+ // If we're SOAP 1.2, allow the web method to be set from the
+ // MessageContext.
+ if (msgContext.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS) {
+ webMethod = msgContext.getStrProp(SOAP12Constants.PROP_WEBMETHOD);
+ if (webMethod != null) {
+ posting = webMethod.equals(HTTPConstants.HEADER_POST);
+ }
+ }
+
Message reqMessage = msgContext.getRequestMessage();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ if(posting) {
+ method = new PostMethod(targetURL.toString());
+ addContextInfo(method, httpClient, msgContext, targetURL);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ reqMessage.writeTo(baos);
+ ((PostMethod)method).setRequestBody(new
ByteArrayInputStream(baos.toByteArray()));
+ ((PostMethod)method).setUseExpectHeader(false); // workaround for
+ } else {
+ method = new GetMethod(targetURL.toString());
+ addContextInfo(method, httpClient, msgContext, targetURL);
+ }
- reqMessage.writeTo(baos);
- method.setRequestBody(new ByteArrayInputStream(baos.toByteArray()));
- method.setUseExpectHeader(false); // workaround for
- // outbound chunking bug
- // in httpclient
-
int returnCode = httpClient.executeMethod(method);
String contentType = null;
String contentLocation = null;
@@ -282,7 +298,7 @@
* @throws Exception
*/
private void addContextInfo(
- PostMethod method, HttpClient httpClient, MessageContext msgContext, URL
tmpURL)
+ HttpMethodBase method, HttpClient httpClient, MessageContext msgContext,
URL tmpURL)
throws Exception {
// optionally set a timeout for the request
@@ -299,8 +315,10 @@
action = "";
}
Message msg = msgContext.getRequestMessage();
- method.setRequestHeader(new Header(HTTPConstants.HEADER_CONTENT_TYPE,
-
msg.getContentType(msgContext.getSOAPConstants())));
+ if (msg != null){
+ method.setRequestHeader(new Header(HTTPConstants.HEADER_CONTENT_TYPE,
+
msg.getContentType(msgContext.getSOAPConstants())));
+ }
method.setRequestHeader(new Header(HTTPConstants.HEADER_SOAP_ACTION, "\"" +
action + "\""));
String userID = msgContext.getUsername();
String passwd = msgContext.getPassword();