Search in sources :

Example 6 with ScopesType

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);
    }
}
Also used : ScopesType(org.apache.cxf.ws.discovery.wsdl.ScopesType) Bus(org.apache.cxf.Bus) ProbeType(org.apache.cxf.ws.discovery.wsdl.ProbeType) LinkedList(java.util.LinkedList) ProbeMatchType(org.apache.cxf.ws.discovery.wsdl.ProbeMatchType) ResolveMatchType(org.apache.cxf.ws.discovery.wsdl.ResolveMatchType) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) WSDiscoveryClient(org.apache.cxf.ws.discovery.WSDiscoveryClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Aggregations

ScopesType (org.apache.cxf.ws.discovery.wsdl.ScopesType)6 Bus (org.apache.cxf.Bus)4 ProbeType (org.apache.cxf.ws.discovery.wsdl.ProbeType)4 LinkedList (java.util.LinkedList)3 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)3 HelloType (org.apache.cxf.ws.discovery.wsdl.HelloType)3 ProbeMatchType (org.apache.cxf.ws.discovery.wsdl.ProbeMatchType)3 ResolveMatchType (org.apache.cxf.ws.discovery.wsdl.ResolveMatchType)3 Test (org.junit.Test)3 QName (javax.xml.namespace.QName)2 Endpoint (javax.xml.ws.Endpoint)2 WSDiscoveryClient (org.apache.cxf.ws.discovery.WSDiscoveryClient)2 ProbeMatchesType (org.apache.cxf.ws.discovery.wsdl.ProbeMatchesType)2 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)2 JBossWSTest (org.jboss.wsf.test.JBossWSTest)2 InputStream (java.io.InputStream)1 DatagramPacket (java.net.DatagramPacket)1 InetAddress (java.net.InetAddress)1 MulticastSocket (java.net.MulticastSocket)1 NetworkInterface (java.net.NetworkInterface)1