Exception::Exception(int fc, const std::string &s) : std::exception(), reason(s), faultcode(fc) { ULXR_DOUT("=== Exception: " << s); }
MethodCall Dispatcher::waitForCall(int _timeout) { ULXR_TRACE("waitForCall"); if (!protocol->isOpen()) { if (!protocol->accept(_timeout)) return MethodCall(); // // @todo throw exception? } else protocol->resetConnection(); char buffer[ULXR_RECV_BUFFER_SIZE]; char *buff_ptr; std::auto_ptr<XmlParserBase> parser; MethodCallParserBase *cpb = 0; ULXR_TRACE("waitForCall in XML"); MethodCallParser *cp = new MethodCallParser(); cpb = cp; parser.reset(cp); bool done = false; long myRead; while (!done && ((myRead = protocol->readRaw(buffer, sizeof(buffer))) > 0) ) { buff_ptr = buffer; while (myRead > 0) { Protocol::State state = protocol->connectionMachine(buff_ptr, myRead); if (state == Protocol::ConnError) throw ConnectionException(TransportError, "network problem occured", 500); else if (state == Protocol::ConnSwitchToBody) { if (!protocol->hasBytesToRead()) { #ifdef ULXR_SHOW_READ std::string super_data(buff_ptr, myRead); while ((myRead = protocol->readRaw(buffer, sizeof(buffer))) > 0) super_data.append(buffer, myRead); ULXR_DOUT_READ("superdata 1 start:\n" << super_data << "superdata 1 end:\n"); #endif throw ConnectionException(NotConformingError, "Content-Length of message not available", 411); } } else if (state == Protocol::ConnBody) { ULXR_DOUT_XML(std::string(buff_ptr, myRead)); if (!parser->parse(buff_ptr, myRead, done)) { ULXR_DOUT("errline: " << parser->getCurrentLineNumber()); ULXR_DWRITE(buff_ptr, myRead); ULXR_DOUT("") ; throw XmlException(parser->mapToFaultCode(parser->getErrorCode()), "Problem while parsing xml request", parser->getCurrentLineNumber(), parser->getErrorString(parser->getErrorCode())); } myRead = 0; } } if (!protocol->hasBytesToRead()) // || parser->isComplete()) done = true; } ULXR_TRACE("waitForCall got " << cpb->getMethodCall().getXml()); return cpb->getMethodCall(); }