Search in sources :

Example 21 with Binding

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

the class HandlerChainTester method testHandlersOnReportPort.

public void testHandlersOnReportPort() {
    TestService_Service service = getService();
    ReportService testStub = service.getReportServicePort();
    Binding testBinding = ((BindingProvider) testStub).getBinding();
    List<Handler> chain = testBinding.getHandlerChain();
    // System.out.println(chain.size());
    assertEquals(2, chain.size());
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 22 with Binding

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

the class BindingTester 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)

Example 23 with Binding

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

the class BindingTester method testBinding1.

/*
     * test the binding objects for the right number of handlers
     */
public void testBinding1() throws Exception {
    TestService_Service service = getService();
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    // get the bindings
    Binding testBinding = ((BindingProvider) testStub).getBinding();
    Binding reportBinding = ((BindingProvider) reportStub).getBinding();
    assertNotNull("Binding object should not be null", testBinding);
    assertNotNull("Binding object should not be null", reportBinding);
    // check the handlers
    List<Handler> testHandlers = testBinding.getHandlerChain();
    List<Handler> reportHandlers = reportBinding.getHandlerChain();
    assertNotNull("Handler list should not be null", testHandlers);
    assertNotNull("Handler list should not be null", reportHandlers);
    // check number of handlers
    assertEquals("got wrong number of handlers in test binding", SERVICE_HANDLERS + TEST_PORT_HANDLERS + PROTOCOL_HANDLERS, testHandlers.size());
    assertEquals("got wrong number of handlers in report binding", SERVICE_HANDLERS + REPORT_PORT_HANDLERS + PROTOCOL_HANDLERS, reportHandlers.size());
    // check handler names -- see config file for order
    int[] testNames = { 4, 0, 5, 1, 7, 3 };
    int[] reportNames = { 4, 0, 2, 6, 7, 3 };
    String foundName = null;
    for (int i = 0; i < testNames.length; i++) {
        foundName = ((HasName) testHandlers.get(i)).getName();
        assertEquals("found unexpected handler in chain", CLIENT_PREFIX + testNames[i], foundName);
    }
    for (int i = 0; i < reportNames.length; i++) {
        foundName = ((HasName) reportHandlers.get(i)).getName();
        assertEquals("found unexpected handler in chain", CLIENT_PREFIX + reportNames[i], foundName);
    }
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 24 with Binding

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

the class EndToEndErrorTester method testServiceSpecificException1.

/*
     * Have the endpoint throw a service specific exception and make
     * sure that the client gets it back. Test case for bug 6232002.
     */
public void testServiceSpecificException1() throws Exception {
    TestService_Service service = getService();
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    // get stubs and clear the trackers
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    reportStub.clearHandlerTracker();
    tracker.clearAll();
    try {
        testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
        fail("did not receive exception (1)");
    } catch (MyFaultException mfe) {
    // passed
    } catch (Exception e) {
        fail("did not receive MyFaultException (1), received " + e);
    }
    // check closed handlers to be sure
    List<String> actualClosed = tracker.getClosedHandlers();
    int[] closed = { 7, 5, 4, 3, 1, 0 };
    assertEquals("Did not get proper number of closed handlers", closed.length, actualClosed.size());
    for (int i = 0; i < closed.length; i++) {
        assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], actualClosed.get(i));
    }
    // remove all client handlers and try again
    Binding binding = ((BindingProvider) testStub).getBinding();
    binding.setHandlerChain(new ArrayList<Handler>());
    tracker.clearAll();
    try {
        testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
        fail("did not receive exception (2)");
    } catch (MyFaultException mfe) {
    // passed
    } catch (Exception e) {
        fail("did not receive MyFaultException (2), received " + e);
    }
    // this just makes sure there really were no handlers
    actualClosed = tracker.getClosedHandlers();
    assertTrue("should not have been closed handlers", actualClosed.isEmpty());
}
Also used : Binding(jakarta.xml.ws.Binding) HandlerTracker(fromwsdl.handler.common.HandlerTracker) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider) WebServiceException(jakarta.xml.ws.WebServiceException) ProtocolException(jakarta.xml.ws.ProtocolException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 25 with Binding

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

the class ClientFeatureTest method validateFeatureList.

private void validateFeatureList(Object bindingProvider, String expectedEncoding) throws Exception {
    Binding binding = ((BindingProvider) bindingProvider).getBinding();
    WSFeatureList list = (((WSBinding) binding).getFeatures());
    // System.out.println(list);
    SerializationFeature encoding = list.get(SerializationFeature.class);
    if (expectedEncoding == null) {
        assertNull("There should not be a SerializationFeature", encoding);
    } else {
        assertEquals("Mismatched encoding in SerializationFeature", expectedEncoding, encoding.getEncoding());
    }
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) Binding(jakarta.xml.ws.Binding) HTTPBinding(jakarta.xml.ws.http.HTTPBinding) WSFeatureList(com.sun.xml.ws.api.WSFeatureList) BindingProvider(jakarta.xml.ws.BindingProvider) SerializationFeature(com.sun.xml.ws.developer.SerializationFeature)

Aggregations

Binding (jakarta.xml.ws.Binding)37 BindingProvider (jakarta.xml.ws.BindingProvider)32 Handler (jakarta.xml.ws.handler.Handler)30 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)17 ArrayList (java.util.ArrayList)8 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)5 Service (jakarta.xml.ws.Service)5 WebServiceException (jakarta.xml.ws.WebServiceException)5 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)4 HTTPBinding (jakarta.xml.ws.http.HTTPBinding)4 Source (javax.xml.transform.Source)3 BaseSOAPHandler (fromwsdl.handler.common.BaseSOAPHandler)2 BaseSOAPHandler (handler.handler_processing.common.BaseSOAPHandler)2 ProtocolException (jakarta.xml.ws.ProtocolException)2 HandlerResolver (jakarta.xml.ws.handler.HandlerResolver)2 PortInfo (jakarta.xml.ws.handler.PortInfo)2 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Localizable (com.sun.istack.localization.Localizable)1