use of org.apache.cxf.binding.corba.CorbaTypeMap in project cxf by apache.
the class CorbaStreamInInterceptor method handleRequest.
private void handleRequest(Message msg) {
ORB orb;
ServiceInfo service;
CorbaDestination destination;
if (msg.getDestination() != null) {
destination = (CorbaDestination) msg.getDestination();
} else {
destination = (CorbaDestination) msg.getExchange().getDestination();
}
service = destination.getBindingInfo().getService();
CorbaMessage message = (CorbaMessage) msg;
Exchange exchange = message.getExchange();
CorbaTypeMap typeMap = message.getCorbaTypeMap();
BindingInfo bInfo = destination.getBindingInfo();
InterfaceInfo info = bInfo.getInterface();
String opName = exchange.get(String.class);
Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
OperationType opType = null;
BindingOperationInfo bopInfo = null;
QName opQName = null;
while (i.hasNext()) {
bopInfo = i.next();
if (bopInfo.getName().getLocalPart().equals(opName)) {
opType = bopInfo.getExtensor(OperationType.class);
opQName = bopInfo.getName();
break;
}
}
if (opType == null) {
throw new RuntimeException("Couldn't find the binding operation for " + opName);
}
orb = exchange.get(ORB.class);
ServerRequest request = exchange.get(ServerRequest.class);
NVList list = prepareArguments(message, info, opType, opQName, typeMap, destination, service);
request.arguments(list);
message.setList(list);
HandlerIterator paramIterator = new HandlerIterator(message, true);
CorbaTypeEventProducer eventProducer = null;
BindingMessageInfo msgInfo = bopInfo.getInput();
boolean wrap = false;
if (bopInfo.isUnwrappedCapable()) {
wrap = true;
}
if (wrap) {
// wrapper element around our args
QName wrapperElementQName = msgInfo.getMessageInfo().getName();
eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName, paramIterator, service, orb);
} else {
eventProducer = new ParameterEventProducer(paramIterator, service, orb);
}
CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
message.setContent(XMLStreamReader.class, reader);
}
use of org.apache.cxf.binding.corba.CorbaTypeMap in project cxf by apache.
the class WSDLToCorbaBindingTest method testMixedArraysMapping.
@Test
public void testMixedArraysMapping() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/arrays-mixed.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("X");
Definition model = generator.generateCORBABinding();
QName bName = new QName("http://schemas.apache.org/idl/anon.idl", "XCORBABinding", "tns");
Binding binding = model.getBinding(bName);
assertNotNull(binding);
assertEquals("XCORBABinding", binding.getQName().getLocalPart());
assertEquals("X", binding.getPortType().getQName().getLocalPart());
assertEquals(1, binding.getExtensibilityElements().size());
assertEquals(1, binding.getBindingOperations().size());
for (ExtensibilityElement extElement : getExtensibilityElements(binding)) {
if (extElement.getElementType().getLocalPart().equals("binding")) {
BindingType bindingType = (BindingType) extElement;
assertEquals(bindingType.getRepositoryID(), "IDL:X:1.0");
}
}
Iterator<?> tm = model.getExtensibilityElements().iterator();
assertTrue(tm.hasNext());
TypeMappingType tmt = (TypeMappingType) tm.next();
CorbaTypeMap typeMap = CorbaUtils.createCorbaTypeMap(Arrays.asList(tmt));
assertNull("All nested anonymous types should have \"nested\" names", typeMap.getType("item"));
// Checkstyle forces me to split the method...
assertMixedArraysMappingEasyTypes(typeMap);
// elem types are no longer strings from now.
assertMixedArraysMappingDifficultSequences(typeMap);
assertMixedArraysMappingDifficultArrays(typeMap);
Iterator<?> j = binding.getBindingOperations().iterator();
while (j.hasNext()) {
BindingOperation bindingOperation = (BindingOperation) j.next();
assertEquals(1, bindingOperation.getExtensibilityElements().size());
assertEquals(bindingOperation.getBindingInput().getName(), "op_a");
assertEquals(bindingOperation.getBindingOutput().getName(), "op_aResponse");
for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
if (extElement.getElementType().getLocalPart().equals("operation")) {
OperationType corbaOpType = (OperationType) extElement;
assertEquals(corbaOpType.getName(), "op_a");
assertEquals(1, corbaOpType.getParam().size());
assertNotNull(corbaOpType.getReturn());
ParamType paramtype = corbaOpType.getParam().get(0);
assertEquals(paramtype.getName(), "part1");
QName idltype = new QName("http://schemas.apache.org/idl/anon.idl/corba/typemap/", "MixedArrayType", "ns1");
assertEquals(paramtype.getIdltype(), idltype);
assertEquals(paramtype.getMode().toString(), "IN");
} else if (extElement.getElementType().getLocalPart().equals("typeMapping")) {
System.out.println("x");
}
}
}
// See if an IDL is able to produce from this CORBA Binding.
WSDLToIDLAction idlgen = new WSDLToIDLAction();
idlgen.setBindingName("XCORBABinding");
idlgen.setOutputFile("array.idl");
idlgen.generateIDL(model);
File f = new File("array.idl");
assertTrue("array.idl should be generated", f.exists());
} finally {
new File("array.idl").deleteOnExit();
}
}
use of org.apache.cxf.binding.corba.CorbaTypeMap in project cxf by apache.
the class CorbaUtils method createCorbaTypeMap.
public static CorbaTypeMap createCorbaTypeMap(List<TypeMappingType> tmTypes) {
CorbaTypeMap map = null;
if (tmTypes != null) {
// Currently, only one type map
TypeMappingType tmType = tmTypes.get(0);
map = new CorbaTypeMap(tmType.getTargetNamespace());
List<CorbaType> types = tmType.getStructOrExceptionOrUnion();
LOG.fine("Found " + types.size() + " types defined in the typemap");
for (Iterator<CorbaType> it = types.iterator(); it.hasNext(); ) {
CorbaType corbaType = it.next();
String name = corbaType.getName();
// There can be some instances where a prefix is added to the name by the tool
// (e.g. Object Reference Names). Since the name is read as a string, this
// prefix is added to the types name. Remove this as it is not needed.
int pos = name.lastIndexOf(":");
if (pos != -1) {
name = name.substring(pos + 1);
corbaType.setName(name);
}
map.addType(name, corbaType);
LOG.fine("Adding type " + name);
}
}
return map;
}
use of org.apache.cxf.binding.corba.CorbaTypeMap in project cxf by apache.
the class CorbaAnyHandlerTest method testCorbaAnyHandler.
@Test
public void testCorbaAnyHandler() {
Any a = orb.create_any();
a.insert_string("TestMessage");
QName anyName = new QName("AnyHandlerName");
QName anyIdlType = CorbaConstants.NT_CORBA_ANY;
TypeCode anyTC = orb.get_primitive_tc(TCKind.from_int(TCKind._tk_any));
CorbaTypeMap tm = new CorbaTypeMap(CorbaConstants.NU_WSDL_CORBA);
CorbaAnyHandler anyHandler = new CorbaAnyHandler(anyName, anyIdlType, anyTC, null);
anyHandler.setTypeMap(tm);
// Test the get/set value methods
anyHandler.setValue(a);
Any resultAny = anyHandler.getValue();
assertNotNull(resultAny);
String value = resultAny.extract_string();
assertEquals("TestMessage", value);
// Test get/set CorbaTypeMap methods
CorbaTypeMap resultTM = anyHandler.getTypeMap();
assertTrue(resultTM.getTargetNamespace().equals(CorbaConstants.NU_WSDL_CORBA));
}
use of org.apache.cxf.binding.corba.CorbaTypeMap in project cxf by apache.
the class CorbaUtilsTest method testErrorConditionNullTypeQName.
@Test
public void testErrorConditionNullTypeQName() {
try {
CorbaUtils.getTypeCode(orb, null, new CorbaTypeMap("dud:namespace"));
fail("expect exception on null type");
} catch (CorbaBindingException expected) {
// ignore
}
CorbaTypeMap typeMap = new CorbaTypeMap("dud:namespace");
QName seen = new QName("bla", "Bla");
Stack<QName> seenTypes = new Stack<QName>();
seenTypes.add(seen);
try {
CorbaUtils.getTypeCode(orb, null, typeMap, seenTypes);
fail("expect exception on null type");
} catch (CorbaBindingException expected) {
assertTrue("enclosed type is present", expected.getMessage().indexOf(seen.toString()) != -1);
}
CorbaType ctype = new CorbaType();
try {
CorbaUtils.getTypeCode(orb, null, ctype, typeMap);
fail("expect exception on null type");
} catch (CorbaBindingException expected) {
assertTrue("enclosed corba type is present", expected.getMessage().indexOf(ctype.toString()) != -1);
}
}
Aggregations