use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class ProviderImpl method getPort.
public <T> T getPort(EndpointReference endpointReference, Class<T> clazz, WebServiceFeature... webServiceFeatures) {
/*
final @NotNull MemberSubmissionEndpointReference msepr =
EndpointReferenceUtil.transform(MemberSubmissionEndpointReference.class, endpointReference);
WSService service = new WSServiceDelegate(msepr.toWSDLSource(), msepr.serviceName.name, Service.class);
*/
if (endpointReference == null)
throw new WebServiceException(ProviderApiMessages.NULL_EPR());
WSEndpointReference wsepr = new WSEndpointReference(endpointReference);
WSEndpointReference.Metadata metadata = wsepr.getMetaData();
WSService service;
if (metadata.getWsdlSource() != null)
service = (WSService) createServiceDelegate(metadata.getWsdlSource(), metadata.getServiceName(), Service.class);
else
throw new WebServiceException("WSDL metadata is missing in EPR");
return service.getPort(wsepr, clazz, webServiceFeatures);
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class DispatchAddNumbersClient method main.
public static void main(String[] args) throws Exception {
DispatchAddNumbersClient client = new DispatchAddNumbersClient();
Service service = client.createService();
URI endpointURI = new URI(endpointAddress.toString());
String path = null;
String query = null;
if (endpointURI != null) {
path = endpointURI.getPath();
query = endpointURI.getQuery();
}
service.addPort(portQName, HTTPBinding.HTTP_BINDING, endpointAddress.toString());
Dispatch<Source> d = service.createDispatch(portQName, Source.class, Service.Mode.MESSAGE);
Map<String, Object> requestContext = d.getRequestContext();
requestContext.put(MessageContext.HTTP_REQUEST_METHOD, new String("GET"));
requestContext.put(MessageContext.QUERY_STRING, queryString);
// this is the original path part of uri
requestContext.put(MessageContext.PATH_INFO, path);
System.out.println("Invoking Restful GET Request with query string " + queryString);
Source result = d.invoke(null);
printSource(result);
requestContext.put(MessageContext.PATH_INFO, pathInfo);
System.out.println("Invoking Restful GET Request with path info " + pathInfo);
result = d.invoke(null);
printSource(result);
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class XMLHttp_JAXB method testXMLHttpJAXBPAYLOAD.
public void testXMLHttpJAXBPAYLOAD() throws JAXBException {
if (ClientServerTestUtil.useLocal()) {
return;
}
Service s = Service.create(GOOGLE_SERVICE_NAME);
s.addPort(GOOGLE_PORT_NAME, HTTPBinding.HTTP_BINDING, getGoogleURL("JAXB"));
// Get a Dispatch interface for the Yahoo News Search service and configure it
JAXBContext jbc = JAXBContext.newInstance("client.dispatch.xmlhttp_jaxb.client.atom");
Dispatch<Object> d = s.createDispatch(GOOGLE_PORT_NAME, jbc, Service.Mode.PAYLOAD);
d.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, "GET");
// Execute the search iterate through the results
JAXBElement<FeedType> o = (JAXBElement<FeedType>) d.invoke(null);
FeedType feed = o.getValue();
assertNotNull(feed);
List<Object> authorOrCategoryOrContributor = feed.getAuthorOrCategoryOrContributor();
assertNotNull(authorOrCategoryOrContributor);
assertTrue(authorOrCategoryOrContributor.size() > 0);
LOGGER.finest("Google Custom Search successfully read as JAXB Object: authorOrCategoryOrContributor.size() = " + authorOrCategoryOrContributor.size());
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class XMLHttpClient method testHttpGetPAYLOAD.
public void testHttpGetPAYLOAD() throws URISyntaxException, TransformerException {
if (ClientServerTestUtil.useLocal()) {
return;
}
String address = getGoogleURL("JAX-WS");
System.out.println("address = " + address);
Service s = Service.create(GOOGLE_SERVICE_NAME);
s.addPort(GOOGLE_PORT_NAME, HTTPBinding.HTTP_BINDING, address);
Dispatch<Source> d = s.createDispatch(GOOGLE_PORT_NAME, Source.class, Service.Mode.PAYLOAD);
d.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, "GET");
Source result = d.invoke(null);
System.out.println(sourceToXMLString(result));
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class XMLHttp_DataSource method testXMLHttpDataSource.
public void testXMLHttpDataSource() {
if (ClientServerTestUtil.useLocal())
return;
URI nsURI = null;
try {
nsURI = new URI("urn:yahoo:yn");
} catch (URISyntaxException e) {
e.printStackTrace();
}
QName serviceName = new QName("yahoo", nsURI.toString());
QName portName = new QName("yahoo_port", nsURI.toString());
Service s = Service.create(serviceName);
URI address = null;
try {
address = new URI("http", null, "api.search.yahoo.com", 80, "/ImageSearchService/V1/imageSearch", "appid=YahooDemo&format=jpeg&query=dog", null);
} catch (URISyntaxException e) {
e.printStackTrace();
}
s.addPort(portName, HTTPBinding.HTTP_BINDING, address.toString());
Dispatch<DataSource> d = s.createDispatch(portName, DataSource.class, Service.Mode.MESSAGE);
Map<String, Object> requestContext = d.getRequestContext();
requestContext.put(MessageContext.HTTP_REQUEST_METHOD, new String("GET"));
// Execute the search iterate through the results
Object rs = d.invoke(null);
assertTrue(rs != null);
assertTrue(rs instanceof DataSource);
}
Aggregations