Ejemplo n.º 1
0
    def _makesoap(self, xmlelement):
        request = """<?xml version="1.0" encoding="UTF-8"?>
        <SOAP-ENV:Envelope  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
                            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
            <SOAP-ENV:Body>
                REQUEST
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
        """
        enve = etree.fromstring(request)

        body = enve.find(".//{%s}Body" %
                         "http://schemas.xmlsoap.org/soap/envelope/")
        body.append(xmlelement)

        headers = {
            "SOAPAction": "\"\"",
        }
        r = requests.post(self.wsdl_url,
                          data=etree.tostring(enve),
                          headers=headers)
        return etree.fromstring(r.text[38:]).find(".//returnData")
Ejemplo n.º 2
0
    def raw(self, **kwargs):
        # These are the features we will actually query against
        query_features = []

        if self.bbox is None and self.features is None:
            raise ValueError("NERRS requires a BBOX or Feature filter")

        if self.bbox is not None and self.features is not None:
            print(
                "Both a BBox and Feature filter is defined, BBOX takes precedence."
            )

        # BBox takes precedence over features
        if self.bbox is not None:
            test_box = box(
                self.bbox[0], self.bbox[1], self.bbox[2], self.bbox[3]
            )
            # Set the features and call collect again
            for s in self.stations:
                p = Point(float(s["Longitude"]), float(s["Latitude"]))
                if test_box.intersects(p):
                    query_features.append(s["Station_Code"])
        else:
            query_features = self.features

        if query_features is not None and len(query_features) > 0:

            results = {}
            for f in query_features:
                if self.start_time is not None and self.end_time is not None:
                    # Date range query
                    soap_env = self._build_exportAllParamsDateRangeXMLNew(f)
                else:
                    # Not a date range query
                    soap_env = self._build_exportSingleParamXMLNew(f)

                if soap_env is not None:
                    response = self._makesoap(soap_env)
                    results[f] = etree.tostring(response)

            return results

        return None
Ejemplo n.º 3
0
    def raw(self, **kwargs):
        # These are the features we will actually query against
        query_features = []

        if self.bbox is None and self.features is None:
            raise ValueError("NERRS requires a BBOX or Feature filter")

        if self.bbox is not None and self.features is not None:
            print(
                "Both a BBox and Feature filter is defined, BBOX takes precedence."
            )

        # BBox takes precedence over features
        if self.bbox is not None:
            test_box = box(self.bbox[0], self.bbox[1], self.bbox[2],
                           self.bbox[3])
            # Set the features and call collect again
            for s in self.stations:
                p = Point(float(s["Longitude"]), float(s["Latitude"]))
                if test_box.intersects(p):
                    query_features.append(s["Station_Code"])
        else:
            query_features = self.features

        if query_features is not None and len(query_features) > 0:

            results = {}
            for f in query_features:
                if self.start_time is not None and self.end_time is not None:
                    # Date range query
                    soap_env = self._build_exportAllParamsDateRangeXMLNew(f)
                else:
                    # Not a date range query
                    soap_env = self._build_exportSingleParamXMLNew(f)

                if soap_env is not None:
                    response = self._makesoap(soap_env)
                    results[f] = etree.tostring(response)

            return results

        return None
Ejemplo n.º 4
0
    def _makesoap(self, xmlelement):
        request = """<?xml version="1.0" encoding="UTF-8"?>
        <SOAP-ENV:Envelope  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
            <SOAP-ENV:Body>
                REQUEST
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
        """
        enve = etree.fromstring(request)

        body = enve.find(".//{%s}Body" % "http://schemas.xmlsoap.org/soap/envelope/")
        body.append(xmlelement)

        headers = {
            "SOAPAction"        : "\"\"",
        }
        r = requests.post(self.wsdl_url, data=etree.tostring(enve), headers=headers)
        return etree.fromstring(r.text[38:]).find(".//returnData")