鉴于大家对ASP.net十分关注,我们编辑小组在此为大家搜集整理了“调用webservice(vc5)(2)”一文,供大家参考学习
// 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;
}