You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/07/14 18:49:19 UTC
svn commit: r219060 - in /webservices/axis/trunk/java/modules:
core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
xml/src/org/apache/axis2/om/impl/MIMEOutputUtils.java
xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
Author: dims
Date: Thu Jul 14 09:49:17 2005
New Revision: 219060
URL: http://svn.apache.org/viewcvs?rev=219060&view=rev
Log:
- Trying to get MTOM interop working with WSE 3.0
- Fix a few typos in code introduced by me
Modified:
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/MIMEOutputUtils.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=219060&r1=219059&r2=219060&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Thu Jul 14 09:49:17 2005
@@ -52,7 +52,7 @@
TransportSender {
private boolean chuncked = false;
- private String httpVersion = HTTPConstants.HEADER_PROTOCOL_10;
+ private String httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
public static final String HTTP_METHOD = "HTTP_METHOD";
@@ -117,11 +117,14 @@
throws AxisFault {
try {
URL url = new URL(toURL.getAddress());
- //Configure the transport
- String soapAction = msgContext.getWSAAction();
- //settign soapAction
- String soapActionString = soapAction == null ? "" : soapAction.toString();
+ String soapActionString = msgContext.getSoapAction();
+ if (soapActionString == null || soapActionString.length() == 0) {
+ soapActionString = msgContext.getWSAAction();
+ }
+ if (soapActionString == null) {
+ soapActionString = "";
+ }
//supporting RESTFacility..
if (!msgContext.isDoingREST()) {
@@ -275,6 +278,12 @@
private void transportConfigurationPOST(MessageContext msgContext,
OMElement dataout, URL url, String soapActionString) throws MalformedURLException, AxisFault, IOException {
+
+ //execuite the HtttpMethodBase - a connection manager can be given for handle multiple
+ httpClient = new HttpClient();
+ //hostConfig handles the socket functions..
+ HostConfiguration hostConfig = getHostConfiguration(msgContext, url);
+
PostMethod postMethod = new PostMethod();
postMethod.setPath(url.getFile());
msgContext.setProperty(HTTP_METHOD, postMethod);
@@ -282,19 +291,19 @@
if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chuncked) {
((PostMethod) postMethod).setContentChunked(true);
}
-
- postMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
- "text/xml; charset=utf-8");
- postMethod.setRequestHeader(HTTPConstants.HEADER_ACCEPT,
- HTTPConstants.HEADER_ACCEPT_APPL_SOAP
- + HTTPConstants.HEADER_ACCEPT_APPLICATION_DIME
- + HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED
- + HTTPConstants.HEADER_ACCEPT_TEXT_ALL);
+ postMethod.setRequestHeader(HTTPConstants.HEADER_USER_AGENT,
+ "Axis/2.0");
+ if (!msgContext.isDoingREST()) {
+ postMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION, soapActionString);
+ }
postMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());
- postMethod.setRequestHeader(HTTPConstants.HEADER_CACHE_CONTROL, "no-cache");
- postMethod.setRequestHeader(HTTPConstants.HEADER_PRAGMA, "no-cache");
- //content length is not set yet
- //setting HTTP vesion
+ if(msgContext.isDoingMTOM()) {
+ postMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
+ omOutput.getOptimizedContentType());
+ } else {
+ postMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
+ "text/xml; charset=utf-8");
+ }
if (httpVersion != null) {
if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
@@ -306,19 +315,10 @@
// allowing keep-alive for 1.1
postMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION,
HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
+ postMethod.setRequestHeader(HTTPConstants.HEADER_EXPECT,
+ HTTPConstants.HEADER_EXPECT_100_Continue);
}
}
- // othervise assumes HTTP 1.1 and keep-alive is default.
- if (!msgContext.isDoingREST()) {
- postMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION, soapActionString);
- }
-
- //execuite the HtttpMethodBase - a connection manager can be given for handle multiple
- httpClient = new HttpClient();
- //hostConfig handles the socket functions..
- HostConfiguration hostConfig = getHostConfiguration(msgContext, url);
-
- //code that wirte the stream to the wire
this.httpClient.executeMethod(hostConfig, postMethod);
if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/MIMEOutputUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/MIMEOutputUtils.java?rev=219060&r1=219059&r2=219060&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/MIMEOutputUtils.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/MIMEOutputUtils.java Thu Jul 14 09:49:17 2005
@@ -47,14 +47,11 @@
"text/xml");
MimeBodyPart rootMimeBodyPart = new MimeBodyPart();
rootMimeBodyPart.setDataHandler(dh);
- ContentType partContentType = new ContentType(
- "application/xop+xml");
- partContentType.setParameter("charset", "UTF-8");
- partContentType.setParameter("type", "application/soap+xml");
- rootMimeBodyPart.addHeader("Content-Type",
- partContentType.toString());
- rootMimeBodyPart.addHeader("Content-Transfer-Encoding", "8bit");
- rootMimeBodyPart.addHeader("Content-ID", contentId);
+
+ rootMimeBodyPart.addHeader("content-type",
+ "application/xop+xml; charset=utf-8; type=\"text/xml; charset=utf-8\"");
+ rootMimeBodyPart.addHeader("content-transfer-encoding", "binary");
+ rootMimeBodyPart.addHeader("content-id", contentId);
writeBodyPart(outStream, rootMimeBodyPart, boundary);
@@ -76,8 +73,9 @@
throws MessagingException {
MimeBodyPart mimeBodyPart = new MimeBodyPart();
mimeBodyPart.setDataHandler(node.getDataHandler());
- mimeBodyPart.addHeader("Content-Transfer-Encoding", "binary");
- mimeBodyPart.addHeader("Content-ID", node.getContentID());
+ mimeBodyPart.addHeader("content-transfer-encoding", "binary");
+ mimeBodyPart.addHeader("content-type", "application/octet-stream");
+ mimeBodyPart.addHeader("content-id", node.getContentID());
return mimeBodyPart;
}
@@ -127,16 +125,18 @@
}
public static String getContentTypeForMime(String boundary, String contentId) {
- ContentType contentType = new ContentType();
- contentType.setPrimaryType("multipart");
- contentType.setSubType("related");
- contentType.setParameter("boundary", boundary);
- contentType.setParameter("start", contentId);
- contentType.setParameter("type", "application/xop+xml");
- //TODO theres something called action that can be set with
- // following. May be SOAPAction. Better check.
- contentType.setParameter("start-info", "application/soap+xml");
- return contentType.toString();
+ StringBuffer sb = new StringBuffer();
+ sb.append("multipart/related");
+ sb.append("; ");
+ sb.append("boundary=");
+ sb.append(boundary);
+ sb.append("; ");
+ sb.append("type=\"application/xop+xml\"");
+ sb.append("; ");
+ sb.append("start=\"" + contentId + "\"");
+ sb.append("; ");
+ sb.append("start-info=\"text/xml; charset=utf-8\"");
+ return sb.toString();
}
/**
@@ -178,6 +178,6 @@
int begin = myRand.nextInt();
if(begin < 0) begin = begin * -1;
begin = begin % 8;
- return new String("--" + sb2.toString().substring(begin, begin + 18)).toUpperCase();
+ return new String(sb2.toString().substring(begin, begin + 18)).toUpperCase();
}
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java?rev=219060&r1=219059&r2=219060&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java Thu Jul 14 09:49:17 2005
@@ -103,20 +103,21 @@
}
public String getMimeBoundary() {
- if(mimeBoundary != null) {
+ if(mimeBoundary == null) {
mimeBoundary = "--MIMEBoundary" + MIMEOutputUtils.getRandomStringOf18Characters();
}
return mimeBoundary;
}
public String getRootContentId() {
- if(rootContentId != null) {
+ if(rootContentId == null) {
rootContentId = "cid:0." + MIMEOutputUtils.getRandomStringOf18Characters() + "@apache.org";
}
return rootContentId;
}
public String getNextContentId() {
+ nextid++;
return "cid:" + nextid + "." + MIMEOutputUtils.getRandomStringOf18Characters() + "@apache.org";
}
}