Search in sources :

Example 76 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class ClientServiceConfigTest method talkToJaxWsHolder.

@Test
public void talkToJaxWsHolder() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setDataBinding(new AegisDatabinding());
    factory.setAddress("local://JaxWsEcho");
    Echo client = factory.create(Echo.class);
    Holder<String> sholder = new Holder<String>();
    client.echo("Channa Doll", sholder);
    assertEquals("Channa Doll", sholder.value);
}
Also used : Holder(javax.xml.ws.Holder) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 77 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class HolderOutInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    MessageContentsList outObjects = MessageContentsList.getContentsList(message);
    Exchange exchange = message.getExchange();
    OperationInfo op = exchange.getBindingOperationInfo() == null ? null : exchange.getBindingOperationInfo().getOperationInfo();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("op: " + op);
        if (null != op) {
            LOG.fine("op.hasOutput(): " + op.hasOutput());
            if (op.hasOutput()) {
                LOG.fine("op.getOutput().size(): " + op.getOutput().size());
            }
        }
    }
    if (op == null || !op.hasOutput() || op.getOutput().size() == 0) {
        LOG.fine("Returning.");
        return;
    }
    if (!Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) {
        List<MessagePartInfo> parts = op.getOutput().getMessageParts();
        MessageContentsList inObjects = MessageContentsList.getContentsList(exchange.getInMessage());
        if (inObjects != null) {
            if (!(inObjects == outObjects)) {
                for (int x = 0; x < inObjects.size(); x++) {
                    Object o = inObjects.get(x);
                    if (o instanceof Holder) {
                        outObjects.set(x + 1, o);
                    }
                }
            } else {
                LOG.severe("CANNOT_SET_HOLDER_OBJECTS");
                throw new Fault(new org.apache.cxf.common.i18n.Message("CANNOT_SET_HOLDER_OBJECTS", LOG));
            }
        }
        for (MessagePartInfo part : parts) {
            if (part.getIndex() > 0 && part.getTypeClass() != null) {
                Holder<?> holder = (Holder<?>) outObjects.get(part);
                outObjects.put(part, holder.value);
            }
        }
    } else {
        List<Object> holders = new ArrayList<>(outObjects);
        for (int x = 0; x < outObjects.size(); x++) {
            Object o = outObjects.get(x);
            if (o instanceof Holder) {
                outObjects.set(x, ((Holder<?>) o).value);
            } else {
                holders.set(x, null);
            }
        }
        message.put(HolderInInterceptor.CLIENT_HOLDERS, holders);
    }
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) MessageContentsList(org.apache.cxf.message.MessageContentsList) Holder(javax.xml.ws.Holder) ArrayList(java.util.ArrayList) Fault(org.apache.cxf.interceptor.Fault) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Exchange(org.apache.cxf.message.Exchange)

Example 78 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class HeaderClientServerTest method testOutHeader.

@Test
public void testOutHeader() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
    assertNotNull(wsdl);
    SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
    assertNotNull(service);
    TestHeader proxy = service.getPort(portName, TestHeader.class);
    try {
        TestHeader2 in = new TestHeader2();
        String val = new String(TestHeader2Response.class.getSimpleName());
        Holder<TestHeader2Response> out = new Holder<TestHeader2Response>();
        Holder<TestHeader2Response> outHeader = new Holder<TestHeader2Response>();
        for (int idx = 0; idx < 2; idx++) {
            val += idx;
            in.setRequestType(val);
            proxy.testHeader2(in, out, outHeader);
            assertEquals(val, out.value.getResponseType());
            assertEquals(val, outHeader.value.getResponseType());
        }
    } catch (UndeclaredThrowableException ex) {
        ex.printStackTrace();
        throw (Exception) ex.getCause();
    }
}
Also used : TestHeader(org.apache.header_test.TestHeader) Holder(javax.xml.ws.Holder) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) SOAPHeaderService(org.apache.header_test.SOAPHeaderService) TestHeader2Response(org.apache.header_test.types.TestHeader2Response) TestHeader2(org.apache.header_test.types.TestHeader2) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 79 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class HeaderClientServerTest method testHolderOutIsTheFirstMessagePart.

@Test
public void testHolderOutIsTheFirstMessagePart() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
    assertNotNull(wsdl);
    SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
    assertNotNull(service);
    TestHeader proxy = service.getPort(portName, TestHeader.class);
    Holder<SimpleAll> simpleAll = new Holder<SimpleAll>();
    SimpleAll sa = new SimpleAll();
    sa.setVarAttrString("varAttrString");
    sa.setVarInt(100);
    sa.setVarString("varString");
    simpleAll.value = sa;
    SimpleChoice sc = new SimpleChoice();
    sc.setVarString("scVarString");
    SimpleStruct ss = proxy.sendReceiveAnyType(simpleAll, sc);
    assertEquals(simpleAll.value.getVarString(), "scVarString");
    assertEquals(ss.getVarInt(), 200);
    assertEquals(ss.getVarAttrString(), "varAttrStringRet");
}
Also used : SimpleChoice(org.apache.tests.type_test.choice.SimpleChoice) TestHeader(org.apache.header_test.TestHeader) Holder(javax.xml.ws.Holder) SOAPHeaderService(org.apache.header_test.SOAPHeaderService) SimpleAll(org.apache.tests.type_test.all.SimpleAll) SimpleStruct(org.apache.tests.type_test.sequence.SimpleStruct) URL(java.net.URL) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 80 with Holder

use of javax.xml.ws.Holder in project cxf by apache.

the class HeaderClientServerTest method testHeaderPartBeforeBodyPart.

@Test
public void testHeaderPartBeforeBodyPart() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
    assertNotNull(wsdl);
    SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
    assertNotNull(service);
    TestHeader proxy = service.getPort(portName, TestHeader.class);
    TestHeader6 in = new TestHeader6();
    String val = new String(TestHeader6.class.getSimpleName());
    Holder<TestHeader3> inoutHeader = new Holder<TestHeader3>();
    for (int idx = 0; idx < 1; idx++) {
        val += idx;
        in.setRequestType(val);
        inoutHeader.value = new TestHeader3();
        TestHeader6Response returnVal = proxy.testHeaderPartBeforeBodyPart(inoutHeader, in);
        // inoutHeader copied to return
        // in copied to inoutHeader
        assertNotNull(returnVal);
        assertNull(returnVal.getResponseType());
        assertEquals(val, inoutHeader.value.getRequestType());
        in.setRequestType(null);
        inoutHeader.value.setRequestType(val);
        returnVal = proxy.testHeaderPartBeforeBodyPart(inoutHeader, in);
        assertNotNull(returnVal);
        assertEquals(val, returnVal.getResponseType());
        assertNull(inoutHeader.value.getRequestType());
    }
}
Also used : TestHeader(org.apache.header_test.TestHeader) TestHeader6Response(org.apache.header_test.types.TestHeader6Response) Holder(javax.xml.ws.Holder) SOAPHeaderService(org.apache.header_test.SOAPHeaderService) TestHeader6(org.apache.header_test.types.TestHeader6) URL(java.net.URL) TestHeader3(org.apache.header_test.types.TestHeader3) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Aggregations

Holder (javax.xml.ws.Holder)328 Test (org.junit.Test)204 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)77 Test (org.testng.annotations.Test)53 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)48 BigInteger (java.math.BigInteger)44 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)33 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)29 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)29 QName (javax.xml.namespace.QName)29 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)24 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)23 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 URL (java.net.URL)23 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)21 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)19 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)16 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)15