Search in sources :

Example 66 with Service

use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.

the class DispatchTest method testNoContentType.

/*
     * Check for service's response code. It shouldn't be 202 since service
     * sets a http status code even for oneway
     */
public void testNoContentType() throws Exception {
    BindingProvider bp = (BindingProvider) new Hello_Service().getHelloPort();
    String address = (String) bp.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    Service service = Service.create(new QName("", ""));
    service.addPort(new QName("", ""), HTTPBinding.HTTP_BINDING, address);
    Dispatch<DataSource> d = service.createDispatch(new QName("", ""), DataSource.class, Service.Mode.MESSAGE);
    // Set HTTP operation to PUT
    Map<String, Object> requestContext = d.getRequestContext();
    requestContext.put(MessageContext.HTTP_REQUEST_METHOD, "PUT");
    d.invoke(new DataSource() {

        public InputStream getInputStream() throws IOException {
            return null;
        }

        public OutputStream getOutputStream() throws IOException {
            return null;
        }

        public String getContentType() {
            return null;
        }

        public String getName() {
            return null;
        }
    });
}
Also used : QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) Service(jakarta.xml.ws.Service) BindingProvider(jakarta.xml.ws.BindingProvider) IOException(java.io.IOException) DataSource(jakarta.activation.DataSource)

Example 67 with Service

use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.

the class DispatchTest method testNoContentType.

/*
     * Service sends status code 200+no envelope
     */
public void testNoContentType() throws Exception {
    BindingProvider bp = (BindingProvider) new Hello_Service().getHelloPort();
    String address = (String) bp.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    Service service = Service.create(new QName("", ""));
    service.addPort(new QName("", ""), SOAPBinding.SOAP11HTTP_BINDING, address);
    Dispatch<SOAPMessage> d = service.createDispatch(new QName("", ""), SOAPMessage.class, Service.Mode.MESSAGE);
    String str = "<S:Envelope xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'><S:Body/></S:Envelope>";
    MessageFactory fact = MessageFactory.newInstance();
    MimeHeaders headers = new MimeHeaders();
    SOAPMessage req = fact.createMessage(headers, new ByteArrayInputStream(str.getBytes("UTF-8")));
    d.invokeOneWay(req);
}
Also used : MimeHeaders(jakarta.xml.soap.MimeHeaders) MessageFactory(jakarta.xml.soap.MessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) QName(javax.xml.namespace.QName) Service(jakarta.xml.ws.Service) BindingProvider(jakarta.xml.ws.BindingProvider) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 68 with Service

use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.

the class HelloLiteralTest method testDataSource.

public void testDataSource() throws Exception {
    Service service = Service.create(serviceQName);
    service.addPort(portQName, HTTPBinding.HTTP_BINDING, endpointAddress);
    Dispatch<DataSource> dispatch = service.createDispatch(portQName, DataSource.class, Service.Mode.MESSAGE);
    final SOAPMessage message = getSOAPMessage();
    DataSource ds = new DataSource() {

        public InputStream getInputStream() {
            try {
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                message.writeTo(bos);
                bos.close();
                return new ByteArrayInputStream(bos.toByteArray());
            } catch (Exception ioe) {
                throw new RuntimeException(ioe);
            }
        }

        public OutputStream getOutputStream() {
            return null;
        }

        public String getContentType() {
            return message.getMimeHeaders().getHeader("Content-Type")[0];
        }

        public String getName() {
            return "";
        }
    };
    DataSource result = dispatch.invoke(ds);
}
Also used : Service(jakarta.xml.ws.Service) DataSource(jakarta.activation.DataSource)

Example 69 with Service

use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.

the class HelloLiteralTest method createDispatch.

private Dispatch createDispatch() throws Exception {
    Service service = createService();
    service.addPort(portQName, HTTPBinding.HTTP_BINDING, setTransport(endpointAddress));
    Dispatch<Object> dispatch = service.createDispatch(portQName, createJAXBContext(), Service.Mode.PAYLOAD);
    return dispatch;
}
Also used : Service(jakarta.xml.ws.Service)

Example 70 with Service

use of jakarta.xml.ws.Service in project metro-jax-ws by eclipse-ee4j.

the class ClientEprTest method msEprGettertest.

private void msEprGettertest(BindingProvider bp, boolean hasWSDL) throws Exception {
    Service service = Service.create(serviceName);
    service.addPort(portName, jakarta.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
    Dispatch dispatch = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
    // validate ms epr
    MemberSubmissionEndpointReference msEpr = bp.getEndpointReference(MemberSubmissionEndpointReference.class);
    // printEPR(msEpr);
    assertTrue(EprUtil.validateEPR(msEpr, endpointAddress, serviceName, portName, portTypeName, hasWSDL));
    W3CEndpointReference w3cEpr = bp.getEndpointReference(W3CEndpointReference.class);
    // printEPR(w3cEpr);
    // assertTrue(EprUtil.validateEPR(w3cEpr,endpointAddress, serviceName, portName, portTypeName, hasWSDL));
    assertTrue(EprUtil.validateEPR(w3cEpr, endpointAddress, null, null, null, false));
}
Also used : W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) Service(jakarta.xml.ws.Service) Dispatch(jakarta.xml.ws.Dispatch) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

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