Search in sources :

Example 6 with Service

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);
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) WSService(com.sun.xml.ws.api.WSService) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) WSDLService(com.sun.xml.ws.api.model.wsdl.WSDLService) WSService(com.sun.xml.ws.api.WSService) Service(jakarta.xml.ws.Service)

Example 7 with Service

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

Example 8 with Service

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());
}
Also used : FeedType(client.dispatch.xmlhttp_jaxb.client.atom.FeedType) Service(jakarta.xml.ws.Service) JAXBContext(jakarta.xml.bind.JAXBContext) JAXBElement(jakarta.xml.bind.JAXBElement)

Example 9 with Service

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

Example 10 with Service

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);
}
Also used : QName(javax.xml.namespace.QName) Service(jakarta.xml.ws.Service) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) DataSource(jakarta.activation.DataSource)

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