web services - How can I connect to a webservice through winIntet library in c++? -
i created webservice seems that:
[webservice(namespace = "http://tempuri.org/")] [webservicebinding(conformsto = wsiprofiles.basicprofile1_1)] // allow web service called script, using asp.net ajax, uncomment following line. // [system.web.script.services.scriptservice] public class webservice : system.web.services.webservice { public webservice() { //uncomment following line if using designed components //initializecomponent(); } [webmethod] public string helloworld() { return "hello world"; } } the service reference http://localhost:4653/webservice.asmx.
now, need access webservice through cpp project. that, i'm using wininet library way:
hinternet handle = internetopen("upload", internet_open_type_direct, null, null, 0); if (handle) { hinternet handleconnect = internetconnect(handle, "localhost:4653", internet_default_http_port, null, null, internet_service_http, null, null); if (handleconnect) { if (hinternet handleopenreq = httpopenrequest(handleconnect, text("post"), text("/webservice.asmx/helloworld"), null, null, null, internet_flag_keep_connection, 0)) { if (httpsendrequest(handleopenreq, null, 0, null, 0)) cout << "succeed" << endl; else { dword p = getlasterror(); } } however httpsendrequest not succeed , getlasterror returns 12029, i.e attempt connect server failed. how can fix problem, connect webservice? there parameters sending wrong? thanks,
instead of using internetconnect, try use internetopenurl()
Comments
Post a Comment