Search in sources :

Example 41 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class XKMSClientFactory method create.

public static XKMSPortType create(String endpointAddress, Bus bus) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setBus(bus);
    factory.setServiceClass(XKMSPortType.class);
    factory.setAddress(endpointAddress);
    Map<String, Object> properties = new HashMap<>();
    properties.put("jaxb.additionalContextClasses", new Class[] { ResultDetails.class });
    factory.setProperties(properties);
    return (XKMSPortType) factory.create();
}
Also used : HashMap(java.util.HashMap) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) XKMSPortType(org.w3._2002._03.xkms_wsdl.XKMSPortType)

Example 42 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class ClientMtomXopWithJMSTest method createPort.

private static <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface, boolean enableMTOM) throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setBus(bus);
    factory.setServiceName(serviceName);
    factory.setServiceClass(serviceEndpointInterface);
    factory.setWsdlURL(ClientMtomXopTest.class.getResource("/wsdl/mtom_xop.wsdl").toExternalForm());
    factory.setFeatures(Collections.singletonList(cff));
    factory.getInInterceptors().add(new TestMultipartMessageInterceptor());
    factory.getOutInterceptors().add(new TestAttachmentOutInterceptor());
    @SuppressWarnings("unchecked") T proxy = (T) factory.create();
    BindingProvider bp = (BindingProvider) proxy;
    SOAPBinding binding = (SOAPBinding) bp.getBinding();
    binding.setMTOMEnabled(true);
    return proxy;
}
Also used : JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider)

Example 43 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class SoapActionTest method testSoap12Endpoint.

@Test
public void testSoap12Endpoint() throws Exception {
    JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
    pf.setServiceClass(Greeter.class);
    pf.setAddress(add12);
    SoapBindingConfiguration config = new SoapBindingConfiguration();
    config.setVersion(Soap12.getInstance());
    pf.setBindingConfig(config);
    pf.setBus(bus);
    Greeter greeter = (Greeter) pf.create();
    assertEquals("sayHi", greeter.sayHi("test"));
    assertEquals("sayHi2", greeter.sayHi2("test"));
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) RPCGreeter(org.apache.hello_world_soap_action.RPCGreeter) Greeter(org.apache.hello_world_soap_action.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 44 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class SoapActionTest method testWrappedSoap12ActionSpoofing.

@Test
public void testWrappedSoap12ActionSpoofing() throws Exception {
    JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
    pf.setServiceClass(WrappedGreeter.class);
    pf.setAddress(add14);
    SoapBindingConfiguration config = new SoapBindingConfiguration();
    config.setVersion(Soap12.getInstance());
    pf.setBindingConfig(config);
    pf.setBus(bus);
    WrappedGreeter greeter = (WrappedGreeter) pf.create();
    assertEquals("sayHi", greeter.sayHiRequestWrapped("test"));
    assertEquals("sayHi2", greeter.sayHiRequest2Wrapped("test"));
    // Now test spoofing attack
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_2");
    try {
        greeter.sayHiRequestWrapped("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
    // Test the other operation
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_1");
    try {
        greeter.sayHiRequest2Wrapped("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
    // Test a SOAP Action that does not exist in the binding
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_UNKNOWN");
    try {
        greeter.sayHiRequestWrapped("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) Test(org.junit.Test)

Example 45 with JaxWsProxyFactoryBean

use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.

the class SoapActionTest method testEndpoint.

@Test
public void testEndpoint() throws Exception {
    JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
    pf.setServiceClass(Greeter.class);
    pf.setAddress(add11);
    pf.setBus(bus);
    Greeter greeter = (Greeter) pf.create();
    assertEquals("sayHi", greeter.sayHi("test"));
    assertEquals("sayHi2", greeter.sayHi2("test"));
}
Also used : WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) RPCGreeter(org.apache.hello_world_soap_action.RPCGreeter) Greeter(org.apache.hello_world_soap_action.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Aggregations

JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)152 Test (org.junit.Test)71 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)21 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)19 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)14 Greeter (org.apache.hello_world_soap_http.Greeter)14 Client (org.apache.cxf.endpoint.Client)13 HashMap (java.util.HashMap)10 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)9 QName (javax.xml.namespace.QName)8 WrappedGreeter (org.apache.hello_world_soap_action.WrappedGreeter)8 BookStoreService (org.apache.cxf.systest.jaxws.tracing.BookStoreService)7 ArrayList (java.util.ArrayList)6 ClientFactoryBean (org.apache.cxf.frontend.ClientFactoryBean)6 Holder (javax.xml.ws.Holder)5 Server (org.apache.cxf.endpoint.Server)5 Greeter (org.apache.cxf.greeter_control.Greeter)5 Service (org.apache.cxf.service.Service)5 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)5 Metadata (org.apache.cxf.ws.mex.model._2004_09.Metadata)5