Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > media > contrib-release > by-pkgid > 9f5c7ae460878d5070e65a29704c26cd > files > 371

gsoap-2.7.8c-1mdv2007.0.i586.rpm

<!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&nbsp;Page</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;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 &gt; 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-&gt;<a class="code" href="classuddi2____business_list.html#o0">businessInfos</a>)
  {
    std::cout &lt;&lt; <span class="stringliteral">"Search results on "</span> &lt;&lt; search_string &lt;&lt; <span class="stringliteral">":"</span> &lt;&lt; std::endl &lt;&lt; std::endl;

    <span class="keywordflow">for</span> (std::vector&lt;uddi2__businessInfo*&gt;::const_iterator bi = bl-&gt;<a class="code" href="classuddi2____business_list.html#o0">businessInfos</a>-&gt;<a class="code" href="classuddi2____business_infos.html#o0">businessInfo</a>.begin(); bi != bl-&gt;<a class="code" href="classuddi2____business_list.html#o0">businessInfos</a>-&gt;<a class="code" href="classuddi2____business_infos.html#o0">businessInfo</a>.end(); ++bi)
    {
      <span class="comment">// Report businessKey</span>
      std::cout &lt;&lt; <span class="stringliteral">"businessKey="</span> &lt;&lt; (*bi)-&gt;businessKey &lt;&lt; std::endl;

      <span class="comment">// Report names</span>
      <span class="keywordflow">for</span> (std::vector&lt;uddi2__name*&gt;::const_iterator n = (*bi)-&gt;name.begin(); n != (*bi)-&gt;name.end(); ++n)
        std::cout &lt;&lt; <span class="stringliteral">"name="</span> &lt;&lt; (*n)-&gt;__item &lt;&lt; std::endl;

      std::cout &lt;&lt; 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>