Skip to content

Commit

Permalink
*) avoid reading of content body into memory
Browse files Browse the repository at this point in the history
*) Bugfix for soap attachment support

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2854 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
theli committed Oct 24, 2006
1 parent 88cfdec commit 4d1f933
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions source/de/anomic/soap/httpdSoapHandler.java
Expand Up @@ -85,6 +85,7 @@
import de.anomic.http.httpc;
import de.anomic.http.httpdAbstractHandler;
import de.anomic.http.httpdHandler;
import de.anomic.plasma.plasmaParser;
import de.anomic.server.serverClassLoader;
import de.anomic.server.serverCore;
import de.anomic.server.serverFileUtils;
Expand Down Expand Up @@ -196,13 +197,16 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http
*/
static {
// create an Axis server
serverLog.logInfo("SOAP","Init soap engine ...");
engine = new AxisServer();

// setting some options ...
engine.setShouldSaveConfig(false);

serverLog.logInfo("SOAP","Deploying default services ...");
for (int i=0; i < defaultServices.length; i++) {
String[] nextService = defaultServices[i].split("=");
serverLog.logInfo("SOAP","Deploying service " + nextService[0] + ":" + nextService[1]);
String deploymentStr = serviceDeploymentString
.replaceAll("@serviceName@", nextService[0])
.replaceAll("@className@", nextService[1]);
Expand Down Expand Up @@ -281,18 +285,6 @@ public httpdSoapHandler(serverSwitch switchboard) {
}
}

private byte[] readRequestBody(httpHeader requestHeader, PushbackInputStream body) throws SoapException {
try {
// getting an input stream to handle transfer encoding and content encoding properly
InputStream soapInput = getBodyInputStream(requestHeader, body);

// read the content
return serverFileUtils.read(soapInput);
} catch (IOException e) {
throw new SoapException(500,"Read error",e.getMessage());
}
}

private InputStream getBodyInputStream(httpHeader requestHeader, PushbackInputStream body) throws SoapException{
InputStream input;

Expand Down Expand Up @@ -446,16 +438,17 @@ public void doPost(Properties conProp, httpHeader requestHeader, OutputStream re
* GENERATE REQUEST MESSAGE
* ======================================================================== */
// read the request message
byte[] buffer = readRequestBody(requestHeader, body);
InputStream bodyStream = getBodyInputStream(requestHeader, body);

// generating the SOAP message context that will be passed over to the invoked service
MessageContext msgContext = this.generateMessageContext(path, requestHeader, conProp);

// Generating a SOAP Request Message Object
String mime = plasmaParser.getRealMimeType(requestHeader.mime()); // this is important !!!!
Message requestMsg = new Message(
buffer,
bodyStream,
false,
requestHeader.mime(),
mime,
(String)requestHeader.get(httpHeader.CONTENT_LOCATION)
);
msgContext.setRequestMessage(requestMsg);
Expand Down Expand Up @@ -713,7 +706,7 @@ protected void sendMessage(OutputStream out, int statusCode, String statusText,
// getting the content type
String contentType = null;
try {
contentType = soapMessage.getContentType(soapMessage.getMessageContext().getSOAPConstants());
contentType = soapMessage.getContentType(soapMessage.getMessageContext().getSOAPConstants());
} catch (AxisFault e) {
throw new SoapException(500,"Unable to get content-type for SOAP message",e.getMessage());
}
Expand Down

0 comments on commit 4d1f933

Please sign in to comment.