<!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 1: Finding a service</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="example1">Code Example 1: Finding a service</a></h1>This example shows you how to find Web services. In this case, the example finds Web services with names that begin with the word "magic".<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">"magic"</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_eservice.html">uddi2__find_USCOREservice</a> fs(soap, search_string); | |
<span class="comment">// Send the request</span> | |
<a class="code" href="classuddi2____service_list.html">uddi2__serviceList</a> *sl = fs.send(<span class="stringliteral">"http://uddi.xmethods.net/inquire"</span>); | |
<span class="comment">// Check if result is OK</span> | |
<span class="keywordflow">if</span> (!sl) | |
soap_print_fault(soap, stderr); | |
<span class="comment">// If OK, report the service name(s) and unique identification keys</span> | |
<span class="keywordflow">else</span> <span class="keywordflow">if</span> (sl-><a class="code" href="classuddi2____service_list.html#o0">serviceInfos</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__serviceInfo*>::const_iterator si = sl-><a class="code" href="classuddi2____service_list.html#o0">serviceInfos</a>-><a class="code" href="classuddi2____service_infos.html#o0">serviceInfo</a>.begin(); si != sl-><a class="code" href="classuddi2____service_list.html#o0">serviceInfos</a>-><a class="code" href="classuddi2____service_infos.html#o0">serviceInfo</a>.end(); ++si) | |
{ | |
<span class="comment">// Report serviceKey and businessKey</span> | |
std::cout << <span class="stringliteral">"serviceKey="</span> << (*si)->serviceKey << std::endl << <span class="stringliteral">"businessKey="</span> << (*si)->businessKey << std::endl; | |
<span class="comment">// Report names</span> | |
<span class="keywordflow">for</span> (std::vector<uddi2__name*>::const_iterator n = (*si)->name.begin(); n != (*si)->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 example1 example1.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> |