Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » HttpRequest and SOAP protocole (I need help about sending soap request to a wep api)
HttpRequest and SOAP protocole [message #50316] Tue, 18 September 2018 12:28 Go to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello Everyone !

Nowaday I tried to send a "Soap Request" via the Object HttpRequest
and looking for the result coming from execute Methode.

I have tried this kind of code :
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
	String reponse="";
	auto test = new HttpRequest("http://www.holidaywebservice.com//HolidayService_v2/HolidayService2.asmx?wsdl");
	test->Timeout(5000);
	test->ContentType("text/xml");
	test->Post("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:hs='http://www.holidaywebservice.com/HolidayService_v2/'><soapenv:Body><hs:GetHolidaysForMonth><hs:year>2018</hs:year><hs:countryCode>UnitedStates</hs:countryCode><hs:month>11</hs:month></hs:GetHolidaysForMonth></soapenv:Body></soapenv:Envelope>");
	reponse = test->Execute();
	LOG(reponse);
}


But it crash with the message : "heap leaks detected" and the exitcode 0.
The heap leaks detected seems related to the LOG/"reponse"
so I tried without them and the result is now a crash with the exitcode : 3224225477

Can someone explain me why this occur ?

Sorry for my bad english, Thanks in advance.
Re: HttpRequest and SOAP protocole [message #50317 is a reply to message #50316] Tue, 18 September 2018 13:26 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Xemuth,

Because you've created an HttpRequest on the heap and you forgot to delete it at the end. Smile
This is the VERY reason you should avoid using new/delete.
Try to allocate resources on the stack, or use containers (e.g. One<> for single instance, Array<> for mulitple instances.)

	HttpRequest test("http://www.holidaywebservice.com//HolidayService_v2/HolidayService2.asmx?wsdl");
	test.Timeout(5000);
	test.ContentType("text/xml");
	test.Post("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:hs='http://www.holidaywebservice.com/HolidayService_v2/'><soapenv:Body><hs:GetHolidaysForMonth><hs:year>2018</hs:year><hs:countryCode>UnitedStates</hs:countryCode><hs:month>11</hs:month></hs:GetHolidaysForMonth></soapenv:Body></soapenv:Envelope>");
	reponse = test.Execute();
	LOG(reponse);


Best regards,
Oblivion


[Updated on: Tue, 18 September 2018 13:28]

Report message to a moderator

Re: HttpRequest and SOAP protocole [message #50318 is a reply to message #50316] Tue, 18 September 2018 13:47 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello Oblivion,

Indeed it fixed the crash ! thanks for your quick reply !

I did not know it was a difference between HttpRequest test(); and HttpRequest test = new HttpRequest();

Thanks a lot !
Previous Topic: Statically linked Web Browser
Next Topic: print the Http Request before sending it
Goto Forum:
  


Current Time: Thu Mar 28 22:23:28 CET 2024

Total time taken to generate the page: 0.01181 seconds