<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>gSOAP UDDI v2: Code Example 2: Finding a business</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.3.8 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div> <h1><a class="anchor" name="example2">Code Example 2: Finding a business</a></h1>This example shows you how to find a business from a UDDI server.<p> <div class="fragment"><pre><span class="preprocessor">#include "inqH.h"</span> <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) { <span class="keywordtype">char</span> *search_string = <span class="stringliteral">"xmethods"</span>; <span class="keywordflow">if</span> (argc > 1) search_string = argv[1]; <span class="comment">// Create a gSOAP context</span> <span class="keyword">struct </span>soap *soap = soap_new(); <span class="comment">// Create an object to find a business</span> <a class="code" href="classuddi2____find___u_s_c_o_r_ebusiness.html">uddi2__find_USCOREbusiness</a> fb(soap, search_string); <span class="comment">// Send the request</span> <a class="code" href="classuddi2____business_list.html">uddi2__businessList</a> *bl = fb.send(<span class="stringliteral">"http://uddi.xmethods.net/inquire"</span>); <span class="comment">// Check if result is OK</span> <span class="keywordflow">if</span> (!bl) soap_print_fault(soap, stderr); <span class="comment">// If OK, report the business name(s) and unique identification keys</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (bl-><a class="code" href="classuddi2____business_list.html#o0">businessInfos</a>) { std::cout << <span class="stringliteral">"Search results on "</span> << search_string << <span class="stringliteral">":"</span> << std::endl << std::endl; <span class="keywordflow">for</span> (std::vector<uddi2__businessInfo*>::const_iterator bi = bl-><a class="code" href="classuddi2____business_list.html#o0">businessInfos</a>-><a class="code" href="classuddi2____business_infos.html#o0">businessInfo</a>.begin(); bi != bl-><a class="code" href="classuddi2____business_list.html#o0">businessInfos</a>-><a class="code" href="classuddi2____business_infos.html#o0">businessInfo</a>.end(); ++bi) { <span class="comment">// Report businessKey</span> std::cout << <span class="stringliteral">"businessKey="</span> << (*bi)->businessKey << std::endl; <span class="comment">// Report names</span> <span class="keywordflow">for</span> (std::vector<uddi2__name*>::const_iterator n = (*bi)->name.begin(); n != (*bi)->name.end(); ++n) std::cout << <span class="stringliteral">"name="</span> << (*n)->__item << std::endl; std::cout << std::endl; } } <span class="comment">// Remove deserialized objects</span> soap_destroy(soap); <span class="comment">// Remove temporary data</span> soap_end(soap); <span class="comment">// Detach and free context</span> soap_done(soap); free(soap); <span class="keywordflow">return</span> 0; } </pre></div><p> To compile:<ul> <li>wsdl2h -tuddi2-typemap.dat inquire_v2.wsdl</li><li>soapcpp2 -I.. -pinq inquire_v2.h</li><li>g++ -DWITH_NONAMESPACES -I.. -o example2 example2.cpp inquire_v2.cpp inqC.cpp inqClient.cpp ../stdsoap2.cpp </li></ul> <hr size="1"><address style="align: right;"><small>Generated on Wed Aug 17 16:17:00 2005 for gSOAP UDDI v2 by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address> </body> </html>