Search in sources :

Example 1 with MAPCodec

use of org.apache.cxf.ws.addressing.soap.MAPCodec in project cxf by apache.

the class AddressingFeatureApplier method initializeProvider.

public void initializeProvider(WSAddressingFeature feature, InterceptorProvider provider, Bus bus) {
    MAPCodec mapCodec = MAPCodec.getInstance(bus);
    MAPAggregatorImpl mapAggregator = new MAPAggregatorImpl();
    mapAggregator.setAllowDuplicates(feature.isAllowDuplicates());
    mapAggregator.setUsingAddressingAdvisory(feature.isUsingAddressingAdvisory());
    mapAggregator.setAddressingRequired(feature.isAddressingRequired());
    if (feature.getMessageIdCache() != null) {
        mapAggregator.setMessageIdCache(feature.getMessageIdCache());
    }
    mapAggregator.setAddressingResponses(feature.getResponses());
    provider.getInInterceptors().add(mapAggregator);
    provider.getInInterceptors().add(mapCodec);
    provider.getOutInterceptors().add(mapAggregator);
    provider.getOutInterceptors().add(mapCodec);
    provider.getInFaultInterceptors().add(mapAggregator);
    provider.getInFaultInterceptors().add(mapCodec);
    provider.getOutFaultInterceptors().add(mapAggregator);
    provider.getOutFaultInterceptors().add(mapCodec);
}
Also used : MAPCodec(org.apache.cxf.ws.addressing.soap.MAPCodec)

Example 2 with MAPCodec

use of org.apache.cxf.ws.addressing.soap.MAPCodec in project cxf by apache.

the class WSAPureWsdlTest method testBasicInvocationTimeouts.

@Test
public void testBasicInvocationTimeouts() throws Exception {
    AddNumbersPortType port = getPort();
    ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add");
    HTTPConduit conduit = (HTTPConduit) ((Client) port).getConduit();
    conduit.getClient().setConnectionTimeout(25);
    conduit.getClient().setReceiveTimeout(10);
    try {
        // read timeout
        port.addNumbersAsync(5092, 25).get();
        fail("should have failed");
    } catch (Exception t) {
        // expected
        assertTrue(t.getCause().toString(), t.getCause() instanceof java.net.SocketTimeoutException);
    }
    AsyncHandler<AddNumbersResponse> handler = new AsyncHandler<AddNumbersResponse>() {

        public void handleResponse(Response<AddNumbersResponse> res) {
            // System.out.println("in handle response");
            synchronized (this) {
                notifyAll();
            }
        }
    };
    synchronized (handler) {
        port.addNumbersAsync(5092, 25, handler);
        handler.wait(1000);
    }
    try {
        // connection timeout
        ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT2 + "/jaxws/add");
        port.addNumbersAsync(25, 25).get();
        fail("should have failed");
    } catch (Exception t) {
        // expected
        assertTrue(t.getCause().getCause().toString(), t.getCause().getCause() instanceof java.net.ConnectException || t.getCause().getCause() instanceof java.net.SocketTimeoutException);
    }
    synchronized (handler) {
        port.addNumbersAsync(25, 25, handler);
        handler.wait(1000);
    }
    MAPCodec mp = getMAPCodec((Client) port);
    assertEquals(0, mp.getUncorrelatedExchanges().size());
}
Also used : AsyncHandler(javax.xml.ws.AsyncHandler) AddNumbersResponse(org.apache.cxf.systest.ws.addr_feature.AddNumbersResponse) MAPCodec(org.apache.cxf.ws.addressing.soap.MAPCodec) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) AddNumbersPortType(org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) AddNumbersResponse(org.apache.cxf.systest.ws.addr_feature.AddNumbersResponse) Response(javax.xml.ws.Response) Test(org.junit.Test)

Example 3 with MAPCodec

use of org.apache.cxf.ws.addressing.soap.MAPCodec in project cxf by apache.

the class WSAPureWsdlTest method testBasicInvocation.

@Test
public void testBasicInvocation() throws Exception {
    ByteArrayOutputStream input = setupInLogging();
    ByteArrayOutputStream output = setupOutLogging();
    Response<AddNumbersResponse> resp;
    AddNumbersPortType port = getPort();
    ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add");
    assertEquals(3, port.addNumbers(1, 2));
    String base = "http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/";
    assertLogContains(output.toString(), "//wsa:Action", base + "addNumbersRequest");
    assertLogContains(input.toString(), "//wsa:Action", base + "addNumbersResponse");
    resp = port.addNumbers3Async(1, 2);
    assertEquals(3, resp.get().getReturn());
    ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/doesntexist");
    resp = port.addNumbers3Async(1, 2);
    try {
        resp.get();
    } catch (ExecutionException ex) {
        assertTrue("Found " + ex.getCause().getClass(), ex.getCause() instanceof IOException);
        Client c = ClientProxy.getClient(port);
        for (Interceptor<? extends Message> m : c.getOutInterceptors()) {
            if (m instanceof MAPCodec) {
                assertTrue(((MAPCodec) m).getUncorrelatedExchanges().isEmpty());
            }
        }
    }
}
Also used : AddNumbersPortType(org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType) Message(org.apache.cxf.message.Message) AddNumbersResponse(org.apache.cxf.systest.ws.addr_feature.AddNumbersResponse) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Client(org.apache.cxf.endpoint.Client) Interceptor(org.apache.cxf.interceptor.Interceptor) MAPCodec(org.apache.cxf.ws.addressing.soap.MAPCodec) Test(org.junit.Test)

Example 4 with MAPCodec

use of org.apache.cxf.ws.addressing.soap.MAPCodec in project cxf by apache.

the class NestedAddressingPolicyTest method greetMeWSA.

@Test
public void greetMeWSA() throws Exception {
    // use a wsa-enabled client
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    BasicGreeterService gs = new BasicGreeterService();
    final Greeter greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LoggingInInterceptor in = new LoggingInInterceptor();
    LoggingOutInterceptor out = new LoggingOutInterceptor();
    MAPCodec mapCodec = MAPCodec.getInstance(bus);
    MAPAggregatorImpl mapAggregator = new MAPAggregatorImpl();
    bus.getInInterceptors().add(in);
    bus.getInInterceptors().add(mapCodec);
    bus.getInInterceptors().add(mapAggregator);
    bus.getOutInterceptors().add(out);
    bus.getOutInterceptors().add(mapCodec);
    bus.getOutInterceptors().add(mapAggregator);
    String s = greeter.greetMe("mytest");
    assertEquals("MYTEST", s);
    ((Closeable) greeter).close();
}
Also used : MAPAggregatorImpl(org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.cxf.greeter_control.Greeter) Closeable(java.io.Closeable) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) BasicGreeterService(org.apache.cxf.greeter_control.BasicGreeterService) MAPCodec(org.apache.cxf.ws.addressing.soap.MAPCodec) Test(org.junit.Test)

Aggregations

MAPCodec (org.apache.cxf.ws.addressing.soap.MAPCodec)4 Test (org.junit.Test)3 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2 AddNumbersPortType (org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType)2 AddNumbersResponse (org.apache.cxf.systest.ws.addr_feature.AddNumbersResponse)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Closeable (java.io.Closeable)1 AsyncHandler (javax.xml.ws.AsyncHandler)1 Response (javax.xml.ws.Response)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 Client (org.apache.cxf.endpoint.Client)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1 BasicGreeterService (org.apache.cxf.greeter_control.BasicGreeterService)1 Greeter (org.apache.cxf.greeter_control.Greeter)1 Interceptor (org.apache.cxf.interceptor.Interceptor)1 Message (org.apache.cxf.message.Message)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1