Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 24th, 2009, 02:46 PM
Authorized User
 
Join Date: Oct 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to C@uark
Default using wininet api to connect to web service on https

i have web service written in C#.net 2.0 framework and i am trying to assist someone that is using the wininet api to connect and send soap request to it. dont think i am configuring the httpsSession correctly. always get a http error 400 bad syntax back from the server after sending request


the excerpt from example app written on vc++6 that i am working with is below to connet

char* agent = "MyWebServiceTest";
unsigned int accessType = INTERNET_OPEN_TYPE_DIRECT;
char* proxyName = NULL;
char* proxyByPass = NULL;
unsigned long connectionFlag = 0;

//baseSession variables
char* serverName = "secure.site.state.ar";
INTERNET_PORT serverPort = 8443;
char* userName = NULL;
char* passWord = NULL;
unsigned long serviceType = INTERNET_SERVICE_HTTP; //handles http and https
unsigned long baseSessionFlags = 0;
unsigned long baseSessionContext = 12345; //Application-defined; identifies the appication context for the returned handle in callbacks

//httpsSession variables
char* httpType = "PUT";
char* requestedResource = "Service1.asmx";
char* httpVersion = "HTTP/1.1";
char* referer = NULL;
char** acceptedTypes = new char*("text/xml; charset=utf-8","\0");
unsigned int httpSessionFlags = INTERNET_FLAG_SECURE;
unsigned int httpSessionContext = 12345;

HINTERNET connection = InternetOpen( agent, accessType, proxyName, proxyByPass, connectionFlag );
HINTERNET baseSession = InternetConnect( connection, serverName, serverPort, userName, passWord, serviceType, baseSessionFlags, baseSessionContext);
HINTERNET httpsSession = HttpOpenRequest( baseSession, httpType, requestedResource, httpVersion, referer, (const char**)acceptedTypes, httpSessionFlags, httpSessionContext);

string header1 = "Content-Type: text/xml;charset=utf-8\r\n";
string header2 = "Content-Length: ";
string header3 = "SOAPAction: "https://secure.site.state.ar/Service1Ping"
(header2 += itoa(soap0.length(), new char[soap0.length()], 10)) += "\r\n";

header1 += header2;

if( HttpAddRequestHeaders(httpSession,header1.c_str(), header1.length(),HTTP_ADDREQ_FLAG_COALESCE_WITH_CO MMA) == 0 )
cout<<"Error adding headers error code "<<GetLastError();

if( HttpSendRequest(httpSession, NULL,0, (void*)soap.c_str(), soap.length()) != 0 )
{
/// response reading stuff here
}
__________________
Mike

Last edited by C@uark; September 24th, 2009 at 02:51 PM..
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Service Consuming another web service CraigWhitfield EJB 0 January 10th, 2008 08:38 AM
running an .exe API without installing a service taunon C# 0 June 10th, 2006 09:37 AM
can not connect to the web-service remote server? okll .NET Web Services 4 May 24th, 2006 06:08 PM
Service Oriented Web Service aldwinenriquez .NET Web Services 2 September 15th, 2005 03:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.