webservice系列教学(14)-如何调用webservice(vc5)-.NET教程,Web Service开发

发布时间:2016-12-7 20:43:17 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"webservice系列教学(14)-如何调用webservice(vc5)-.NET教程,Web Service开发",主要涉及到webservice系列教学(14)-如何调用webservice(vc5)-.NET教程,Web Service开发方面的内容,对于webservice系列教学(14)-如何调用webservice(vc5)-.NET教程,Web Service开发感兴趣的同学可以参考一下。

webservice系列教学(14)-如何调用webservice(vc5)-.NET教程,Web Service开发 ////////////////////////////////////////////////////////////////////////////////////////////////// //  function: cmclientdlg::ondeleteitemlistparam() // //  parameters: (nmhdr* pnmhdr, lresult* presult) // //  description: for each row of list, it calls the release // //  returns: void // ////////////////////////////////////////////////////////////////////////////////////////////////// void cmclientdlg::ondeleteitemlistparam(nmhdr* pnmhdr, lresult* presult) { // we have to release lparam that i filled with object of isoapmapper     nmlistview   *tempvar = (nmlistview*)pnmhdr;;     if (reinterpret_cast <iunknown*>(tempvar->lparam))         (reinterpret_cast <iunknown*>(tempvar->lparam))->release();          *presult = 0; } ////////////////////////////////////////////////////////////////////////////////////////////////// //  function: cmclientdlg::ondeleteitemtree() // //  parameters: (nmhdr* pnmhdr, lresult* presult) // //  description: for each tree elements, it calls the release method //  returns: void // ////////////////////////////////////////////////////////////////////////////////////////////////// void cmclientdlg::ondeleteitemtree(nmhdr* pnmhdr, lresult* presult) {     // we have to release lparam that i filled with object     nmtreeview   *tempvar = (nmtreeview*)pnmhdr;;     if (reinterpret_cast <iunknown*>(tempvar->itemold.lparam))         (reinterpret_cast <iunknown*>(tempvar->itemold.lparam))->release();     *presult = 0; } ////////////////////////////////////////////////////////////////////////////////////////////////// //  function: cmclientdlg::onselchangedtree() // //  parameters: (nmhdr* pnmhdr, lresult* presult) // //  description: for selection on tree, it updates the list // //  returns: void // ////////////////////////////////////////////////////////////////////////////////////////////////// void cmclientdlg::onselchangedtree(nmhdr* pnmhdr, lresult* presult) {     // if the selected is operation, update the list with its parameters     nmtreeview* pnmtreeview = (nmtreeview*)pnmhdr;     iunknown *punk = reinterpret_cast<iunknown *>(pnmtreeview->itemnew.lparam);     if (! punk)         return;     iwsdloperation *poper = 0;     m_strparameter.empty();     updatedata(false);     if(succeeded(punk->queryinterface(__uuidof(iwsdloperation), reinterpret_cast<void **>(&poper))))     {         if (updatelist() != 1)             msg("parameter list can not be created!");     }     *presult = 0; cleanup:     if (poper)         poper->release();          return; } ///////////////////////////////////////////////////////////////////////////////////////////////////////// //  function: cmclientdlg::onload() // //  parameters: no parameters // //  description:  takes the service, ports and operations and fills the tree // //  returns: void // ///////////////////////////////////////////////////////////////////////////////////////////////////////// void cmclientdlg::onload() {     uses_conversion;     updatedata(true); // chech if wsdl file is given, if not, return     if (checkforurl() == -1)         return; // delete the tree if exist, if a tree exist and cant be deleted, return     if (!destroytree())         return;     hresult                            hr                        =    s_ok;     bstr                            bstrwsdlfilename        =   0;     bstr                            bstrservicename            =    0;     bstr                            bstrportname            =    0;     bstr                            bstroperationname        =    0;     int                             flag                    =   1;     int                             flag_service            =   0;     int                             flag_port               =   0;     int                             flag_operation          =   0;     ccomptr<ienumwsdlservice>        pienumwsdlservices;     ccomptr<ienumwsdlports>            pienumwsdlports;     ccomptr<ienumwsdloperations>    pienumwsdlops;     ccomptr<iwsdloperation>            pioperation;     ccomptr<iwsdlreader>            piwsdlreader;     ccomptr<iwsdlservice>            piwsdlservice;     ccomptr<iwsdlport>                piwsdlport;     long                            cfetched;     htreeitem                        hservice;     htreeitem                        hport;     htreeitem                        hoperation;     // take the name of wsdl file     bstrwsdlfilename =  m_strurl.allocsysstring();     if (bstrwsdlfilename == null)         return;     hr = cocreateinstance(__uuidof(wsdlreader), null, clsctx_inproc_server, __uuidof(iwsdlreader),                         (void**)&piwsdlreader);     check_hresult(hr, "can not create the  object of the clsid_wsdlreader");     // loading needs wsdl and wsml files, but i dont know wsml file and i pass ""     hr = piwsdlreader->load(bstrwsdlfilename, l"");            check_hresult(hr, "loading wsdl and wsml files failed!");     // get soap service     hr = piwsdlreader->getsoapservices(&pienumwsdlservices);     check_hresult(hr, "can not get services");     if (!pienumwsdlservices)         msg("can not get services");     while((hr = pienumwsdlservices->next(1, &piwsdlservice, &cfetched)) == s_ok)     {         // at least one time this loop should go inside; if it does not, the flag wont be updated         // so we can not continue and should destroy the tree if any part created         flag_service   =   1;         // get service name         hr = piwsdlservice->get_name(&bstrservicename);         check_hresult(hr, "can not get service names");         // add the name of service in to tree         // first field is null, it means insert this as root         hservice= addtotree(null,tvi_sort,w2a(bstrservicename),tvif_text,piwsdlservice);         ::sysfreestring(bstrservicename);         if (!hservice)         {             flag = 0;             goto cleanup;         }         hr = piwsdlservice->getsoapports(&pienumwsdlports);         check_hresult(hr, "can not get ports");         if (!pienumwsdlports)             msg("can not get ports");         while((hr = pienumwsdlports->next(1,&piwsdlport, &cfetched)) == s_ok)         {             // at least one time this loop should go inside; if it does not, the flag wont be updated             // so we can not continue and should destroy the tree if any part created             flag_port  =   1;              // get port name             hr = piwsdlport->get_name(&bstrportname);             check_hresult(hr, "can not get port names");             // add to tree but as a child of service             hport= addtotree(hservice,tvi_sort,w2a(bstrportname),tvif_text,piwsdlport);             ::sysfreestring(bstrportname);             if (!hport)             {                 flag = 0;                 goto cleanup;             }             hr = piwsdlport->getsoapoperations(&pienumwsdlops);             check_hresult(hr, "can not get operations");             if (!pienumwsdlops)                 msg("can not get operations");             while((hr = pienumwsdlops->next(1,&pioperation, &cfetched)) == s_ok)             {              // at least one time this loop should go inside; if it does not, the flag wont be updated              // so we can not continue and should destroy the tree if any part created                 flag_operation  =   1;                 hr = pioperation->get_name(&bstroperationname);                 check_hresult(hr, "can not get operation names");                 hoperation= addtotree(hport,tvi_sort,w2a(bstroperationname),tvif_text,pioperation);                 ::sysfreestring(bstroperationname);                 if (!hoperation)                 {                     flag = 0;                     goto cleanup;                 }                 // we do release by assigning to 0                 pioperation= 0;             }             if (flag_operation == 0)             {                 flag =0;                 msg("could not load  operations!");             }             //// we do release by assigning to 0             piwsdlport = 0;         }         if (flag_port == 0)         {             flag =0;             msg("could not load  ports!");         }         //// we do release by assigning to 0         piwsdlservice = 0;     }          if (flag_service == 0)     {         flag =0;         msg("could not load  service!");     }     updatedata(false); cleanup:     ::sysfreestring(bstrwsdlfilename);        ::sysfreestring(bstrservicename);     ::sysfreestring(bstrportname);     ::sysfreestring(bstroperationname);     if (flag == 0)         destroytree();     return; } 文章整理:西部数码--专业提供域名注册、虚拟主机服务 http://www.west263.com 以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!  

上一篇:iOS中textbox文本框清除圆角
下一篇:UNIX/Linux进程间通信IPC系列(六)信号量

相关文章

相关评论