- Code: Select all
std::string xml =
"<test>"
"<abc id="\xxx\" num=\"1\">"
" <stuff>30</stuff>"
"</abc>
"</test>;
int main ( int arg, char* argv[] ){
try {
//this is just to check if xml is well formed.. apparently the abstraction class will throw exception if it objects
//start
std::istringstream iss ( xml ) ;
Poco::Util::AbstractionConfiguration *ptr = new ( std::nothrow ) Poco::Util::AbstractionConfiguration ( iss ) ;
if ( !ptr ) return EXIT_FAILURE ;
//end
Poco::HTTPRequest request( "POST", "/event");
request.setContentType ( "text/xml");
//request.setContentType ( "text/xml; char=\"utf-8\"" ); //makes no difference it seems
request.setContentLength( xml.length() );
Poco::HTTPClientSession s( "127.0.0.1", 8801 ) ;
s.sendRequest(request) << xml;
//check response
} catch ( Poco::Exception& exec ) {
}
return EXIT_SUCCESS ;
}
Server side snippet
- Code: Select all
std::istream& istr = req.stream ; //where req is Poco::Net::HTTPServerRequest& req
std::stringstream oss;
oss << istr.rdbuf();
std::string request = oss.str();
std::istringstream iss ( xml ) ;
Poco::Util::AbstractionConfiguration *ptr = new ( std::nothrow ) Poco::Util::AbstractionConfiguration ( iss ) ;
if ( !ptr ) return ;
Invocation of new AbstractionConfiguration invokes an exception on server side. This tells me that something is amiss about the client side transfer. I know the XML is 'loosely speaking' well formed because if it wasn't I would not be able to create an Abstraction object on the client side.
Clearly, i receive the contents on the server side since I'm able to do std::cout << request<< std::endl; What's unclear to me though is why the abstraction class rejects the XML. Ideas? Thanks





