Search in sources :

Example 26 with W3CEndpointReference

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

the class EndpointReferenceTest method testEndpointGetEndpointReferenceSOAPBinding.

@Test
public void testEndpointGetEndpointReferenceSOAPBinding() throws Exception {
    GreeterImpl greeter = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
        Document doc = StaxUtils.read(is);
        Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:ReferenceParameters", "");
        EndpointReference endpointReference = endpoint.getEndpointReference(referenceParameters);
        assertNotNull(endpointReference);
        assertTrue(endpointReference instanceof W3CEndpointReference);
        // A returned W3CEndpointReferenceMUST also contain the specified referenceParameters.
        // W3CEndpointReference wer = (W3CEndpointReference)endpointReference;
        endpoint.stop();
    }
}
Also used : InputStream(java.io.InputStream) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Element(org.w3c.dom.Element) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 27 with W3CEndpointReference

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

the class EndpointReferenceTest method testBindingProviderSOAPBindingStaicService.

@Test
public void testBindingProviderSOAPBindingStaicService() throws Exception {
    org.apache.hello_world_soap_http.SOAPService s = new org.apache.hello_world_soap_http.SOAPService();
    Greeter greeter = s.getPort(Greeter.class);
    BindingProvider bindingProvider = (BindingProvider) greeter;
    EndpointReference er = bindingProvider.getEndpointReference();
    assertNotNull(er);
    // If the BindingProvider instance has a binding that is either SOAP 1.1/HTTP or SOAP
    // 1.2/HTTP, then a W3CEndpointReference MUST be returned.
    assertTrue(er instanceof W3CEndpointReference);
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Greeter(org.apache.hello_world_soap_http.Greeter) BindingProvider(javax.xml.ws.BindingProvider) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 28 with W3CEndpointReference

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

the class EndpointReferenceTest method testProviderCreateW3CEndpointReference.

@Test
public void testProviderCreateW3CEndpointReference() throws Exception {
    ProviderImpl provider = new ProviderImpl();
    InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
    Document doc = StaxUtils.read(is);
    Element referenceParameter = fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:ReferenceParameters", "");
    List<Element> referenceParameters = new ArrayList<>();
    if (referenceParameter != null) {
        referenceParameters.add(referenceParameter);
    }
    Element metadata = fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:metadata", "");
    List<Element> metadataList = new ArrayList<>();
    if (metadata != null) {
        metadataList.add(metadata);
    }
    W3CEndpointReference endpointReference = provider.createW3CEndpointReference("http://localhost:8080/test", serviceName, portName, metadataList, "wsdlDocumentLocation", referenceParameters);
    assertNotNull(endpointReference);
}
Also used : InputStream(java.io.InputStream) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) ProviderImpl(org.apache.cxf.jaxws.spi.ProviderImpl) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 29 with W3CEndpointReference

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

the class EndpointReferenceTest method testEndpointGetEndpointReferenceW3C.

@Test
public void testEndpointGetEndpointReferenceW3C() throws Exception {
    GreeterImpl greeter = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
        Document doc = StaxUtils.read(is);
        Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:ReferenceParameters", "");
        EndpointReference endpointReference = endpoint.getEndpointReference(W3CEndpointReference.class, referenceParameters);
        assertNotNull(endpointReference);
        assertTrue(endpointReference instanceof W3CEndpointReference);
        // A returned W3CEndpointReferenceMUST also contain the specified referenceParameters.
        // W3CEndpointReference wer = (W3CEndpointReference)endpointReference;
        endpoint.stop();
    }
}
Also used : InputStream(java.io.InputStream) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Element(org.w3c.dom.Element) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 30 with W3CEndpointReference

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

the class ProviderImplTest method testCreateW3CEprMetadataServiceNameOnly.

@org.junit.Test
public void testCreateW3CEprMetadataServiceNameOnly() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org", "ServiceName");
    ProviderImpl impl = new ProviderImpl();
    W3CEndpointReference w3Epr = impl.createW3CEndpointReference("http://myaddress", null, serviceName, 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"));
    assertFalse("Interface element unexpected", sw.toString().contains("Interface"));
    assertTrue("ServiceName is expected", sw.toString().contains("ServiceName"));
}
Also used : StreamResult(javax.xml.transform.stream.StreamResult) QName(javax.xml.namespace.QName) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference)

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