Esempio n. 1
0
int msWFSException11(mapObj *map, const char *locator, 
                     const char *exceptionCode, const char *version)
{
    int size = 0;
    char *errorString     = NULL;
    char *errorMessage    = NULL;
    char *schemasLocation = NULL;
    const char *encoding;

    xmlDocPtr  psDoc      = NULL;   
    xmlNodePtr psRootNode = NULL;
    xmlNsPtr   psNsOws    = NULL;
    xmlChar *buffer       = NULL;
    
    if (version == NULL)
       version = "1.1.0";

    psNsOws = xmlNewNs(NULL, BAD_CAST "http://www.opengis.net/ows", BAD_CAST "ows");

    encoding = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");

    errorString = msGetErrorString("\n");
    errorMessage = msEncodeHTMLEntities(errorString);
    schemasLocation = msEncodeHTMLEntities(msOWSGetSchemasLocation(map));

    psDoc = xmlNewDoc(BAD_CAST "1.0");

    psRootNode = msOWSCommonExceptionReport(psNsOws, OWS_1_0_0, schemasLocation, version, msOWSGetLanguage(map, "exception"), exceptionCode, locator, errorMessage);

    xmlDocSetRootElement(psDoc, psRootNode);

    xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/ows", BAD_CAST "ows");

    if (encoding)
        msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
    else
        msIO_printf("Content-type: text/xml%c%c",10,10);

    xmlDocDumpFormatMemoryEnc(psDoc, &buffer, &size, (encoding ? encoding : "ISO-8859-1"), 1);
    
    msIO_printf("%s", buffer);

    /*free buffer and the document */
    free(errorString);
    free(errorMessage);
    free(schemasLocation);
    xmlFree(buffer);
    xmlFreeDoc(psDoc);
    xmlFreeNs(psNsOws);

    /* clear error since we have already reported it */
    msResetErrorList();

    return MS_FAILURE;
}
Esempio n. 2
0
int msWFSException11(mapObj *map, const char *locator,
                     const char *exceptionCode, const char *version)
{
  int size = 0;
  char *errorString     = NULL;
  char *schemasLocation = NULL;

  xmlDocPtr  psDoc      = NULL;
  xmlNodePtr psRootNode = NULL;
  xmlNsPtr   psNsOws    = NULL;
  xmlChar *buffer       = NULL;

  if (version == NULL)
    version = "1.1.0";

  psNsOws = xmlNewNs(NULL, BAD_CAST "http://www.opengis.net/ows", BAD_CAST "ows");

  errorString = msGetErrorString("\n");
  schemasLocation = msEncodeHTMLEntities(msOWSGetSchemasLocation(map));

  psDoc = xmlNewDoc(BAD_CAST "1.0");

  psRootNode = msOWSCommonExceptionReport(psNsOws, OWS_1_0_0, schemasLocation, version, msOWSGetLanguage(map, "exception"), exceptionCode, locator, errorString);

  xmlDocSetRootElement(psDoc, psRootNode);

  xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/ows", BAD_CAST "ows");

  msIO_setHeader("Content-Type","text/xml; charset=UTF-8");
  msIO_sendHeaders();

  xmlDocDumpFormatMemoryEnc(psDoc, &buffer, &size, ("UTF-8"), 1);

  msIO_printf("%s", buffer);

  /*free buffer and the document */
  free(errorString);
  free(schemasLocation);
  xmlFree(buffer);
  xmlFreeDoc(psDoc);
  xmlFreeNs(psNsOws);

  /* clear error since we have already reported it */
  msResetErrorList();

  return MS_FAILURE;
}