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);
}
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);
}
}
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();
}
}
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");
}
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());
}
}
Aggregations