use of javax.xml.ws.EndpointReference in project cxf by apache.
the class EndpointReferenceTest method testEndpointReferenceGetPort.
@Test
public void testEndpointReferenceGetPort() throws Exception {
BusFactory.setDefaultBus(getBus());
GreeterImpl greeter1 = new GreeterImpl();
try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
endpoint.publish("http://localhost:8080/test");
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
Document doc = StaxUtils.read(is);
DOMSource erXML = new DOMSource(doc);
EndpointReference endpointReference = EndpointReference.readFrom(erXML);
WebServiceFeature[] wfs = new WebServiceFeature[] {};
Greeter greeter = endpointReference.getPort(Greeter.class, wfs);
String response = greeter.greetMe("John");
assertEquals("Hello John", response);
}
}
use of javax.xml.ws.EndpointReference in project cxf by apache.
the class EndpointReferenceTest method testBindingProviderSOAPBinding.
@Test
public void testBindingProviderSOAPBinding() throws Exception {
javax.xml.ws.Service s = javax.xml.ws.Service.create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
assertNotNull(s);
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.EndpointReference in project cxf by apache.
the class EndpointReferenceTest method testProviderReadEndpointReference.
@Test
public void testProviderReadEndpointReference() throws Exception {
ProviderImpl provider = new ProviderImpl();
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
Document doc = StaxUtils.read(is);
DOMSource erXML = new DOMSource(doc);
EndpointReference endpointReference = provider.readEndpointReference(erXML);
assertNotNull(endpointReference);
assertTrue(endpointReference instanceof W3CEndpointReference);
}
use of javax.xml.ws.EndpointReference in project cxf by apache.
the class EndpointReferenceTest method testServiceGetPortUsingEndpointReference.
/*
* Any JAX-WS supported epr metadata MUST match the Service instances
* ServiceName, otherwise a WebServiceExeption MUST be thrown. Any JAX-WS
* supported epr metadata MUST match the PortName for the sei, otherwise a
* WebServiceException MUST be thrown. If the Service instance has an
* associated WSDL, its WSDL MUST be used to determine any binding
* information, anyWSDL in a JAX-WS suppported epr metadata MUST be ignored.
* If the Service instance does not have a WSDL, then any WSDL inlined in
* the JAX-WS supported metadata of the epr MUST be used to determine
* binding information. If there is not enough metadata in the Service
* instance or in the epr metadata to determine a port, then a
* WebServiceException MUST be thrown.
*/
@Test
public void testServiceGetPortUsingEndpointReference() throws Exception {
BusFactory.setDefaultBus(getBus());
GreeterImpl greeter1 = new GreeterImpl();
try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
endpoint.publish("http://localhost:8080/test");
javax.xml.ws.Service s = javax.xml.ws.Service.create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
Document doc = StaxUtils.read(is);
DOMSource erXML = new DOMSource(doc);
EndpointReference endpointReference = EndpointReference.readFrom(erXML);
WebServiceFeature[] wfs = new WebServiceFeature[] {};
Greeter greeter = s.getPort(endpointReference, Greeter.class, wfs);
String response = greeter.greetMe("John");
assertEquals("Hello John", response);
}
}
use of javax.xml.ws.EndpointReference in project cxf by apache.
the class WSDiscoveryClient method probe.
public List<EndpointReference> probe(QName type) {
ProbeType p = new ProbeType();
if (type != null) {
p.getTypes().add(type);
}
ProbeMatchesType pmt = probe(p, defaultProbeTimeout);
List<EndpointReference> er = new ArrayList<>();
for (ProbeMatchType pm : pmt.getProbeMatch()) {
for (String add : pm.getXAddrs()) {
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
builder.address(add);
// builder.serviceName(type);
// builder.endpointName(type);
er.add(builder.build());
}
}
return er;
}
Aggregations