Search in sources :

Example 11 with SAAJInInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project cxf by apache.

the class CryptoCoverageCheckerTest method testOrder.

@Test
public void testOrder() throws Exception {
    // make sure the interceptors get ordered correctly
    SortedSet<Phase> phases = new TreeSet<>();
    phases.add(new Phase(Phase.PRE_PROTOCOL, 1));
    List<Interceptor<? extends Message>> lst = new ArrayList<>();
    lst.add(new MustUnderstandInterceptor());
    lst.add(new WSS4JInInterceptor());
    lst.add(new SAAJInInterceptor());
    lst.add(new CryptoCoverageChecker());
    PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
    chain.add(lst);
    String output = chain.toString();
    assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker"));
}
Also used : PhaseInterceptorChain(org.apache.cxf.phase.PhaseInterceptorChain) Phase(org.apache.cxf.phase.Phase) Message(org.apache.cxf.message.Message) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) MustUnderstandInterceptor(org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor) ArrayList(java.util.ArrayList) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) TreeSet(java.util.TreeSet) Interceptor(org.apache.cxf.interceptor.Interceptor) MustUnderstandInterceptor(org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor) PhaseInterceptor(org.apache.cxf.phase.PhaseInterceptor) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) Test(org.junit.Test)

Example 12 with SAAJInInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project cxf by apache.

the class RoundTripTest method setUpService.

@Before
public void setUpService() throws Exception {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();
    Service service = server.getEndpoint().getService();
    service.getInInterceptors().add(new SAAJInInterceptor());
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new SAAJOutInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());
    wsIn = new WSS4JInInterceptor();
    wsIn.setProperty(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
    wsIn.setProperty(ConfigurationConstants.DEC_PROP_FILE, "insecurity.properties");
    wsIn.setProperty(ConfigurationConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());
    service.getInInterceptors().add(wsIn);
    wsOut = new WSS4JOutInterceptor();
    wsOut.setProperty(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
    wsOut.setProperty(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties");
    wsOut.setProperty(ConfigurationConstants.USER, "myalias");
    wsOut.setProperty("password", "myAliasPassword");
    wsOut.setProperty(ConfigurationConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());
    service.getOutInterceptors().add(wsOut);
    // Create the client
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setServiceClass(Echo.class);
    proxyFac.setAddress("local://Echo");
    proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID);
    echo = (Echo) proxyFac.create();
    client = ClientProxy.getClient(echo);
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.getInInterceptors().add(wsIn);
    client.getInInterceptors().add(new SAAJInInterceptor());
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    client.getOutInterceptors().add(wsOut);
    client.getOutInterceptors().add(new SAAJOutInterceptor());
}
Also used : SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) Server(org.apache.cxf.endpoint.Server) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Service(org.apache.cxf.service.Service) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Before(org.junit.Before)

Example 13 with SAAJInInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project cxf by apache.

the class ClientMtomXopTest method testMtomXop.

@Test
public void testMtomXop() throws Exception {
    TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true, true);
    try {
        Holder<DataHandler> param = new Holder<>();
        Holder<String> name;
        byte[] bytes;
        InputStream in;
        InputStream pre = this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl");
        int fileSize = 0;
        for (int i = pre.read(); i != -1; i = pre.read()) {
            fileSize++;
        }
        int count = 50;
        byte[] data = new byte[fileSize * count];
        for (int x = 0; x < count; x++) {
            this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl").read(data, fileSize * x, fileSize);
        }
        Object[] validationTypes = new Object[] { Boolean.TRUE, SchemaValidationType.IN, SchemaValidationType.BOTH };
        for (Object validationType : validationTypes) {
            ((BindingProvider) mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
            param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
            name = new Holder<>("call detail");
            mtomPort.testXop(name, param);
            assertEquals("name unchanged", "return detail + call detail", name.value);
            assertNotNull(param.value);
            in = param.value.getInputStream();
            bytes = IOUtils.readBytesFromStream(in);
            assertEquals(data.length, bytes.length);
            in.close();
            param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
            name = new Holder<>("call detail");
            mtomPort.testXop(name, param);
            assertEquals("name unchanged", "return detail + call detail", name.value);
            assertNotNull(param.value);
            in = param.value.getInputStream();
            bytes = IOUtils.readBytesFromStream(in);
            assertEquals(data.length, bytes.length);
            in.close();
        }
        validationTypes = new Object[] { Boolean.FALSE, SchemaValidationType.OUT, SchemaValidationType.NONE };
        for (Object validationType : validationTypes) {
            ((BindingProvider) mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
            SAAJOutInterceptor saajOut = new SAAJOutInterceptor();
            SAAJInInterceptor saajIn = new SAAJInInterceptor();
            param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
            name = new Holder<>("call detail");
            mtomPort.testXop(name, param);
            assertEquals("name unchanged", "return detail + call detail", name.value);
            assertNotNull(param.value);
            in = param.value.getInputStream();
            bytes = IOUtils.readBytesFromStream(in);
            assertEquals(data.length, bytes.length);
            in.close();
            ClientProxy.getClient(mtomPort).getInInterceptors().add(saajIn);
            ClientProxy.getClient(mtomPort).getInInterceptors().add(saajOut);
            param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
            name = new Holder<>("call detail");
            mtomPort.testXop(name, param);
            assertEquals("name unchanged", "return detail + call detail", name.value);
            assertNotNull(param.value);
            in = param.value.getInputStream();
            bytes = IOUtils.readBytesFromStream(in);
            assertEquals(data.length, bytes.length);
            in.close();
            ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajIn);
            ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajOut);
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    } catch (Exception ex) {
        System.out.println(System.getProperties());
        throw ex;
    }
}
Also used : SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) InputStream(java.io.InputStream) Holder(javax.xml.ws.Holder) TestMtom(org.apache.cxf.mime.TestMtom) DataHandler(javax.activation.DataHandler) Endpoint(org.apache.cxf.endpoint.Endpoint) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) Test(org.junit.Test)

Example 14 with SAAJInInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project ddf by codice.

the class SamlProtocol method parseSoapMessage.

public static SOAPPart parseSoapMessage(String samlRequest) throws XMLStreamException {
    XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(new StringReader(samlRequest));
    SoapMessage soapMessage = new SoapMessage(Soap11.getInstance());
    SAAJInInterceptor.SAAJPreInInterceptor preInInterceptor = new SAAJInInterceptor.SAAJPreInInterceptor();
    soapMessage.setContent(XMLStreamReader.class, xmlStreamReader);
    preInInterceptor.handleMessage(soapMessage);
    SAAJInInterceptor inInterceptor = new SAAJInInterceptor();
    inInterceptor.handleMessage(soapMessage);
    return ((SOAPPart) soapMessage.getContent(Node.class));
}
Also used : SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) XMLStreamReader(javax.xml.stream.XMLStreamReader) StringReader(java.io.StringReader) SoapMessage(org.apache.cxf.binding.soap.SoapMessage)

Example 15 with SAAJInInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project ddf by codice.

the class SamlProtocol method parseSoapMessage.

public static SOAPPart parseSoapMessage(String samlRequest) throws XMLStreamException {
    XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(new StringReader(samlRequest));
    SoapMessage soapMessage = new SoapMessage(Soap11.getInstance());
    SAAJInInterceptor.SAAJPreInInterceptor preInInterceptor = new SAAJInInterceptor.SAAJPreInInterceptor();
    soapMessage.setContent(XMLStreamReader.class, xmlStreamReader);
    preInInterceptor.handleMessage(soapMessage);
    SAAJInInterceptor inInterceptor = new SAAJInInterceptor();
    inInterceptor.handleMessage(soapMessage);
    return ((SOAPPart) soapMessage.getContent(Node.class));
}
Also used : SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) XMLStreamReader(javax.xml.stream.XMLStreamReader) StringReader(java.io.StringReader) SoapMessage(org.apache.cxf.binding.soap.SoapMessage)

Aggregations

SAAJInInterceptor (org.apache.cxf.binding.soap.saaj.SAAJInInterceptor)21 SAAJOutInterceptor (org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor)10 Test (org.junit.Test)8 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)7 XMLStreamReader (javax.xml.stream.XMLStreamReader)5 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)5 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)5 Interceptor (org.apache.cxf.interceptor.Interceptor)5 Message (org.apache.cxf.message.Message)5 Endpoint (org.apache.cxf.endpoint.Endpoint)4 StringReader (java.io.StringReader)3 SOAPException (javax.xml.soap.SOAPException)3 SOAPMessage (javax.xml.soap.SOAPMessage)3 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)3 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2