Revision 37871 branches/v2_0_0_prep/applications/appCatalog/src/org/gvsig/catalog/protocols/SOAPProtocol.java

View differences:

SOAPProtocol.java
1 1

  
2 2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42 42
package org.gvsig.catalog.protocols;
43 43
import java.io.BufferedReader;
44 44
import java.io.ByteArrayInputStream;
......
56 56
import org.apache.soap.messaging.Message;
57 57
import org.apache.soap.transport.SOAPTransport;
58 58
import org.apache.soap.util.xml.XMLParserUtils;
59
import org.gvsig.catalog.metadataxml.XMLTree;
59
import org.slf4j.Logger;
60
import org.slf4j.LoggerFactory;
60 61
import org.w3c.dom.Document;
61 62
import org.xml.sax.InputSource;
62 63

  
64
import org.gvsig.catalog.metadataxml.XMLTree;
63 65

  
66

  
64 67
/**
65 68
 * 
66 69
 * 
......
68 71
 * @author Jorge Piera Llodra (piera_jor@gva.es)
69 72
 */
70 73
public class SOAPProtocol implements IProtocols {
71

  
72
/**
73
 * 
74
 * 
75
 * 
76
 * @return 
77
 * @param url 
78
 * @param object 
79
 * @param firstRecord 
80
 */
81
    public Collection doQuery(URL url, Object object, int firstRecord) {        
74
    private static final Logger LOG =
75
        LoggerFactory.getLogger(SOAPProtocol.class);
76
    
77
    /**
78
     * @return 
79
     * @param url 
80
     * @param object 
81
     * @param firstRecord 
82
     */
83
    public Collection doQuery(URL url, Object object, int firstRecord) {    
82 84
        String message = (String) object;
83 85
        File fileAnswer = null;
84
       
86

  
85 87
        //get the envelope to send
86 88
        try {
87 89
            InputStream buffer = new ByteArrayInputStream(message.getBytes());
......
89 91
            Document doc = xdb.parse(new InputSource(buffer));
90 92
            if (doc == null) {
91 93
                throw new SOAPException(Constants.FAULT_CODE_CLIENT,
92
                    "parsing error");
94
                "parsing error");
93 95
            }
94 96
            Envelope msgEnv = Envelope.unmarshall(doc.getDocumentElement());
95 97
            // send the message
......
110 112
                fwAnswer.flush();
111 113
            }
112 114
            fwAnswer.close();
113
               
114
         
115

  
116

  
115 117
        } catch (Exception e) {
118
            LOG.error("Error sending the SOAP request", e);
116 119
            return null;
117 120
        }
118 121
        Collection col = new java.util.ArrayList();
......
120 123
        return col;
121 124
    } 
122 125

  
123
/**
124
 * 
125
 * 
126
 * 
127
 * @return 
128
 * @param url 
129
 */
126
    /**
127
     * 
128
     * 
129
     * 
130
     * @return 
131
     * @param url 
132
     */
130 133
    public static boolean isProtocolSupported(URL url) {        
131 134
        return true;
132 135
    } 
133 136

  
134
/**
135
 * This function returns a SOAP message
136
 * 
137
 * 
138
 * @return 
139
 * @param message the XML message
140
 * @param schemas 
141
 */
137
    /**
138
     * This function returns a SOAP message
139
     * 
140
     * 
141
     * @return 
142
     * @param message the XML message
143
     * @param schemas 
144
     */
142 145
    public static String setSOAPMessage(String message, String[] schemas) {        
143 146
        String soap =  "<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
144
        	"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" ;
147
        "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" ;
145 148
        if (schemas != null){
146 149
            for (int i=0 ; i<schemas.length ; i++){
147 150
                soap = soap + " " + schemas[i];
......
150 153
        soap = soap + ">";
151 154
        soap = soap + "<SOAP:Body>" + message + "</SOAP:Body>" + "</SOAP:Envelope>";
152 155
        return soap;
153
        
156

  
154 157
    } 
155
 }
158
}

Also available in: Unified diff