Use wininet problem!

 

After run code ,httpAnyis system output is http!

But my post code is https!




#property copyright ""
#property link      ""
#property version               "1.00"
#property description  ""
#property library


#import "wininet.dll"

int InternetOpenW(string &sAgent,int lAccessType,string &sProxyName,string &sProxyBypass,int lFlags);
int InternetConnectW(int hInternet,string &lpszServerName,int nServerPort,string &lpszUsername,string &lpszPassword,int dwService,int dwFlags,int dwContext);
int HttpOpenRequestW(int hConnect,string &lpszVerb,string &lpszObjectName,string &lpszVersion,string &lpszReferer,string &lplpszAcceptTypes,uint dwFlags,int dwContext);
int HttpSendRequestW(int hRequest,string &lpszHeaders,int dwHeadersLength,uchar &lpOptional[],int dwOptionalLength);
int InternetCloseHandle(int hInet);

int InternetReadFile(int hFile,uchar     &sBuffer[],int     lNumBytesToRead,int     &lNumberOfBytesRead);
int InternetReadFile(
        int     hFile,
        string  sBuffer,
        int     lNumBytesToRead,
        int&    lNumberOfBytesRead[]
);



#define OPEN_TYPE_PRECONFIG     0           // use the configuration by default
#define FLAG_KEEP_CONNECTION    0x00400000  // do not terminate the connection
#define FLAG_PRAGMA_NOCACHE     0x00000100  // no cashing of the page
#define FLAG_RELOAD             0x80000000  // receive the page from the server when accessing it
#define SERVICE_HTTP            3           // the required protocol
#import

#define INTERNET_SERVICE_FTP                                            1 // Ftp 服务
#define INTERNET_SERVICE_HTTP                                           3       // Http 服务 
#define HTTP_QUERY_CONTENT_LENGTH                       5

void setHttpSend(string varBoday)
{
  string nill=NULL;
  
  string hIntern="Microsoft Internet Explorer";
  
  string ipHost="localhost";
  
  string urlPath="/WebService1.asmx/ReciveStringData";
  
  string lpVerb="POST";
  
  string Version="HTTP/1.1";
  
  string stHead="Content-Type: application/x-www-form-urlencoded";
  
  uchar data[];
  
  int hSession=InternetOpenW(hIntern,OPEN_TYPE_PRECONFIG,nill,nill,0); // 打开会话
  
  int hHttpSession =InternetConnectW(hSession,ipHost,44309,nill,nill,INTERNET_SERVICE_HTTP,0,0);

  int hOpenRequest = HttpOpenRequestW(hHttpSession,lpVerb,urlPath,Version,nill, nill,FLAG_KEEP_CONNECTION|FLAG_RELOAD|FLAG_PRAGMA_NOCACHE,0); 
   
  string varRequesStr="ipt="+varBoday;

  StringToCharArray(varRequesStr,data);
  
  int dataLenth=ArraySize(data)-1; //这个地方一定要注意-1哦.
  
  bool boSendRequest=HttpSendRequestW(hOpenRequest,stHead,StringLen(stHead),data,dataLenth); // 发送文件            



 uchar ch[100]; string toStr=""; int dwBytes, h=-1;

   while(InternetReadFile(hOpenRequest, ch, 100, dwBytes)) 

     {

       if (dwBytes<=0) break; toStr=toStr+CharArrayToString(ch, 0, dwBytes);

     }

   int err = GetLastError();

   if(err>0)Print ("Last MSDN Error =: ",err);

   Print(toStr);

  InternetCloseHandle(hOpenRequest);
  InternetCloseHandle(hSession);
 

   
}
 
 
 
  
 
ah2005: After run code ,httpAnyis system output is http! But my post code is https!

Your issue is with the Windows API, which has nothing to do with MQL. I suggest posting on a Windows or Microsoft forum related to the API programming for a more a informed response.

 
  1. No idea except you call Http:
      bool boSendRequest=HttpSendRequestW(
  2. Why are you using the Windows API when MTx has a built in WebRequest?