|
From: <dgl...@us...> - 2003-08-07 04:21:47
|
Update of /cvsroot/babeldoc/babeldoc/modules/soap/src/com/babeldoc/soap/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv21166/modules/soap/src/com/babeldoc/soap/pipeline/stage
Modified Files:
SoapWriterPipelineStage.java
Log Message:
The SOAP response is now returned if responseDoc is true in the config.properties file.
Index: SoapWriterPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/soap/src/com/babeldoc/soap/pipeline/stage/SoapWriterPipelineStage.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** SoapWriterPipelineStage.java 27 Jun 2003 00:35:46 -0000 1.10
--- SoapWriterPipelineStage.java 7 Aug 2003 04:21:44 -0000 1.11
***************
*** 74,79 ****
--- 74,81 ----
import com.babeldoc.soap.pipeline.util.SoapHelper;
+ import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collection;
+ import java.util.Iterator;
import javax.xml.messaging.URLEndpoint;
***************
*** 88,94 ****
*/
public class SoapWriterPipelineStage extends PipelineStage {
! public static final String SOAP_URL = "soapUrl";
! public static final String SOAP_ACTION = "soapAction";
public static final String RESULT_STAGE = "resultStage";
/**
--- 90,97 ----
*/
public class SoapWriterPipelineStage extends PipelineStage {
! public static final String SOAP_URL = "soapUrl";
! public static final String SOAP_ACTION = "soapAction";
public static final String RESULT_STAGE = "resultStage";
+ public static final String RESPONSE_DOC = "responseDoc";
/**
***************
*** 115,118 ****
--- 118,125 ----
options.add(new ConfigOption(RESULT_STAGE, IConfigOptionType.STRING,
null, true, I18n.get("soap.103")));
+ options.add(new ConfigOption(RESULT_STAGE, IConfigOptionType.STRING,
+ null, true, I18n.get("soap.103")));
+ options.add(new ConfigOption(RESPONSE_DOC, IConfigOptionType.BOOLEAN,
+ null, false, I18n.get("soap.106")));
return options;
***************
*** 133,137 ****
*/
public static String sendSoapMessage(String soapUrl, String soapAction,
! PipelineDocument document) throws Exception {
// create a message
MessageFactory mf = MessageFactory.newInstance();
--- 140,144 ----
*/
public static String sendSoapMessage(String soapUrl, String soapAction,
! boolean returnResponse, PipelineDocument document) throws Exception {
// create a message
MessageFactory mf = MessageFactory.newInstance();
***************
*** 156,164 ****
connection.close();
! // TODO process the reply
! // if (SoapHelper.containsFault(reply)) {
! // throw new Exception("soapFault")
! // }
! return null;
}
--- 163,177 ----
connection.close();
! // either return the response, or else return null to default to previous behavior
! String retv = null; // assume the default
! if (returnResponse) {
!
! // convert the reply into a document
! ByteArrayOutputStream bs = new ByteArrayOutputStream();
! reply.writeTo(bs);
! retv = bs.toString();
! }
!
! return retv;
}
***************
*** 173,184 ****
String soapUrl = getOptions(SOAP_URL);
String soapAction = getOptions(SOAP_ACTION);
!
try {
! sendSoapMessage(soapUrl, soapAction, this.getDocument());
} catch (Exception e) {
throw new PipelineException(I18n.get("soap.104"), e);
}
! return super.processHelper();
}
}
--- 186,209 ----
String soapUrl = getOptions(SOAP_URL);
String soapAction = getOptions(SOAP_ACTION);
! String responseDoc = getOptions(RESPONSE_DOC);
! boolean returnResponse = Boolean.valueOf(responseDoc).booleanValue();
! String response = null;
try {
! response = sendSoapMessage(soapUrl, soapAction, returnResponse, this.getDocument());
} catch (Exception e) {
throw new PipelineException(I18n.get("soap.104"), e);
}
! if (returnResponse) {
! try {
! return super.processHelper("text/xml", new String[] {response});
! }
! catch (Exception e) {
! throw new com.babeldoc.core.pipeline.PipelineException("SOAPWriter", e);
! }
! }
! else {
! return super.processHelper();
! }
}
}
|