cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > WS-Discovery
Date Fri, 28 Sep 2012 18:58:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/WS-Discovery">WS-Discovery</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~dkulp">Daniel
Kulp</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-unchanged" >h1.WS-Discovery <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
<br>[WS-Discovery|http://docs.oasis-open.org/ws-dd/discovery/1.1/os/wsdd-discovery-1.1-spec-os.html]
is a protocol to enable dynamic discovery of services available on the local network.   By
default, WS-Discovery uses a UDP based multicast transport to announce new services and probe
for existing services.  However, it also supports a managed mode where a discovery proxy is
used to reduce the amount of multicast traffic required. <br> <br> <br>h3.
Enabling WS-Discovery announcements for services <br> <br>To enable CXF to send
&quot;Hello&quot; announcements when services and endpoint are started, the cxf-services-ws-discovery-service
and cxf-services-ws-discovery-api jars need to be available on the classpath.   The cxf-services-ws-discovery-service
jar will register a ServerLifecyleListener that will automatically publish the &quot;Hello&quot;
messages.   It will also respond to any Probe requests that match the services it has published.
<br> <br>By default, the WS-Discovery service will startup in ad-hoc mode.  However,
if you set a Bus property of &quot;org.apache.cxf.service.ws-discovery.address&quot;
to a URL address of a WS-Discovery Proxy, the service will change to managed mode and send
the Hello/Bye notices directly to that proxy.  It will also not respond to Probes. <br>
<br> <br>h3. Using WS-Discovery client to probe for services <br> <br>CXF
also provides an API to probe the network or WS-Discovery proxy.   The org.apache.cxf.ws.discovery.WSDiscoveryClient
class provides several methods for probing the network.  <br> <br>{code:java}
<br>//Use WS-Discovery to find references to services that implement the Greeter portType
<br>WSDiscoveryClient client = new WSDiscoveryClient(); <br>   // or: new WSDiscoveryClient(&quot;soap.udp://proxyhost:3702&quot;);
<br>List&lt;EndpointReference&gt; references = client.probe(new QName(&quot;http://cxf.apache.org/hello_world/discovery&quot;,
&quot;Greeter&quot;)); <br>client.close(); <br> <br>GreeterService
service = new GreeterService(); <br>//loop through all of them and have them greet me.
<br>for (EndpointReference ref : references) { <br>    Greeter g = service.getPort(ref,
Greeter.class); <br>    System.out.println(g.greetMe(&quot;World&quot;)); <br>}
 <br>{code} <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="WS-Discovery-WSDiscovery"></a>WS-Discovery</h1>

<p><a href="http://docs.oasis-open.org/ws-dd/discovery/1.1/os/wsdd-discovery-1.1-spec-os.html"
class="external-link" rel="nofollow">WS-Discovery</a> is a protocol to enable dynamic
discovery of services available on the local network.   By default, WS-Discovery uses a UDP
based multicast transport to announce new services and probe for existing services.  However,
it also supports a managed mode where a discovery proxy is used to reduce the amount of multicast
traffic required.</p>


<h3><a name="WS-Discovery-EnablingWSDiscoveryannouncementsforservices"></a>Enabling
WS-Discovery announcements for services</h3>

<p>To enable CXF to send "Hello" announcements when services and endpoint are started,
the cxf-services-ws-discovery-service and cxf-services-ws-discovery-api jars need to be available
on the classpath.   The cxf-services-ws-discovery-service jar will register a ServerLifecyleListener
that will automatically publish the "Hello" messages.   It will also respond to any Probe
requests that match the services it has published.</p>

<p>By default, the WS-Discovery service will startup in ad-hoc mode.  However, if you
set a Bus property of "org.apache.cxf.service.ws-discovery.address" to a URL address of a
WS-Discovery Proxy, the service will change to managed mode and send the Hello/Bye notices
directly to that proxy.  It will also not respond to Probes.</p>


<h3><a name="WS-Discovery-UsingWSDiscoveryclienttoprobeforservices"></a>Using
WS-Discovery client to probe for services</h3>

<p>CXF also provides an API to probe the network or WS-Discovery proxy.   The org.apache.cxf.ws.discovery.WSDiscoveryClient
class provides several methods for probing the network. </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-comment">//Use WS-Discovery to find references to services that implement
the Greeter portType
</span>WSDiscoveryClient client = <span class="code-keyword">new</span>
WSDiscoveryClient();
   <span class="code-comment">// or: <span class="code-keyword">new</span>
WSDiscoveryClient(<span class="code-quote">"soap.udp://proxyhost:3702"</span>);
</span>List&lt;EndpointReference&gt; references = client.probe(<span class="code-keyword">new</span>
QName(<span class="code-quote">"http:<span class="code-comment">//cxf.apache.org/hello_world/discovery"</span>,
<span class="code-quote">"Greeter"</span>));
</span>client.close();
        
GreeterService service = <span class="code-keyword">new</span> GreeterService();
<span class="code-comment">//loop through all of them and have them greet me.
</span><span class="code-keyword">for</span> (EndpointReference ref : references)
{
    Greeter g = service.getPort(ref, Greeter.class);
    <span class="code-object">System</span>.out.println(g.greetMe(<span class="code-quote">"World"</span>));
} 
</pre>
</div></div>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/WS-Discovery">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=30737341&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/WS-Discovery?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message