use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class GoogleClient method createDispatch.
private Dispatch<Source> createDispatch(URI uri) {
// Create service and port to obtain Dispatch instance
Service s = jakarta.xml.ws.Service.create(GOOGLE_SERVICE_NAME);
s.addPort(GOOGLE_PORT_NAME, HTTPBinding.HTTP_BINDING, uri.toString());
Dispatch<Source> d = s.createDispatch(GOOGLE_PORT_NAME, Source.class, Service.Mode.PAYLOAD);
d.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, "GET");
return d;
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class DispatchAddNumbersTest method testService.
@Test
public void testService() throws Exception {
DispatchAddNumbersTest client = new DispatchAddNumbersTest();
Service service = client.createService();
URI endpointURI = new URI(endpointAddress);
String path = endpointURI.getPath();
String query = endpointURI.getQuery();
service.addPort(portQName, HTTPBinding.HTTP_BINDING, endpointAddress);
Dispatch<Source> d = service.createDispatch(portQName, Source.class, Service.Mode.MESSAGE);
Map<String, Object> requestContext = d.getRequestContext();
requestContext.put(MessageContext.HTTP_REQUEST_METHOD, "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 AddNumbersClient method testAddressingWithNoWSDLwithHandler.
public void testAddressingWithNoWSDLwithHandler() throws Exception {
Service service = Service.create(SERVICE_QNAME);
service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING, getAddress());
Dispatch<SOAPMessage> dispatch = service.createDispatch(PORT_QNAME, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature());
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, ADD_NUMBERS_ACTION);
String message = "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body>" + "<addNumbers xmlns=\"http://example.com/\">" + "<number1>10</number1>" + "<number2>10</number2>" + "</addNumbers>" + "</S:Body></S:Envelope>";
List<Handler> handlerChain = dispatch.getBinding().getHandlerChain();
handlerChain.add(new MyHandler());
dispatch.getBinding().setHandlerChain(handlerChain);
WsaUtils.invoke(dispatch, message);
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class SourceTest method invoke.
private Source invoke(String address) throws Exception {
QName portName = new QName(NS, "RpcLitPort");
QName serviceName = new QName(NS, "RpcLitEndpoint");
Service service = Service.create(new URL(address + "?wsdl"), serviceName);
Dispatch<Source> d = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
String body = "<ns0:echoInteger xmlns:ns0=\"http://echo.abstract.org/\"><arg0>2</arg0></ns0:echoInteger>";
return d.invoke(new StreamSource(new StringReader(body)));
}
use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.
the class OnewayTest method verify.
private String verify(String address) throws Exception {
QName portName = new QName(NS, "OnewayEndpointPort");
QName serviceName = new QName(NS, "OnewayEndpointService");
Service service = Service.create(new URL(address + "?wsdl"), serviceName);
Dispatch<Source> d = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
String body = "<ns0:verifyInteger xmlns:ns0='" + NS + "'/>";
Source response = d.invoke(new StreamSource(new StringReader(body)));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.transform(response, new StreamResult(bos));
bos.close();
return new String(bos.toByteArray());
}
Aggregations