use of org.apache.cxf.ws.discovery.wsdl.ScopesType in project jbossws-cxf by jbossws.
the class WSDiscoveryTestCase method testInvocation.
@Test
@RunAsClient
public void testInvocation() throws Exception {
Bus bus = null;
try {
bus = BusFactory.newInstance().createBus();
WSDiscoveryClient client = new WSDiscoveryClient(bus);
ProbeType pt = new ProbeType();
ScopesType scopes = new ScopesType();
pt.setScopes(scopes);
final String serverHost = getServerHost().replace("127.0.0.1", "localhost");
List<ProbeMatchType> pmts = client.probe(pt, TIMEOUT).getProbeMatch();
assertFalse("There must be some services discovered, check that you have allowed UDP broadcast on port 3072", pmts.isEmpty());
List<ProbeMatchType> pmtsForHost = filterProbeMatchesForHost(pmts, serverHost.replace("127.0.0.1", "localhost"));
assertFalse("There must be some services discovered for current host " + serverHost, pmtsForHost.isEmpty());
List<ResolveMatchType> rmts = new LinkedList<ResolveMatchType>();
for (ProbeMatchType pmt : pmtsForHost) {
W3CEndpointReference epr = pmt.getEndpointReference();
ResolveMatchType rmt = client.resolve(epr, TIMEOUT);
assertNotNull("Could not resolve (timeout = " + TIMEOUT + " ms) reference: " + epr, rmt);
rmts.add(rmt);
}
int i = 0;
for (ResolveMatchType rmt : rmts) {
i++;
ServiceIface port = rmt.getEndpointReference().getPort(ServiceIface.class);
String address = rmt.getXAddrs().iterator().next();
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
String expected = address.contains("AnotherWSDDService") ? "Hi " : "Greetings ";
assertEquals(expected + "Alice" + i, port.greet("Alice" + i));
}
client.close();
} finally {
bus.shutdown(true);
}
}
Aggregations