use of javax.wsdl.Binding in project cxf by apache.
the class WSDLToCorbaBindingTest method testMultipartCORBABindingGeneration.
@Test
public void testMultipartCORBABindingGeneration() throws Exception {
String fileName = getClass().getResource("/wsdl/multipart.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("Test.MultiPart");
Definition model = generator.generateCORBABinding();
QName bName = new QName("http://schemas.apache.org/tests", "Test.MultiPartCORBABinding", "tns");
Binding binding = model.getBinding(bName);
assertNotNull(binding);
assertEquals("Test.MultiPartCORBABinding", binding.getQName().getLocalPart());
assertEquals("Test.MultiPart", binding.getPortType().getQName().getLocalPart());
assertEquals(1, binding.getExtensibilityElements().size());
assertEquals(32, binding.getBindingOperations().size());
List<ExtensibilityElement> extElements = getExtensibilityElements(binding);
ExtensibilityElement extElement = extElements.get(0);
if ("binding".equals(extElement.getElementType().getLocalPart())) {
BindingType bindingType = (BindingType) extElement;
assertEquals(bindingType.getRepositoryID(), "IDL:Test/MultiPart:1.0");
}
getStringAttributeTest(binding);
getTestIdTest(binding);
setTestIdTest(binding);
testVoidTest(binding);
testPrimitiveTypeTest(binding, "test_short", CorbaConstants.NT_CORBA_SHORT);
testPrimitiveTypeTest(binding, "test_long", CorbaConstants.NT_CORBA_LONG);
testPrimitiveTypeTest(binding, "test_longlong", CorbaConstants.NT_CORBA_LONGLONG);
testPrimitiveTypeTest(binding, "test_ushort", CorbaConstants.NT_CORBA_USHORT);
testPrimitiveTypeTest(binding, "test_ulong", CorbaConstants.NT_CORBA_ULONG);
testPrimitiveTypeTest(binding, "test_ulonglong", CorbaConstants.NT_CORBA_ULONGLONG);
testPrimitiveTypeTest(binding, "test_float", CorbaConstants.NT_CORBA_FLOAT);
testPrimitiveTypeTest(binding, "test_double", CorbaConstants.NT_CORBA_DOUBLE);
testPrimitiveTypeTest(binding, "test_octet", CorbaConstants.NT_CORBA_OCTET);
testPrimitiveTypeTest(binding, "test_boolean", CorbaConstants.NT_CORBA_BOOLEAN);
testPrimitiveTypeTest(binding, "test_char", CorbaConstants.NT_CORBA_CHAR);
testPrimitiveTypeTest(binding, "test_integer", CorbaConstants.NT_CORBA_LONGLONG);
testPrimitiveTypeTest(binding, "test_nonNegativeInteger", CorbaConstants.NT_CORBA_ULONGLONG);
testPrimitiveTypeTest(binding, "test_positiveInteger", CorbaConstants.NT_CORBA_ULONGLONG);
testPrimitiveTypeTest(binding, "test_negativeInteger", CorbaConstants.NT_CORBA_LONGLONG);
testPrimitiveTypeTest(binding, "test_normalizedString", CorbaConstants.NT_CORBA_STRING);
testPrimitiveTypeTest(binding, "test_token", CorbaConstants.NT_CORBA_STRING);
testPrimitiveTypeTest(binding, "test_language", CorbaConstants.NT_CORBA_STRING);
testPrimitiveTypeTest(binding, "test_Name", CorbaConstants.NT_CORBA_STRING);
testPrimitiveTypeTest(binding, "test_NCName", CorbaConstants.NT_CORBA_STRING);
testPrimitiveTypeTest(binding, "test_ID", CorbaConstants.NT_CORBA_STRING);
testPrimitiveTypeTest(binding, "test_anyURI", CorbaConstants.NT_CORBA_STRING);
testPrimitiveTypeTest(binding, "test_nick_name", CorbaConstants.NT_CORBA_STRING);
}
use of javax.wsdl.Binding in project cxf by apache.
the class WSDLToCorbaBindingTest method testArrayMapping.
@Test
public void testArrayMapping() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/array.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 ("binding".equals(extElement.getElementType().getLocalPart())) {
BindingType bindingType = (BindingType) extElement;
assertEquals(bindingType.getRepositoryID(), "IDL:X:1.0");
}
}
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 ("operation".equals(extElement.getElementType().getLocalPart())) {
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/", "ArrayType", "ns1");
assertEquals(paramtype.getIdltype(), idltype);
assertEquals(paramtype.getMode().toString(), "IN");
}
}
}
// 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 javax.wsdl.Binding 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 ("binding".equals(extElement.getElementType().getLocalPart())) {
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 ("operation".equals(extElement.getElementType().getLocalPart())) {
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 ("typeMapping".equals(extElement.getElementType().getLocalPart())) {
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 javax.wsdl.Binding in project cxf by apache.
the class WSDLToCorbaBinding method generateCORBABinding.
private Binding generateCORBABinding(Definition definition, PortType portType) throws Exception {
QName bqname;
if (extReg == null) {
extReg = def.getExtensionRegistry();
}
bindingNames = new ArrayList<>();
String interfaceName = portType.getQName().getLocalPart();
String bname = getMappedBindingName(interfaceName);
String prefix = definition.getPrefix(definition.getTargetNamespace());
if (prefix == null) {
prefix = "";
}
if (bname == null && !allbindings) {
bname = bindingName;
}
if (bname == null) {
bname = mangleInterfaceName(interfaceName) + "CORBABinding";
setBindingName(bname);
bqname = new QName(definition.getTargetNamespace(), bname, prefix);
int count = 0;
StringBuilder builder = new StringBuilder(bname);
while (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
builder.append(count);
bqname = new QName(definition.getTargetNamespace(), builder.toString(), prefix);
}
bname = builder.toString();
} else {
bqname = new QName(definition.getTargetNamespace(), bname, prefix);
// Check if the Binding with name already exists
if (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
String msgStr = "Binding " + bqname.getLocalPart() + " already exists in WSDL.";
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
throw new ToolException(msg.toString());
}
}
// jwsdl model should have all other bindings in it.
String pfx = definition.getPrefix(CorbaConstants.NU_WSDL_CORBA);
if (pfx == null) {
pfx = "corba";
def.addNamespace(pfx, CorbaConstants.NU_WSDL_CORBA);
}
Binding binding = def.createBinding();
binding.setPortType(portType);
binding.setQName(bqname);
bindingNames.add(bname);
mapBindingToInterface(portType.getQName().getLocalPart(), bname);
addCorbaTypeMap(def);
try {
BindingType bindingType = (BindingType) extReg.createExtension(Binding.class, CorbaConstants.NE_CORBA_BINDING);
bindingType.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + binding.getPortType().getQName().getLocalPart().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION);
binding.addExtensibilityElement((ExtensibilityElement) bindingType);
} catch (WSDLException ex) {
ex.printStackTrace();
}
try {
addBindingOperations(def, portType, binding);
binding.setUndefined(false);
definition.addBinding(binding);
} catch (Exception ex) {
binding.setUndefined(true);
}
cleanUpTypeMap(typeMappingType);
return binding;
}
use of javax.wsdl.Binding in project cxf by apache.
the class WSDLHelper method getBindingOperation.
public BindingOperation getBindingOperation(Definition def, String operationName) {
if (operationName == null) {
return null;
}
Iterator<Binding> ite = CastUtils.cast(def.getBindings().values().iterator());
while (ite.hasNext()) {
Binding binding = ite.next();
Iterator<BindingOperation> ite1 = CastUtils.cast(binding.getBindingOperations().iterator());
while (ite1.hasNext()) {
BindingOperation bop = ite1.next();
if (bop.getName().equals(operationName)) {
return bop;
}
}
}
return null;
}
Aggregations