首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > WinCE >

WinCE6.0上怎么实现WebService?

2012-09-10 
WinCE6.0下如何实现WebService???在网上查找了一下,用gSOAP的很多。但例子基本上是一样的,先要使用wsdl2h.e

WinCE6.0下如何实现WebService???
在网上查找了一下,用gSOAP的很多。

但例子基本上是一样的,先要使用wsdl2h.exe和soapcpp2.exe生成指定网页的 WSDL。
可偶每次访问的网页地址可能不一样,如何解决?

以前没有接触过网络编程,大家有什么好的解决方式啊?

[解决办法]
http://bbs.51cto.com/archiver/tid-864655.html

C/C++ code
{    // TODO: Add your control notification handler code here    LPTSTR AcceptTypes[2] = {L"/MsgUDPServer/index.jsp HTTP/1.0\r\n", NULL};    char lpOutBuf[1024];    BOOL bAllDone = FALSE;    ghInstance = InternetOpen(L"CeHttp",         INTERNET_OPEN_TYPE_PRECONFIG,        NULL,        NULL,        INTERNET_FLAG_ASYNC);        // 用异步模式时,HttpSendRequestEx 失败并返回: 997    if(NULL == ghInstance)    {        RETAILMSG(1,(L"Call InternetOpen failed: %d\r\n",GetLastError()));        return;    }    if(InternetSetStatusCallback(ghInstance,(INTERNET_STATUS_CALLBACK)&Callback) == INTERNET_INVALID_STATUS_CALLBACK)    {        RETAILMSG(1,(L"InternetSetStatusCallback failed, error ",GetLastError()));        return;    }    hConnect = InternetConnect(ghInstance,         L"www.baidu.com",         //L"58.250.61.201",        INTERNET_DEFAULT_HTTP_PORT,        NULL,        NULL,        INTERNET_SERVICE_HTTP,        0,        1);    if(NULL == hConnect)    {        if(ERROR_IO_PENDING != GetLastError())        {            RETAILMSG(1,(L"InternetConnect failed, error: %d\r\n",GetLastError()));            return;        }        WaitForSingleObject(hConnectedEvent, INFINITE);    }    hRequest = HttpOpenRequest(hConnect,         L"GET",         NULL,         HTTP_VERSION,        NULL,        (LPCTSTR *)AcceptTypes,        INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE,        0);    if(NULL == hRequest)    {        if(ERROR_IO_PENDING != GetLastError())        {            RETAILMSG(1,(L"HttpOpenRequest failed, error: %d\r\n",GetLastError()));            return;        }        WaitForSingleObject(hRequestCompleteEvent,INFINITE);    }    INTERNET_BUFFERS IntBuff;    FillMemory(&IntBuff, sizeof(IntBuff), 0);    IntBuff.dwStructSize= sizeof(IntBuff);    IntBuff.dwBufferTotal = 1024 * 64;    //IntBuff.lpcszHeader = L"Content-Type: application/x-www-form-urlencoded\r\n Content-Length: 4\r\n\r\n";    IntBuff.lpcszHeader = L"Content-Type: text/text\r\n";    IntBuff.dwHeadersLength = lstrlen(IntBuff.lpcszHeader);    if(!HttpSendRequestEx(hRequest,&IntBuff,NULL,0,2))    {        if(ERROR_IO_PENDING != GetLastError())        {            RETAILMSG(1,(L"HttpSendRequestEx failed: %d\r\n",GetLastError()));            return;        }        RETAILMSG(1,(L"HttpSendRequestEx called successfully\r\n"));                WaitForSingleObject(hRequestCompleteEvent, INFINITE);    // 等待信号    }    for(DWORD dwNumKSent = 0;dwNumKSent < 10;dwNumKSent++)    {        DWORD dwBytesWritten = 0;        if(!InternetWriteFile(hRequest,lpOutBuf,1024,&dwBytesWritten))        {            if(ERROR_IO_PENDING != GetLastError())            {                RETAILMSG(1,(L"InternetWriteFile failed: %d\r\n",GetLastError()));                return;            }            else            {                RETAILMSG(1,(L"InternetWriteFile completing asynchronously.\r\n"));                WaitForSingleObject(hRequestCompleteEvent,INFINITE);//            }        }    }    RETAILMSG(1,(L"Calling HttpEndRequest\r\n"));    if(!HttpEndRequest(hRequest, NULL, HSR_INITIATE, 2))    {        if(GetLastError() == ERROR_IO_PENDING)        {            RETAILMSG(1,(L"HttpEndRequest called.\r\n"));            WaitForSingleObject(hRequestCompleteEvent, INFINITE);        }        else        {            RETAILMSG(1,(L"HttpEndRequest failed, error: %d\r\n",GetLastError()));            return;        }    }    RETAILMSG(1,(L"------------------- Read the response -------------------\r\n"));    char lpReadBuff[256 + 1];    DWORD dwReadSize = 0;    do    {        ZeroMemory(lpReadBuff,sizeof(char) * (256 + 1));//         INTERNET_BUFFERS InetBuff;// //         FillMemory(&InetBuff, sizeof(InetBuff), 0);//         InetBuff.dwStructSize = sizeof(InetBuff);//         InetBuff.lpvBuffer = lpReadBuff;//         InetBuff.dwBufferLength = sizeof(lpReadBuff) - 1;        RETAILMSG(1,(L"Calling InternetReadFile\r\n"));        // if(!InternetReadFileEx(hRequest,&InetBuff,0,0))        if(!InternetReadFile(hRequest,lpReadBuff,256,&dwReadSize))        {            if(GetLastError() == ERROR_IO_PENDING)            {                // WaitForSingleObject(hRequestCompleteEvent, INFINITE);                RETAILMSG(1,(L"Waiting for InternetReadFile to complete\r\n"));                WaitForSingleObject(hRequestCompleteEvent, INFINITE);            }            else            {                RETAILMSG(1,(L"InternetReadFileEx failed: %d\r\n",GetLastError()));                return;            }        }        // lpReadBuff[InetBuff.dwBufferLength] = 0;        RETAILMSG(1,(L"%s\r\n",CString(lpReadBuff)));        // if (InetBuff.dwBufferLength == 0)        {            bAllDone = TRUE;        }    } while (bAllDone == FALSE);    RETAILMSG(1,(L"\r\n------------------- Request Complete ----------------\r\n"));} 

热点排行