and I finally read the docs and try without success.
I must generate a XML and post to a URL for processing.
I write the next code but I don't send nothing when post it.
TIA
Gustavsen
PS: I disasembly the xml for avoid problem with forum
- Code: Select all
#include "stdafx.h"
#include "HttpCliente.h"
#include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/HTMLForm.h"
#include "Poco/StreamCopier.h"
#include "Poco/URI.h"
#include "Poco/Exception.h"
#include
#include
#include
using Poco::Net::HTTPClientSession;
using Poco::Net::HTTPRequest;
using Poco::Net::HTTPResponse;
using Poco::Net::HTTPMessage;
using Poco::Net::HTMLForm;
using Poco::StreamCopier;
using Poco::URI;
using Poco::Exception;
using namespace std;
int main(int argc, char* argv)
{
cout << "begin" << endl;
string xml = "< ?xml version="1.0"? >< request >THE XML< /request >
";
URI uri("http://localhost:9980/");
string path = uri.getPathAndQuery();
HTTPClientSession session (uri.getHost(), uri.getPort());
HTTPRequest request(HTTPRequest::HTTP_POST, path, HTTPMessage::HTTP_1_1);
request.setContentType("text/xml; charset="iso-8859-1"");
request.setKeepAlive(true);
HTMLForm form (request);
form.set("xml", xml);
session.sendRequest(request);
form.prepareSubmit(request);
ostringstream oss;
form.write(oss);
string texto = oss.str();
cout << "form: " << texto << endl;
istringstream iss(texto);
cout << "request: " << endl;
request.write(cout);
cout << "fin request: " << endl;
HTTPResponse response;
istream& rs = session.receiveResponse(response);
cout << response.getStatus() << " " << response.getReason() << endl;
StreamCopier::copyStream(rs, cout);
return 0;
}





