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();
}
}
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);
}
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);
}
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();
}
}
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"));
}
Aggregations