use of javax.wsdl.BindingOperation 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);
}
}
}
}
use of javax.wsdl.BindingOperation in project cxf by apache.
the class PartialWSDLProcessor method addBindingOperation.
@SuppressWarnings("unchecked")
private static void addBindingOperation(Definition wsdlDefinition, PortType portType, Binding binding, ExtensionRegistry extReg) throws Exception {
List<Operation> ops = portType.getOperations();
for (Operation op : ops) {
BindingOperation bindingOperation = wsdlDefinition.createBindingOperation();
setSoapOperationExtElement(bindingOperation, extReg);
bindingOperation.setName(op.getName());
if (op.getInput() != null) {
bindingOperation.setBindingInput(getBindingInput(op.getInput(), wsdlDefinition, extReg));
}
if (op.getOutput() != null) {
bindingOperation.setBindingOutput(getBindingOutput(op.getOutput(), wsdlDefinition, extReg));
}
if (op.getFaults() != null && op.getFaults().size() > 0) {
addSoapFaults(op, bindingOperation, wsdlDefinition, extReg);
}
bindingOperation.setOperation(op);
binding.addBindingOperation(bindingOperation);
}
}
use of javax.wsdl.BindingOperation in project cxf by apache.
the class AbstractWSDLBindingFactory method initializeBindingInfo.
protected BindingInfo initializeBindingInfo(ServiceInfo service, Binding binding, BindingInfo bi) {
bi.setName(binding.getQName());
copyExtensors(bi, binding, null);
for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
String inName = null;
String outName = null;
if (bop.getBindingInput() != null) {
inName = bop.getBindingInput().getName();
}
if (bop.getBindingOutput() != null) {
outName = bop.getBindingOutput().getName();
}
String portTypeNs = binding.getPortType().getQName().getNamespaceURI();
QName opName = new QName(portTypeNs, bop.getName());
BindingOperationInfo bop2 = bi.getOperation(opName);
if (bop2 == null) {
bop2 = bi.buildOperation(opName, inName, outName);
if (bop2 != null) {
bi.addOperation(bop2);
}
}
if (bop2 != null) {
copyExtensors(bop2, bop, bop2);
if (bop.getBindingInput() != null) {
copyExtensors(bop2.getInput(), bop.getBindingInput(), bop2);
}
if (bop.getBindingOutput() != null) {
copyExtensors(bop2.getOutput(), bop.getBindingOutput(), bop2);
}
for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
if (StringUtils.isEmpty(f.getName())) {
throw new IllegalArgumentException("wsdl:fault and soap:fault elements" + " must have a name attribute.");
}
copyExtensors(bop2.getFault(new QName(service.getTargetNamespace(), f.getName())), bop.getBindingFault(f.getName()), bop2);
}
}
}
return bi;
}
use of javax.wsdl.BindingOperation in project cxf by apache.
the class SOAPBindingUtil method isMixedStyle.
public static boolean isMixedStyle(Binding binding) {
String bindingStyle = "";
String previousOpStyle = "";
String style = "";
for (Object obj : binding.getExtensibilityElements()) {
if (isSOAPBinding(obj)) {
SoapBinding soapBinding = getSoapBinding(obj);
bindingStyle = soapBinding.getStyle();
if (bindingStyle == null) {
bindingStyle = "";
}
}
}
for (Object bobj : binding.getBindingOperations()) {
BindingOperation bop = (BindingOperation) bobj;
for (Object obj : bop.getExtensibilityElements()) {
if (isSOAPOperation(obj)) {
SoapOperation soapOperation = getSoapOperation(obj);
style = soapOperation.getStyle();
if (style == null) {
style = "";
}
if ("".equals(bindingStyle) && "".equals(previousOpStyle) || "".equals(bindingStyle) && previousOpStyle.equalsIgnoreCase(style)) {
previousOpStyle = style;
} else if (!"".equals(bindingStyle) && "".equals(previousOpStyle) && bindingStyle.equalsIgnoreCase(style) || bindingStyle.equalsIgnoreCase(previousOpStyle) && bindingStyle.equalsIgnoreCase(style)) {
previousOpStyle = style;
} else if (!"".equals(bindingStyle) && "".equals(style) && "".equals(previousOpStyle)) {
continue;
} else {
return true;
}
}
}
}
return false;
}
Aggregations