source: main/trunk/greenstone3/resources/java/SOAPServer.java.in@ 31977

Last change on this file since 31977 was 31977, checked in by kjdon, 7 years ago

noteToElement is in GSXML

  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/*
2 * SOAPServer.java.in: a template for a new SOAPServer
3 * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20package org.greenstone.gsdl3;
21
22import org.greenstone.util.GlobalProperties;
23import org.greenstone.gsdl3.core.MessageRouter;
24import org.greenstone.gsdl3.util.GSFile;
25import org.greenstone.gsdl3.util.GSXML;
26import org.greenstone.gsdl3.util.XMLConverter;
27import org.w3c.dom.Element;
28import org.w3c.dom.Node;
29import java.io.File;
30
31/**
32 * The server side of a SOAP connection
33 *
34 * @see <a href="http://www.w3.org/TR/SOAP/">Simple Object Access Protocol (SOAP) 1.1 </a>
35 */
36
37public class SOAPServer@sitename@
38{
39
40 /** The message router we're talking to */
41 protected MessageRouter mr=null;
42 /** the name of the site we are serving */
43 protected String site_name = "@sitename@";
44
45 /** The no-args constructor */
46 public SOAPServer@sitename@() {
47 String gsdl3_home = GlobalProperties.getGSDL3Home();
48 if (gsdl3_home == null || gsdl3_home.equals("")) {
49 System.err.println("Couldn't access GSDL3Home from GlobalProerties.getGSDL3HOME, can't initialize the SOAP Server.");
50 return;
51 }
52 String site_home = GSFile.siteHome(gsdl3_home, this.site_name);
53
54 File site_file = new File(site_home);
55 if (!site_file.isDirectory()) {
56 System.err.println("The site directory "+site_file.getPath()+" doesn't exist. Can't initialize the SOAP Server.");
57 return;
58 }
59 mr = new MessageRouter();
60 mr.setSiteName(this.site_name);
61 mr.configure();
62 }
63
64
65 public Element [] process (Element [] xml_in) {
66 Element [] result = new Element[xml_in.length];
67 for (int i=0; i<xml_in.length; i++) {
68 Element req = xml_in[i];
69 // get rid of the obligatory namespace that axis needs
70 String tag_name = req.getTagName();
71 String namespace="";
72 if (tag_name.indexOf(':')!= -1) {
73 namespace = tag_name.substring(0, tag_name.indexOf(':'));
74 tag_name = tag_name.substring(tag_name.indexOf(':')+1);
75 }
76 Element new_req = GSXML.duplicateWithNewName(req.getOwnerDocument(), req, tag_name, true);
77 Node n = mr.process(new_req);
78 Element r = GSXML.nodeToElement(n);
79 // add the namespace back on
80 //Element new_res = r;
81 //if (!namespace.equals("")) {
82 // new_res = GSXML.duplicateWithNewName(r.getOwnerDocument(), r, namespace+r.getTagName(), true);
83 //}
84 result[i] = r;
85 }
86 return result;
87 }
88}
89
Note: See TracBrowser for help on using the repository browser.