|  | Home | Documentation | Code Example 2: Finding a business updated by Robert van Engelen |

Code Example 2: Finding a business

This example shows you how to find a business from a UDDI server.

#include "inqH.h"
int main(int argc, char **argv)
{
char *search_string = "xmethods";
if (argc > 1)
search_string = argv[1];
// Create a gSOAP context
struct soap *soap = soap_new();
// Create an object to find a business
uddi2__find_USCOREbusiness fb(soap, search_string);
// Send the request
uddi2__businessList *bl = fb.send("http://uddi.xmethods.net/inquire");
// Check if result is OK
if (!bl)
soap_print_fault(soap, stderr);
// If OK, report the business name(s) and unique identification keys
else if (bl->businessInfos)
{
std::cout << "Search results on " << search_string << ":" << std::endl << std::endl;
for (std::vector<uddi2__businessInfo*>::const_iterator bi = bl->businessInfos->businessInfo.begin(); bi != bl->businessInfos->businessInfo.end(); ++bi)
{
// Report businessKey
std::cout << "businessKey=" << (*bi)->businessKey << std::endl;
// Report names
for (std::vector<uddi2__name*>::const_iterator n = (*bi)->name.begin(); n != (*bi)->name.end(); ++n)
std::cout << "name=" << (*n)->__item << std::endl;
std::cout << std::endl;
}
}
// Remove deserialized objects
soap_destroy(soap);
// Remove temporary data
soap_end(soap);
// Detach and free context
soap_done(soap);
free(soap);
return 0;
}
uddi2__businessInfos::businessInfo
std::vector< uddi2__businessInfo * > businessInfo
Vector of uddi2__businessInfo* with length 0..unbounded.
Definition uddi_v2.h:1994
uddi2__businessList
Schema urn:uddi-org:api_v2:"businessList".
Definition uddi_v2.h:3018
uddi2__businessList::businessInfos
uddi2__businessInfos * businessInfos
Element reference "urn:uddi-org:api_v2":businessInfos.
Definition uddi_v2.h:3020
uddi2__find_USCOREbusiness
Schema urn:uddi-org:api_v2:"find_business".
Definition uddi_v2.h:2522

To compile:

- wsdl2h -tuddi2-typemap.dat inquire_v2.wsdl
- soapcpp2 -I.. -pinq inquire_v2.h
- g++ -DWITH_NONAMESPACES -I.. -o example2 example2.cpp inquire_v2.cpp inqC.cpp inqClient.cpp ../stdsoap2.cpp