use of javax.wsdl.BindingFault in project tomee by apache.
the class WsdlVisitor method walkTree.
public void walkTree() {
begin();
try {
visit(definition);
for (Iterator iterator = definition.getImports().entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry entry = (Map.Entry) iterator.next();
String namespaceURI = (String) entry.getKey();
List importsForNamespace = (List) entry.getValue();
for (Iterator iterator1 = importsForNamespace.iterator(); iterator1.hasNext(); ) {
Import anImport = (Import) iterator1.next();
visit(anImport);
}
}
visit(definition.getTypes());
Collection messages = definition.getMessages().values();
for (Iterator iterator = messages.iterator(); iterator.hasNext(); ) {
Message message = (Message) iterator.next();
visit(message);
Collection parts = message.getParts().values();
for (Iterator iterator2 = parts.iterator(); iterator2.hasNext(); ) {
Part part = (Part) iterator2.next();
visit(part);
}
}
Collection services = definition.getServices().values();
for (Iterator iterator = services.iterator(); iterator.hasNext(); ) {
Service service = (Service) iterator.next();
visit(service);
Collection ports = service.getPorts().values();
for (Iterator iterator1 = ports.iterator(); iterator1.hasNext(); ) {
Port port = (Port) iterator1.next();
visit(port);
Binding binding = port.getBinding();
visit(binding);
List bindingOperations = binding.getBindingOperations();
for (int i = 0; i < bindingOperations.size(); i++) {
BindingOperation bindingOperation = (BindingOperation) bindingOperations.get(i);
visit(bindingOperation);
visit(bindingOperation.getBindingInput());
visit(bindingOperation.getBindingOutput());
Collection bindingFaults = bindingOperation.getBindingFaults().values();
for (Iterator iterator2 = bindingFaults.iterator(); iterator2.hasNext(); ) {
BindingFault bindingFault = (BindingFault) iterator2.next();
visit(bindingFault);
}
}
PortType portType = binding.getPortType();
visit(portType);
List operations = portType.getOperations();
for (int i = 0; i < operations.size(); i++) {
Operation operation = (Operation) operations.get(i);
visit(operation);
{
Input input = operation.getInput();
visit(input);
}
{
Output output = operation.getOutput();
visit(output);
}
Collection faults = operation.getFaults().values();
for (Iterator iterator2 = faults.iterator(); iterator2.hasNext(); ) {
Fault fault = (Fault) iterator2.next();
visit(fault);
}
}
}
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
} finally {
end();
}
}
use of javax.wsdl.BindingFault 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 ("binding".equals(extElement.getElementType().getLocalPart())) {
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 ("operation".equals(extElement.getElementType().getLocalPart())) {
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.BindingFault in project cxf by apache.
the class WSDLToSoapProcessorTest method testDocLitWithFault.
@Test
public void testDocLitWithFault() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world_doc_lit.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_doc_lit-soapbinding.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
processor.setEnvironment(env);
try {
processor.parseWSDL(outputFile.getAbsolutePath());
Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_Binding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_Binding Missed!");
}
boolean found = false;
for (Object obj : binding.getExtensibilityElements()) {
SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
if (soapBinding != null && soapBinding.getStyle().equalsIgnoreCase("document")) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:binding Missed!");
}
BindingOperation bo = binding.getBindingOperation("pingMe", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"pingMe\"> Missed!");
}
found = false;
for (Object obj : bo.getExtensibilityElements()) {
SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
if (soapOperation != null && soapOperation.getStyle().equalsIgnoreCase("document")) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:operation Missed!");
}
BindingFault fault = bo.getBindingFault("pingMeFault");
if (fault == null) {
fail("Element <wsdl:fault name=\"pingMeFault\"> Missed!");
}
found = false;
for (Object obj : fault.getExtensibilityElements()) {
if (SOAPBindingUtil.isSOAPFault(obj)) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:fault Missed!");
}
List<SoapFault> faults = SOAPBindingUtil.getBindingOperationSoapFaults(bo);
assertEquals(1, faults.size());
assertEquals("pingMeFault", faults.get(0).getName());
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
use of javax.wsdl.BindingFault in project cxf by apache.
the class WSDLToCorbaBinding method addBindingOperations.
private void addBindingOperations(Definition definition, PortType portType, Binding binding) throws Exception {
List<Operation> ops = CastUtils.cast(portType.getOperations());
for (Operation op : ops) {
try {
BindingOperation bindingOperation = definition.createBindingOperation();
addCorbaOperationExtElement(bindingOperation, op);
bindingOperation.setName(op.getName());
if (op.getInput() != null) {
BindingInput bindingInput = definition.createBindingInput();
bindingInput.setName(op.getInput().getName());
bindingOperation.setBindingInput(bindingInput);
}
if (op.getOutput() != null) {
BindingOutput bindingOutput = definition.createBindingOutput();
bindingOutput.setName(op.getOutput().getName());
bindingOperation.setBindingOutput(bindingOutput);
}
// add Faults
if (op.getFaults() != null && op.getFaults().size() > 0) {
Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
for (Fault fault : faults) {
BindingFault bindingFault = definition.createBindingFault();
bindingFault.setName(fault.getName());
bindingOperation.addBindingFault(bindingFault);
}
}
bindingOperation.setOperation(op);
binding.addBindingOperation(bindingOperation);
} catch (Exception ex) {
LOG.warning("Operation " + op.getName() + " not mapped to CORBA binding.");
}
}
}
use of javax.wsdl.BindingFault in project cxf by apache.
the class PartialWSDLProcessor method addSoapFaults.
private static void addSoapFaults(Operation op, BindingOperation bindingOperation, Definition wsdlDefinition, ExtensionRegistry extReg) throws Exception {
Map<String, Fault> faults = CastUtils.cast(op.getFaults());
for (Fault fault : faults.values()) {
BindingFault bf = wsdlDefinition.createBindingFault();
bf.setName(fault.getName());
setSoapFaultExtElement(bf, extReg);
bindingOperation.addBindingFault(bf);
}
}
Aggregations