Search in sources :

Example 31 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project cxf by apache.

the class ProviderImplTest method testCreateW3CEprMetadataInterfaceNameOnly.

@org.junit.Test
public void testCreateW3CEprMetadataInterfaceNameOnly() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org", "IntfName");
    ProviderImpl impl = new ProviderImpl();
    W3CEndpointReference w3Epr = impl.createW3CEndpointReference("http://myaddress", serviceName, null, null, null, null, null, null, null);
    java.io.StringWriter sw = new java.io.StringWriter();
    StreamResult result = new StreamResult(sw);
    w3Epr.writeTo(result);
    assertTrue("Address is expected", sw.toString().contains("Address"));
    assertTrue("Metadata element expected", sw.toString().contains("Metadata"));
    assertTrue("Interface element expected", sw.toString().contains("Interface"));
    assertFalse("ServiceName is unexpected", sw.toString().contains("ServiceName"));
}
Also used : StreamResult(javax.xml.transform.stream.StreamResult) QName(javax.xml.namespace.QName) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference)

Example 32 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project cxf by apache.

the class ProviderImplTest method testCreateW3CEprMetadataMetadataOnly.

@org.junit.Test
public void testCreateW3CEprMetadataMetadataOnly() throws Exception {
    ProviderImpl impl = new ProviderImpl();
    DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Element element = builder.newDocument().createElement("customMetadata");
    List<Element> metadata = new ArrayList<>();
    metadata.add(element);
    W3CEndpointReference w3Epr = impl.createW3CEndpointReference("http://myaddress", null, null, metadata, null, null);
    java.io.StringWriter sw = new java.io.StringWriter();
    StreamResult result = new StreamResult(sw);
    w3Epr.writeTo(result);
    assertTrue("Address is expected", sw.toString().contains("Address"));
    assertTrue("Metadata element expected", sw.toString().contains("Metadata"));
    assertTrue("Custom Metadata element expected", sw.toString().contains("customMetadata"));
    assertFalse("Interface element unexpected", sw.toString().contains("Interface"));
    assertFalse("ServiceName unexpected", sw.toString().contains("ServiceName"));
}
Also used : StreamResult(javax.xml.transform.stream.StreamResult) DocumentBuilder(javax.xml.parsers.DocumentBuilder) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList)

Example 33 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project cxf by apache.

the class WSDiscoveryClientTest method main.

// this is a standalone test
public static void main(String[] arg) throws Exception {
    try {
        Bus bus = BusFactory.getDefaultBus();
        Endpoint ep = Endpoint.publish("http://localhost:51919/Foo/Snarf", new FooImpl());
        WSDiscoveryServiceImpl service = new WSDiscoveryServiceImpl(bus);
        service.startup();
        // this service will just generate an error.  However, the probes should still
        // work to probe the above stuff.
        WSDiscoveryServiceImpl s2 = new WSDiscoveryServiceImpl() {

            public ProbeMatchesType handleProbe(ProbeType pt) {
                throw new RuntimeException("Error!!!");
            }
        };
        s2.startup();
        HelloType h = service.register(ep.getEndpointReference());
        bus = BusFactory.newInstance().createBus();
        WSDiscoveryClient c = new WSDiscoveryClient(bus);
        c.setVersion10();
        System.out.println("1");
        ProbeType pt = new ProbeType();
        ScopesType scopes = new ScopesType();
        pt.setScopes(scopes);
        ProbeMatchesType pmts = c.probe(pt, 1000);
        System.out.println("2");
        if (pmts != null) {
            for (ProbeMatchType pmt : pmts.getProbeMatch()) {
                System.out.println("Found " + pmt.getEndpointReference());
                System.out.println(pmt.getTypes());
                System.out.println(pmt.getXAddrs());
            }
        }
        if (pmts.getProbeMatch().isEmpty()) {
            System.exit(0);
        }
        pmts = c.probe(pt);
        System.out.println("Size:" + pmts.getProbeMatch().size());
        System.out.println("3");
        W3CEndpointReference ref = null;
        if (pmts != null) {
            for (ProbeMatchType pmt : pmts.getProbeMatch()) {
                ref = pmt.getEndpointReference();
                System.out.println("Found " + pmt.getEndpointReference());
                System.out.println(pmt.getTypes());
                System.out.println(pmt.getXAddrs());
            }
        }
        ResolveMatchType rmt = c.resolve(ref);
        System.out.println("Resolved " + rmt.getEndpointReference());
        System.out.println(rmt.getTypes());
        System.out.println(rmt.getXAddrs());
        service.unregister(h);
        System.out.println("4");
        c.close();
        System.exit(0);
    } catch (Throwable t) {
        t.printStackTrace();
        System.exit(1);
    }
}
Also used : ScopesType(org.apache.cxf.ws.discovery.wsdl.ScopesType) Bus(org.apache.cxf.Bus) ProbeType(org.apache.cxf.ws.discovery.wsdl.ProbeType) WSDiscoveryServiceImpl(org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl) HelloType(org.apache.cxf.ws.discovery.wsdl.HelloType) ProbeMatchType(org.apache.cxf.ws.discovery.wsdl.ProbeMatchType) ResolveMatchType(org.apache.cxf.ws.discovery.wsdl.ResolveMatchType) Endpoint(javax.xml.ws.Endpoint) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ProbeMatchesType(org.apache.cxf.ws.discovery.wsdl.ProbeMatchesType)

Example 34 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project cxf by apache.

the class AbstractNotificationBroker method handleNotify.

protected void handleNotify(Notify notify) {
    for (NotificationMessageHolderType messageHolder : notify.getNotificationMessage()) {
        W3CEndpointReference producerReference = messageHolder.getProducerReference();
        AbstractPublisher publisher = getPublisher(producerReference);
        if (publisher != null) {
            publisher.notify(messageHolder);
        }
    }
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) NotificationMessageHolderType(org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)

Example 35 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project cxf by apache.

the class DispatchClientServerTest method testJAXBObjectPAYLOADFromEPR.

@Test
public void testJAXBObjectPAYLOADFromEPR() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
    assertNotNull(service);
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.address("http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort");
    builder.serviceName(SERVICE_NAME);
    builder.endpointName(PORT_NAME);
    W3CEndpointReference w3cEpr = builder.build();
    JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
    Dispatch<Object> disp = service.createDispatch(w3cEpr, jc, Service.Mode.PAYLOAD, new AddressingFeature());
    doJAXBPayload(disp);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) AddressingFeature(javax.xml.ws.soap.AddressingFeature) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) JAXBContext(javax.xml.bind.JAXBContext) URL(java.net.URL) Test(org.junit.Test)

Aggregations

W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)37 Test (org.junit.Test)17 QName (javax.xml.namespace.QName)9 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)9 URL (java.net.URL)8 InputStream (java.io.InputStream)6 StreamResult (javax.xml.transform.stream.StreamResult)6 EndpointReference (javax.xml.ws.EndpointReference)6 Element (org.w3c.dom.Element)6 Number (org.apache.cxf.factory_pattern.Number)5 NumberFactory (org.apache.cxf.factory_pattern.NumberFactory)5 NumberFactoryService (org.apache.cxf.factory_pattern.NumberFactoryService)5 NumberService (org.apache.cxf.factory_pattern.NumberService)5 Document (org.w3c.dom.Document)5 Source (javax.xml.transform.Source)4 Endpoint (javax.xml.ws.Endpoint)4 ServiceImpl (org.apache.cxf.jaxws.ServiceImpl)4 ArrayList (java.util.ArrayList)2 JAXBContext (javax.xml.bind.JAXBContext)2 JAXBException (javax.xml.bind.JAXBException)2