VC++2005 使用调用webserver ,使用MSXML读取XML文件

来源:互联网 发布:手机仅限数据连接 编辑:程序博客网 时间:2024/06/06 04:34

VC++2005 使用调用webserver ,使用MSXML读取XML文件

 

生成接口文件

使用的工具 http://download.csdn.net/detail/aasmfox/9109261

用法: sproxy.exe /wsdl test.wsdl 我自己用的工具,用于生成文件。

 

MSXML使用的SDK

http://download.csdn.net/detail/aasmfox/9459555

 

我的测试代码

<span style="font-size:12px;">// update_test.cpp : Defines the entry point for the console application.//#include "stdafx.h" #include "updateserver.h"using namespace updateserver;UINT ThreadFunciton(LPVOID lParam); int _tmain(int argc, _TCHAR* argv[]){    CoInitialize(NULL);    HANDLE hThread ;     DWORD hThreadID;    hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ThreadFunciton,0,0,&hThreadID);    WaitForSingleObject(hThread,INFINITE);       CoUninitialize();return 0;}UINT ThreadFunciton(LPVOID lParam){    CoInitialize(NULL);    HRESULT hr = S_OK;    CComBSTR indata = NULL;    BSTRoutdata;    MSXML2::IXMLDOMDocumentPtr pDoc =NULL;    MSXML2::IXMLDOMElementPtr xmlRoot ;    CupdateserverT<CSoapSocketClientT<>> * server = new CupdateserverT<CSoapSocketClientT<>>;        try    {     indata = "select * From sys_app where appcode=\'1001\'";    hr  = server->Query(indata,&outdata);    if(SUCCEEDED(hr))    {                OutputDebugString(_T("\n"));        OutputDebugString(outdata);    }    ////创建DOMDocument对象    hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));    if (FAILED(hr))     {        printf("Failed to CoCreate an instance of an XML DOM\n");    }    pDoc->loadXML(outdata) ;      MSXML2::IXMLDOMNodePtr pNode;     //     _bstr_t Text;    pNode=pDoc->selectSingleNode("//code");    _bstr_t code =pNode->Gettext();      if(code.operator ==(_bstr_t("-1"))  )     {        pNode=pDoc->selectSingleNode("message");        Text =pNode->Gettext();          OutputDebugString(_T("\n"));        OutputDebugString(Text);    }         }    catch(_com_error&e)    {        _bstr_t ERR = e.Description();        OutputDebugString(_T("\n"));        OutputDebugString(ERR);    }    CoUninitialize();    return 0 ; }</span>


XML编辑工具
http://download.csdn.net/detail/aasmfox/9457841

 

 

0 0
原创粉丝点击