use of org.apache.cxf.binding.corba.wsdl.TypeMappingType in project cxf by apache.
the class CorbaConduitTest method testBuildExceptionListWithExceptions.
@Test
public void testBuildExceptionListWithExceptions() throws Exception {
CorbaConduit conduit = setupCorbaConduit(false);
Message msg = new MessageImpl();
CorbaMessage message = new CorbaMessage(msg);
TestUtils testUtils = new TestUtils();
CorbaDestination destination = testUtils.getExceptionTypesTestDestination();
EndpointInfo endpointInfo2 = destination.getEndPointInfo();
QName name = new QName("http://schemas.apache.org/idl/except", "review_data", "");
BindingOperationInfo bInfo = destination.getBindingInfo().getOperation(name);
OperationType opType = bInfo.getExtensor(OperationType.class);
CorbaTypeMap typeMap = null;
List<TypeMappingType> corbaTypes = endpointInfo2.getService().getDescription().getExtensors(TypeMappingType.class);
if (corbaTypes != null) {
typeMap = CorbaUtils.createCorbaTypeMap(corbaTypes);
}
ExceptionList exList = conduit.getExceptionList(conduit.getOperationExceptions(opType, typeMap), message, opType);
assertNotNull("ExceptionList is not null", exList != null);
assertNotNull("TypeCode is not null", exList.item(0) != null);
assertEquals("ID should be equal", exList.item(0).id(), "IDL:BadRecord:1.0");
assertEquals("ID should be equal", exList.item(0).name(), "BadRecord");
assertEquals("ID should be equal", exList.item(0).member_count(), 2);
assertEquals("ID should be equal", exList.item(0).member_name(0), "reason");
assertNotNull("Member type is not null", exList.item(0).member_type(0) != null);
}
use of org.apache.cxf.binding.corba.wsdl.TypeMappingType in project cxf by apache.
the class CorbaHandlerUtilsTest method setUp.
@Before
public void setUp() throws Exception {
bus = BusFactory.getDefaultBus();
BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
factory = bfm.getBindingFactory("http://cxf.apache.org/bindings/corba");
bfm.registerBindingFactory(CorbaConstants.NU_WSDL_CORBA, factory);
java.util.Properties props = System.getProperties();
props.put("yoko.orb.id", "CXF-CORBA-Server-Binding");
orb = ORB.init(new String[0], props);
CorbaDestination destination = getDestination();
service = destination.getBindingInfo().getService();
List<TypeMappingType> corbaTypes = service.getDescription().getExtensors(TypeMappingType.class);
typeMap = CorbaUtils.createCorbaTypeMap(corbaTypes);
}
use of org.apache.cxf.binding.corba.wsdl.TypeMappingType in project cxf by apache.
the class ScopedNameVisitor method populateAliasSchemaType.
protected static void populateAliasSchemaType(CorbaType corbaType, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
holder.setCorbaType(corbaType);
Alias alias = (Alias) corbaType;
// loop through alias base types, till you get a non-alias corba type
CorbaType type = findCorbaType(typeMap, alias.getBasetype());
while ((type != null) && (type instanceof Alias)) {
alias = (Alias) type;
type = findCorbaType(typeMap, alias.getBasetype());
}
QName tname;
if (type == null) {
// it must be a primitive type
tname = xmlSchemaPrimitiveMap.get(alias.getBasetype());
} else {
tname = type.getType();
}
XmlSchemaType stype = schemas.getTypeByQName(tname);
if (stype == null) {
XmlSchema xmlSchema = wsdlVisitor.getManager().getXmlSchema(tname.getNamespaceURI());
if (xmlSchema != null) {
stype = xmlSchema.getTypeByName(tname);
} else {
stype = wsdlVisitor.getSchema().getTypeByName(tname);
}
}
holder.setSchemaType(stype);
}
use of org.apache.cxf.binding.corba.wsdl.TypeMappingType in project cxf by apache.
the class ScopedNameVisitor method findScopeSchemaType.
// Searches this scope for the schema type.
private static boolean findScopeSchemaType(Scope scopedName, XmlSchema schemaRef, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
ModuleToNSMapper mapper = wsdlVisitor.getModuleToNSMapper();
WSDLSchemaManager manager = wsdlVisitor.getManager();
boolean result = findNonSchemaType(scopedName.toString(), wsdlVisitor, holder);
if (!result) {
XmlSchema xmlSchema = schemaRef;
String tns = wsdlVisitor.getModuleToNSMapper().map(scopedName.getParent());
if (tns != null) {
xmlSchema = wsdlVisitor.getManager().getXmlSchema(tns);
}
XmlSchemaType stype = null;
if (xmlSchema != null) {
// Exceptions are treated as a special case as for the
// doc/literal style
// in the schema we will have an element and a complextype
// so the name
// and the typename will be different.
final String scopedNameString;
if (mapper.isDefaultMapping()) {
scopedNameString = scopedName.toString();
} else {
scopedNameString = scopedName.tail();
}
final QName qname;
if (exceptionMode) {
qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString + "Type");
} else {
qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString);
}
stype = xmlSchema.getTypeByName(qname);
if (stype == null) {
stype = schemas.getTypeByQName(qname);
}
}
if (stype != null) {
result = true;
}
if (result && holder != null) {
holder.setSchemaType(stype);
holder.setCorbaType(getCorbaSchemaType(xmlSchema, typeMap, stype, scopedName));
// add a xmlschema import
if (!schemaRef.getTargetNamespace().equals(xmlSchema.getTargetNamespace())) {
String importFile = wsdlVisitor.getOutputDir() + System.getProperty("file.separator") + scopedName.getParent().toString("_");
manager.addXmlSchemaImport(schemaRef, xmlSchema, importFile);
}
}
}
return result;
}
use of org.apache.cxf.binding.corba.wsdl.TypeMappingType in project cxf by apache.
the class ScopedNameVisitor method findNonSchemaType.
protected static boolean findNonSchemaType(String name, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
boolean result = false;
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
QName qname = new QName(typeMap.getTargetNamespace(), name);
CorbaType corbaType = findCorbaType(typeMap, qname);
if (corbaType != null) {
if (corbaType instanceof Alias) {
result = true;
if (holder != null) {
populateAliasSchemaType(corbaType, wsdlVisitor, holder);
}
} else if (((corbaType instanceof Sequence) || (corbaType instanceof Anonsequence)) && ((corbaType.getType().equals(Constants.XSD_BASE64)))) {
// special case of sequence of octets
result = true;
if (holder != null) {
holder.setCorbaType(corbaType);
holder.setSchemaType(schemas.getTypeByQName(corbaType.getType()));
}
}
}
return result;
}
Aggregations