大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> NET专区 -> webservice系列教学(15)-如何调用webservice(vc6)

webservice系列教学(15)-如何调用webservice(vc6)

时间: 2021-07-31 作者:daque

////////////////////////////////////////////////////////////////////////////////////////////////////function: cmclientdlg::addtotree()////parameters: (htreeitem hparent, htreeitem hinsertafter, lptstr pszdata, uint mask, iunknown //* theinterface)////description: insert the tree item to tree ////returns: htreeitem////////////////////////////////////////////////////////////////////////////////////////////////////htreeitem cmclientdlg::addtotree(htreeitem hparent, htreeitem hinsertafter, lptstr pszdata, uint mask, iunknown * theinterface){tv_insertstructcurtreeitem;htreeitemhreturn;curtreeitem.hparent = hparent;curtreeitem.hinsertafter = hinsertafter;curtreeitem.item.psztext = pszdata;curtreeitem.item.mask = mask |lvif_param;curtreeitem.item.lparam = reinterpret_cast<dword>(theinterface);hreturn = m_treectrl.insertitem(&curtreeitem);// if insertionfails , it will return null, otherwise it will return handle of the new item,if(hreturn)theinterface->addref();return hreturn;}////////////////////////////////////////////////////////////////////////////////////////////////////function: cmclientdlg::ncountparameter()////parameters: no parameters////description: counts the number of parameters, the function takes//returns: int////////////////////////////////////////////////////////////////////////////////////////////////////int cmclientdlg::ncountparameter(){lvitemitem;int ncounter;int nnum;smisinputenum isinput;nnum= m_parameters.getitemcount();for ( ncounter = 0;ncounter <= nnum ;ncounter ++){assignitem(&item, lvif_param,ncounter,0,0,0);// if could not get the item from list, return -1if (m_parameters.getitem(&item) == 0)return -1;reinterpret_cast<isoapmapper *>(item.lparam)->get_isinput(&isinput);if (isinput == smoutput)nnum --;}returnnnum;}////////////////////////////////////////////////////////////////////////////////////////////////////function: cmclientdlg::modifydialog()////parameters: no parameter////description: modifies the parameter list dialog //returns: int////////////////////////////////////////////////////////////////////////////////////////////////////int cmclientdlg::modifydialog(){// modify the list control dialog , add two more column with their headersrectrlistdialog;int nreturn= 0;int flag = 1;m_parameters.getclientrect(&rlistdialog);nreturn = m_parameters.insertcolumn(0, _t("variable"), lvcfmt_left, (rlistdialog.right - rlistdialog.left) / 3 );if (nreturn == -1){flag = 0;msg("could not modify the dialog");}nreturn =m_parameters.insertcolumn(1, _t("type"), lvcfmt_left,(rlistdialog.right - rlistdialog.left) / 3 );if (nreturn == -1){flag = 0;msg("could not modify the dialog");}nreturn =m_parameters.insertcolumn(2, _t("value"),lvcfmt_left,(rlistdialog.right - rlistdialog.left)-(2*(rlistdialog.right - rlistdialog.left)/3));if (nreturn == -1){flag = 0;msg("could not modify the dialog");}updatedata(false);cleanup:if (flag == 0)return -1;return 1;}////////////////////////////////////////////////////////////////////////////////////////////////////function: cmclientdlg::checkforurl()////parameters: no parameters////description: checks whether url for wsdl file is given or not. if it is not given , returns -1//returns: int////////////////////////////////////////////////////////////////////////////////////////////////////int cmclientdlg::checkforurl(){int flag = 1;if (m_strurl.isempty()){flag = 0;msg("wsdl file is not given");}cleanup:if (flag == 0)return -1;return 1;}////////////////////////////////////////////////////////////////////////////////////////////////////function: cmclientdlg::destroytree()////parameters: no parameters////description: deletes the existing tree, if any problem occurs for deleting returns false//returns: bool////////////////////////////////////////////////////////////////////////////////////////////////////bool cmclientdlg::destroytree(){// if any tree exist, delete it ,and also delete the listint flag = 1;if (m_treectrl.getcount() != 0){if (!m_treectrl.deleteallitems()){flag = 0;msg("tree could not be destroyed");}if (m_parameters.getitemcount() != 0){if (m_parameters.deleteallitems() == 0){flag = 0;msg("parameter list could not be destroyed");;}}}cleanup:if (flag ==0)return false;return true;}////////////////////////////////////////////////////////////////////////////////////////////////////function: cmclientdlg::updatelist()////parameters: no parameters////description: updates parameters of the operation////returns: int////////////////////////////////////////////////////////////////////////////////////////////////////int cmclientdlg::updatelist(){uses_conversion;ccomptr<isoapmapper>pisoapmap;ccomptr<ienumsoapmappers>ppienumsoapmappers;tvitemtvitem;hresulthr= s_ok;longcfetched;bstrbstrelementname = 0;bstrbstrelementtype = 0;lvitemlvitem;cstringstrtmp;intncounter= 0;int flag= 1;int flagsm= 0;smisinputenumisinput;// if list is not empty, delete itif (m_parameters.getitemcount() != 0){if (m_parameters.deleteallitems() == 0){flag = 0;msg("could not delete list");}}// get the selected operationtvitem.mask = tvif_param;tvitem.hitem = m_treectrl.getselecteditem();if (! tvitem.hitem){flag = 0;msg("could not get selected item");}if (m_treectrl.getitem(&tvitem) == 0){flag = 0;msg("could not get item");}// get parts of the operationhr = (reinterpret_cast<iwsdloperation *> (tvitem.lparam))->getoperationparts(&ppienumsoapmappers);check_hresult(hr,"getting operation parts failed");// in this loop take each parameter one by onewhile(((hr = ppienumsoapmappers->next(1, &pisoapmap, &cfetched))== s_ok) &&(pisoapmap != null)){flagsm =1;// type of parameterhr = pisoapmap->get_elementtype(&bstrelementtype);check_hresult(hr,"could not get name of parameter!");//name of parameterhr = pisoapmap->get_elementname(&bstrelementname);check_hresult(hr,"could not get the type of parameter!");strtmp = bstrelementtype;// check what type of parameter it is?[in] , [in,out]...hr = pisoapmap->get_isinput(&isinput);check_hresult(hr,"checking input type is failed");if (isinput == sminput){strtmp += " [in]";}else if (isinput == sminout){strtmp +=" [in/out]";}else if (isinput == smoutput){strtmp +=" [out]";}assignitem(&lvitem, lvif_text| lvif_param, ncounter ++, 0,w2a(bstrelementname), ::sysstringlen(bstrelementname));lvitem.lparam= (dword)(isoapmapper*)pisoapmap;// insert the item in to listif (m_parameters.insertitem(&lvitem) == -1){flag = 0;msg("could not set item to list");}lvitem.mask= lvif_text; lvitem.isubitem= 1;lvitem.psztext = strtmp.getbuffer(0);// insert the second columnif (m_parameters.setitem(&lvitem) == 0){flag = 0;msg("could not insert item to list");}// i have to addref() before pisoapmap = 0 , otherwise i will loose the object((iunknown*)pisoapmap)->addref();// release pisoapmappisoapmap = 0;}if (flagsm == 0){flag = 0;msg("getting operation parts failed");}updatedata();cleanup:::sysfreestring(bstrelementname);::sysfreestring(bstrelementtype);if (flag == 0)return -1;return 1; }

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.