Search in sources :

Example 16 with BindingProvider

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

the class SOAPAction1Test method testSOAPActionWithDispatch_WithUse_true.

// use is set to true, so action property is effective
public void testSOAPActionWithDispatch_WithUse_true() throws JAXBException {
    TestEndpoint1 port = new TestEndpointService1().getTestEndpointPort1();
    String address = (String) ((BindingProvider) port).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    Service s = Service.create(new QName("http://client.soapaction_use.server/", "TestEndpointService1"));
    s.addPort(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), SOAPBinding.SOAP11HTTP_BINDING, address);
    Dispatch<Object> d = s.createDispatch(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), JAXBContext.newInstance(ObjectFactory.class), Service.Mode.PAYLOAD);
    ((BindingProvider) d).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, action);
    ((BindingProvider) d).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
    JAXBElement<String> r = (JAXBElement<String>) d.invoke(new ObjectFactory().createEchoSOAPAction("dummy"));
    assertEquals(action, r.getValue());
}
Also used : QName(javax.xml.namespace.QName) Service(jakarta.xml.ws.Service) BindingProvider(jakarta.xml.ws.BindingProvider) JAXBElement(jakarta.xml.bind.JAXBElement)

Example 17 with BindingProvider

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

the class SOAPAction1Test method testSOAPActionWithDispatch_WithoutUse.

// since use property is default (false), action property is ineffective
public void testSOAPActionWithDispatch_WithoutUse() throws JAXBException {
    TestEndpoint1 port = new TestEndpointService1().getTestEndpointPort1();
    String address = (String) ((BindingProvider) port).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    Service s = Service.create(new QName("http://client.soapaction_use.server/", "TestEndpointService1"));
    s.addPort(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), SOAPBinding.SOAP11HTTP_BINDING, address);
    Dispatch<Object> d = s.createDispatch(new QName("http://client.soapaction_use.server/", "TestEndpointPort1"), JAXBContext.newInstance(ObjectFactory.class), Service.Mode.PAYLOAD);
    ((BindingProvider) d).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, action);
    JAXBElement<String> r = (JAXBElement<String>) d.invoke(new ObjectFactory().createEchoSOAPAction("dummy"));
    assertEquals(empty_action, r.getValue());
}
Also used : QName(javax.xml.namespace.QName) Service(jakarta.xml.ws.Service) BindingProvider(jakarta.xml.ws.BindingProvider) JAXBElement(jakarta.xml.bind.JAXBElement)

Example 18 with BindingProvider

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

the class Util method addHandler.

// utility methods to be made available to the test clients
/**
 * Method used to add a Handler to a stub or dispatch object.
 */
public static void addHandler(Handler handler, Object provider) {
    BindingProvider bindingProvider = (BindingProvider) provider;
    Binding binding = bindingProvider.getBinding();
    List<Handler> handlers = binding.getHandlerChain();
    handlers.add(handler);
    binding.setHandlerChain(handlers);
}
Also used : Binding(jakarta.xml.ws.Binding) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 19 with BindingProvider

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

the class Util method clearHandlers.

/**
 * Method used to clear any handlers from a stub or dispatch object.
 */
public static void clearHandlers(Object provider) {
    BindingProvider bindingProvider = (BindingProvider) provider;
    Binding binding = bindingProvider.getBinding();
    binding.setHandlerChain(new java.util.ArrayList());
}
Also used : Binding(jakarta.xml.ws.Binding) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 20 with BindingProvider

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

the class BindingTest method testSoapBinding1.

/*
     * tests for SOAPBinding.
     *
     */
public void testSoapBinding1() throws Exception {
    TestService_Service service = getService();
    TestService stub = getTestStub(service);
    Binding binding = ((BindingProvider) stub).getBinding();
    if (binding instanceof SOAPBinding) {
        SOAPBinding sb = (SOAPBinding) binding;
        assertNotNull("did not get SOAPBinding", sb);
        Set<String> roles = sb.getRoles();
        assertNotNull("roles cannot be null", roles);
        assertFalse("found zero roles in SOAPBinding", roles.isEmpty());
        assertTrue("soap 1.1 \"next\" role is not included in roles", roles.contains(NEXT_1_1));
        assertFalse("soap 1.2 \"none\" role cannot be included in roles", roles.contains(NONE));
        // try setting new roles
        Set<String> newSet = new HashSet<String>();
        String testURI = "http://java.sun.com/justanexample";
        newSet.add(testURI);
        sb.setRoles(newSet);
        try {
            newSet.add(NONE);
            sb.setRoles(newSet);
            throw new RuntimeException("did not get jaxrpc exception for setting \"none\" role");
        } catch (WebServiceException e) {
        // pass
        }
        newSet.addAll(roles);
        newSet.remove(NONE);
        sb.setRoles(newSet);
        // add empty set and check for next/ultimate
        newSet = new HashSet<String>();
        sb.setRoles(newSet);
        Set<String> newSet2 = sb.getRoles();
        assertTrue("soap 1.1 \"next\" role is not included in roles", newSet2.contains(NEXT_1_1));
        assertFalse("soap 1.2 \"none\" role cannot be included in roles", newSet2.contains(NONE));
    } else {
        throw new Exception("binding is not a SOAPBinding");
    }
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) WebServiceException(jakarta.xml.ws.WebServiceException) SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) BindingProvider(jakarta.xml.ws.BindingProvider) WebServiceException(jakarta.xml.ws.WebServiceException) HashSet(java.util.HashSet)

Aggregations

BindingProvider (jakarta.xml.ws.BindingProvider)75 Binding (jakarta.xml.ws.Binding)32 Handler (jakarta.xml.ws.handler.Handler)28 Service (jakarta.xml.ws.Service)17 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)17 QName (javax.xml.namespace.QName)16 URL (java.net.URL)9 ArrayList (java.util.ArrayList)8 Source (javax.xml.transform.Source)8 SOAPMessage (jakarta.xml.soap.SOAPMessage)7 MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)7 List (java.util.List)6 Map (java.util.Map)6 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)5 JAXBElement (jakarta.xml.bind.JAXBElement)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 StreamSource (javax.xml.transform.stream.StreamSource)5 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)4 MimeHeaders (jakarta.xml.soap.MimeHeaders)4 WebServiceException (jakarta.xml.ws.WebServiceException)4