aboutsummaryrefslogtreecommitdiff
path: root/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker
diff options
context:
space:
mode:
authorgregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2006-06-26 14:50:59 +0000
committergregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2006-06-26 14:50:59 +0000
commite06e1534392fadfd84c84fb403be56fa9c852fdb (patch)
tree8a924d4f5a5080dec1bd4e5d4ab53e0e8f6184f7 /spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker
parenta8c6c5e86da29a1e17d73f672b95bf58e8aa6de0 (diff)
downloadmoa-id-spss-e06e1534392fadfd84c84fb403be56fa9c852fdb.tar.gz
moa-id-spss-e06e1534392fadfd84c84fb403be56fa9c852fdb.tar.bz2
moa-id-spss-e06e1534392fadfd84c84fb403be56fa9c852fdb.zip
Verzeichnis verschoben nach /src
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@714 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker')
-rw-r--r--spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java92
1 files changed, 92 insertions, 0 deletions
diff --git a/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java
new file mode 100644
index 000000000..e89d255f0
--- /dev/null
+++ b/spss.slinterface/src/at/gv/egovernment/moa/spss/slinterface/moainvoker/MOAInvoker.java
@@ -0,0 +1,92 @@
+/*
+ * Created on 19.11.2003
+ *
+ * (c) Stabsstelle IKT-Strategie des Bundes
+ */
+package at.gv.egovernment.moa.spss.slinterface.moainvoker;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.rmi.RemoteException;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+import javax.xml.rpc.Call;
+import javax.xml.rpc.Service;
+import javax.xml.rpc.ServiceException;
+import javax.xml.rpc.ServiceFactory;
+
+import org.apache.axis.message.SOAPBodyElement;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.Document;
+
+import at.gv.egovernment.moa.spss.slinterface.Constants;
+
+/**
+ * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at)
+ */
+public class MOAInvoker
+{
+ /**
+ * Invokes MOA SP.
+ *
+ * @param request The XML request to be sent to MOA SP.
+ *
+ * @param endpoint The endpoint of the SOAP service where to send the XML request to.
+ *
+ * @return the XML response from the service.
+ *
+ * @throws Exception if getting the XML response from the SOAP response body fails.
+ *
+ * @throws RemoteException if MOA SP signals an error.
+ *
+ * @throws ServiceException if the SOAP client invoking MOA SP signals an error.
+ */
+ public static Document invokeSP(Document request, String endpoint)
+ throws Exception, RemoteException, ServiceException
+ {
+ QName serviceQName = new QName(Constants.MI_SP_QNAME_);
+ return invoke(request, endpoint, serviceQName);
+ }
+
+ /* ---------------------------------------------------------------------------------------------------- */
+
+ private static Document invoke(Document request, String endpoint, QName serviceQName) throws Exception
+ {
+ // Instantiate AXIS service
+ Service service = ServiceFactory.newInstance().createService(serviceQName);
+
+ // Create and configure service call
+ Call call = service.createCall();
+ call.setTargetEndpointAddress(endpoint);
+
+ // Create SOAP body
+ SOAPBodyElement body = new SOAPBodyElement(request.getDocumentElement());
+ SOAPBodyElement[] params = new SOAPBodyElement[] {body};
+
+ // Make call
+ Vector responses = (Vector) call.invoke(params);
+
+ // Get response
+ SOAPBodyElement responseBody = (SOAPBodyElement) responses.get(0);
+ Document response = responseBody.getAsDocument();
+ return response;
+ }
+
+ /* ---------------------------------------------------------------------------------------------------- */
+
+ public static void serializeDocument(Document doc, OutputStream out) throws IOException
+ {
+ OutputFormat format = new OutputFormat(doc);
+
+ format.setLineSeparator("\n");
+ format.setIndenting(false);
+ format.setPreserveSpace(true);
+ format.setOmitXMLDeclaration(false);
+ format.setEncoding("UTF-8");
+
+ XMLSerializer serializer = new XMLSerializer(out, format);
+ serializer.serialize(doc);
+ }
+}