Search in sources :

Example 11 with Service

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;
}
Also used : Service(jakarta.xml.ws.Service) Source(javax.xml.transform.Source)

Example 12 with Service

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);
}
Also used : Service(jakarta.xml.ws.Service) URI(java.net.URI) Source(javax.xml.transform.Source) Test(org.junit.jupiter.api.Test)

Example 13 with Service

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);
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) Service(jakarta.xml.ws.Service) Handler(jakarta.xml.ws.handler.Handler) SOAPHandler(jakarta.xml.ws.handler.soap.SOAPHandler) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 14 with Service

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)));
}
Also used : QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader) Service(jakarta.xml.ws.Service) WebService(jakarta.jws.WebService) URL(java.net.URL) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source)

Example 15 with Service

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());
}
Also used : TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader) Service(jakarta.xml.ws.Service) WebService(jakarta.jws.WebService) URL(java.net.URL) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source)

Aggregations

Service (jakarta.xml.ws.Service)81 QName (javax.xml.namespace.QName)45 Source (javax.xml.transform.Source)23 StreamSource (javax.xml.transform.stream.StreamSource)21 BindingProvider (jakarta.xml.ws.BindingProvider)17 Dispatch (jakarta.xml.ws.Dispatch)16 URL (java.net.URL)13 StringReader (java.io.StringReader)11 WebService (jakarta.jws.WebService)10 DataSource (jakarta.activation.DataSource)8 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)7 JAXBElement (jakarta.xml.bind.JAXBElement)7 Handler (jakarta.xml.ws.handler.Handler)7 WSBindingProvider (com.sun.xml.ws.developer.WSBindingProvider)6 SOAPMessage (jakarta.xml.soap.SOAPMessage)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 JAXBContext (jakarta.xml.bind.JAXBContext)5 Binding (jakarta.xml.ws.Binding)5 AddressingFeature (jakarta.xml.ws.soap.AddressingFeature)5 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)5