use of org.apache.cxf.binding.corba.wsdl.BindingType in project cxf by apache.
the class CorbaDSIServant method init.
public void init(ORB theOrb, POA poa, CorbaDestination dest, MessageObserver observer, CorbaTypeMap map) {
orb = theOrb;
servantPOA = poa;
destination = dest;
incomingObserver = observer;
typeMap = map;
// Get the list of interfaces that this servant will support
try {
BindingType bindType = destination.getBindingInfo().getExtensor(BindingType.class);
if (bindType == null) {
throw new CorbaBindingException("Unable to determine corba binding information");
}
List<String> bases = bindType.getBases();
interfaces = new ArrayList<>();
interfaces.add(bindType.getRepositoryID());
for (Iterator<String> iter = bases.iterator(); iter.hasNext(); ) {
interfaces.add(iter.next());
}
} catch (java.lang.Exception ex) {
LOG.log(Level.SEVERE, "Couldn't initialize the corba DSI servant");
throw new CorbaBindingException(ex);
}
// Build the list of CORBA operations and the WSDL operations they map to. Note that
// the WSDL operation name may not always match the CORBA operation name.
BindingInfo bInfo = destination.getBindingInfo();
Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
operationMap = new HashMap<>(bInfo.getOperations().size());
while (i.hasNext()) {
BindingOperationInfo bopInfo = i.next();
OperationType opType = bopInfo.getExtensor(OperationType.class);
if (opType != null) {
operationMap.put(opType.getName(), bopInfo.getName());
}
}
}
use of org.apache.cxf.binding.corba.wsdl.BindingType in project cxf by apache.
the class CorbaObjectReferenceHelper method getBindingForTypeId.
public static EprMetaData getBindingForTypeId(String repId, Definition wsdlDef) {
LOG.log(Level.FINE, "RepositoryId " + repId + ", wsdl namespace " + wsdlDef.getTargetNamespace());
EprMetaData ret = new EprMetaData();
Collection<Binding> bindings = CastUtils.cast(wsdlDef.getBindings().values());
for (Binding b : bindings) {
List<?> extElements = b.getExtensibilityElements();
// Get the list of all extensibility elements
for (Iterator<?> extIter = extElements.iterator(); extIter.hasNext(); ) {
java.lang.Object element = extIter.next();
// Find a binding type so we can check against its repository ID
if (element instanceof BindingType) {
BindingType type = (BindingType) element;
if (repId.equals(type.getRepositoryID())) {
ret.setCandidateWsdlDef(wsdlDef);
ret.setBinding(b);
return ret;
}
}
}
}
if (!ret.isValid()) {
// recursivly check imports
Iterator<?> importLists = wsdlDef.getImports().values().iterator();
while (importLists.hasNext()) {
List<?> imports = (List<?>) importLists.next();
for (java.lang.Object imp : imports) {
if (imp instanceof Import) {
Definition importDef = ((Import) imp).getDefinition();
LOG.log(Level.INFO, "Following import " + importDef.getDocumentBaseURI());
ret = getBindingForTypeId(repId, importDef);
if (ret.isValid()) {
return ret;
}
}
}
}
}
return ret;
}
use of org.apache.cxf.binding.corba.wsdl.BindingType in project cxf by apache.
the class WSDLToCorbaBindingTest method testCORBABindingGeneration.
@Test
public void testCORBABindingGeneration() throws Exception {
String fileName = getClass().getResource("/wsdl/simpleList.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("BasePortType");
Definition model = generator.generateCORBABinding();
QName bName = new QName("http://schemas.apache.org/tests", "BaseCORBABinding", "tns");
Binding binding = model.getBinding(bName);
assertNotNull(binding);
assertEquals("BaseCORBABinding", binding.getQName().getLocalPart());
assertEquals("BasePortType", 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:BasePortType:1.0");
}
}
Iterator<?> j = binding.getBindingOperations().iterator();
while (j.hasNext()) {
BindingOperation bindingOperation = (BindingOperation) j.next();
assertEquals(1, bindingOperation.getExtensibilityElements().size());
assertEquals(bindingOperation.getBindingInput().getName(), "echoString");
assertEquals(bindingOperation.getBindingOutput().getName(), "echoStringResponse");
for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
if (extElement.getElementType().getLocalPart().equals("operation")) {
OperationType corbaOpType = (OperationType) extElement;
assertEquals(corbaOpType.getName(), "echoString");
assertEquals(3, corbaOpType.getParam().size());
assertEquals(corbaOpType.getReturn().getName(), "return");
assertEquals(corbaOpType.getReturn().getIdltype(), CorbaConstants.NT_CORBA_STRING);
assertEquals(corbaOpType.getParam().get(0).getName(), "x");
assertEquals(corbaOpType.getParam().get(0).getMode().value(), "in");
QName qname = new QName("http://schemas.apache.org/tests/corba/typemap/", "StringEnum1", "ns1");
assertEquals(corbaOpType.getParam().get(0).getIdltype(), qname);
}
}
}
}
use of org.apache.cxf.binding.corba.wsdl.BindingType in project cxf by apache.
the class WSDLToCorbaBindingTest method testExceptionCORBABindingGeneration.
// next story to add Fault support
@Test
public void testExceptionCORBABindingGeneration() throws Exception {
String fileName = getClass().getResource("/wsdl/exceptions.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("TestException.ExceptionTest");
Definition model = generator.generateCORBABinding();
QName bName = new QName("http://schemas.apache.org/idl/exceptions.idl", "TestException.ExceptionTestCORBABinding", "tns");
Binding binding = model.getBinding(bName);
assertNotNull(binding);
assertEquals("TestException.ExceptionTestCORBABinding", binding.getQName().getLocalPart());
assertEquals("TestException.ExceptionTest", 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:TestException/ExceptionTest:1.0");
}
}
Iterator<?> j = binding.getBindingOperations().iterator();
while (j.hasNext()) {
BindingOperation bindingOperation = (BindingOperation) j.next();
assertEquals(1, bindingOperation.getExtensibilityElements().size());
assertEquals(bindingOperation.getBindingInput().getName(), "review_data");
assertEquals(bindingOperation.getBindingOutput().getName(), "review_dataResponse");
Iterator<?> f = bindingOperation.getBindingFaults().values().iterator();
boolean hasBadRecord = false;
boolean hasMyException = false;
while (f.hasNext()) {
BindingFault bindingFault = (BindingFault) f.next();
if ("TestException.BadRecord".equals(bindingFault.getName())) {
hasBadRecord = true;
} else if ("MyException".equals(bindingFault.getName())) {
hasMyException = true;
} else {
fail("Unexpected BindingFault: " + bindingFault.getName());
}
}
assertTrue("Did not get expected TestException.BadRecord", hasBadRecord);
assertTrue("Did not get expected MyException", hasMyException);
for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
if (extElement.getElementType().getLocalPart().equals("operation")) {
OperationType corbaOpType = (OperationType) extElement;
assertEquals(corbaOpType.getName(), "review_data");
assertEquals(1, corbaOpType.getParam().size());
assertEquals(2, corbaOpType.getRaises().size());
hasBadRecord = false;
hasMyException = false;
for (int k = 0; k < corbaOpType.getRaises().size(); k++) {
String localPart = corbaOpType.getRaises().get(k).getException().getLocalPart();
if ("TestException.BadRecord".equals(localPart)) {
hasBadRecord = true;
} else if ("MyExceptionType".equals(localPart)) {
hasMyException = true;
} else {
fail("Unexpected Raises: " + localPart);
}
}
assertTrue("Did not find expected TestException.BadRecord", hasBadRecord);
assertTrue("Did not find expected MyException", hasMyException);
}
}
}
}
Aggregations