void QgsGetRequestHandler::sendServiceException( const QgsMapServiceException& ex ) const { //create Exception DOM document QDomDocument exceptionDoc; QDomElement serviceExceptionReportElem = exceptionDoc.createElement( "ServiceExceptionReport" ); serviceExceptionReportElem.setAttribute( "version", "1.3.0" ); serviceExceptionReportElem.setAttribute( "xmlns", "http://www.opengis.net/ogc" ); exceptionDoc.appendChild( serviceExceptionReportElem ); QDomElement serviceExceptionElem = exceptionDoc.createElement( "ServiceException" ); serviceExceptionElem.setAttribute( "code", ex.code() ); QDomText messageText = exceptionDoc.createTextNode( ex.message() ); serviceExceptionElem.appendChild( messageText ); serviceExceptionReportElem.appendChild( serviceExceptionElem ); QByteArray ba = exceptionDoc.toByteArray(); sendHttpResponse( &ba, "text/xml" ); }
void QgsHttpRequestHandler::setServiceException( QgsMapServiceException ex ) { mException = &ex; //create Exception DOM document QDomDocument exceptionDoc; QDomElement serviceExceptionReportElem = exceptionDoc.createElement( "ServiceExceptionReport" ); serviceExceptionReportElem.setAttribute( "version", "1.3.0" ); serviceExceptionReportElem.setAttribute( "xmlns", "http://www.opengis.net/ogc" ); exceptionDoc.appendChild( serviceExceptionReportElem ); QDomElement serviceExceptionElem = exceptionDoc.createElement( "ServiceException" ); serviceExceptionElem.setAttribute( "code", ex.code() ); QDomText messageText = exceptionDoc.createTextNode( ex.message() ); serviceExceptionElem.appendChild( messageText ); serviceExceptionReportElem.appendChild( serviceExceptionElem ); QByteArray ba = exceptionDoc.toByteArray(); // Clear response headers and body and set new exception // TODO: check for headersSent() clearHeaders(); clearBody(); setHttpResponse( &ba, "text/xml" ); }
void QgsSOAPRequestHandler::setServiceException( const QgsMapServiceException& ex ) { //create response document QDomDocument soapResponseDoc; //Envelope element QDomElement soapEnvelopeElement = soapResponseDoc.createElement( "soap:Envelope" ); soapEnvelopeElement.setAttribute( "xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/" ); soapEnvelopeElement.setAttribute( "soap:encoding", "http://schemas.xmlsoap.org/soap/encoding/" ); soapResponseDoc.appendChild( soapEnvelopeElement ); //Body element QDomElement soapBodyElement = soapResponseDoc.createElementNS( "http://schemas.xmlsoap.org/soap/envelope/", "soap:Body" ); soapEnvelopeElement.appendChild( soapBodyElement ); QDomElement msExceptionsElement = soapResponseDoc.createElement( "Exception" ); msExceptionsElement.setAttribute( "format", "text/xml" ); soapBodyElement.appendChild( msExceptionsElement ); QDomText msExceptionMessage = soapResponseDoc.createTextNode( QString( ex.message() ) ); msExceptionsElement.appendChild( msExceptionMessage ); QByteArray ba = soapResponseDoc.toByteArray(); setHttpResponse( &ba, "text/xml" ); }