WinCE6.0下如何实现WebService???

icesoft2000 2012-07-12 07:00:59
在网上查找了一下,用gSOAP的很多。

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

以前没有接触过网络编程,大家有什么好的解决方式啊?
...全文
273 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
多啦A孟 2012-07-31
  • 打赏
  • 举报
回复
MFC的,我也不会,好像就是你说的那个玩意,在C#里添加引用,IP地址也不能是动态的,需要在编译的时候就把IP地址设置好
icesoft2000 2012-07-28
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
你用MFC还是C#?C#直接添加web引用就可以用了
[/Quote]

MFC 应该如何?
多啦A孟 2012-07-27
  • 打赏
  • 举报
回复
你用MFC还是C#?C#直接添加web引用就可以用了
icesoft2000 2012-07-23
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
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"……
[/Quote]

代码编译运行没错,可是得不到想要的结果啊
icesoft2000 2012-07-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
啊?你用CE做webService? 做个客户端而已吧。 CE下用wininet加个XML解析库就可以了
[/Quote]

做客户端
91program 2012-07-18
  • 打赏
  • 举报
回复
http://bbs.51cto.com/archiver/tid-864655.html


{
// 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"));
}
Kwanvin 2012-07-13
  • 打赏
  • 举报
回复
啊?你用CE做webService? 做个客户端而已吧。 CE下用wininet加个XML解析库就可以了

19,500

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧