use of javax.wsdl.Fault in project cxf by apache.
the class WSIBPValidator method checkR2205.
// TODO: Should also check SoapHeader/SoapHeaderFault
public boolean checkR2205() {
Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());
for (Binding binding : bindings) {
if (!SOAPBindingUtil.isSOAPBinding(binding)) {
System.err.println("WSIBP Validator found <" + binding.getQName() + "> is NOT a SOAP binding");
continue;
}
if (binding.getPortType() == null) {
// will error later
continue;
}
for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext(); ) {
Operation operation = (Operation) ite2.next();
Collection<Fault> faults = CastUtils.cast(operation.getFaults().values());
if (CollectionUtils.isEmpty(faults)) {
continue;
}
for (Fault fault : faults) {
Message message = fault.getMessage();
Collection<Part> parts = CastUtils.cast(message.getParts().values());
for (Part part : parts) {
if (part.getElementName() == null) {
addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2205") + "In Message " + message.getQName() + ", part " + part.getName() + " must specify a 'element' attribute");
return false;
}
}
}
}
}
return true;
}
use of javax.wsdl.Fault 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.Fault in project cxf by apache.
the class WSDLToCorbaBinding method addCorbaOperationExtElement.
private void addCorbaOperationExtElement(BindingOperation bo, Operation op) throws Exception {
final OperationType operationType;
try {
operationType = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
} catch (WSDLException wse) {
LOG.log(Level.SEVERE, "Failed to create a Binding Operation extension", wse);
throw new Exception(LOG.toString(), wse);
}
operationType.setName(op.getName());
List<ParamType> params = new ArrayList<>();
List<ArgType> returns = new ArrayList<>();
wsdlParameter.processParameters(this, op, def, xmlSchemaList, params, returns, true);
for (ParamType paramtype : params) {
operationType.getParam().add(paramtype);
}
for (ArgType retType : returns) {
operationType.setReturn(retType);
}
Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
for (Fault fault : faults) {
RaisesType raisestype = new RaisesType();
CorbaType extype = convertFaultToCorbaType(xmlSchemaType, fault);
if (extype != null) {
raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));
operationType.getRaises().add(raisestype);
}
}
bo.addExtensibilityElement((ExtensibilityElement) operationType);
}
use of javax.wsdl.Fault in project cxf by apache.
the class PortTypeVisitor method visitInterfaceInheritanceSpec.
private AST visitInterfaceInheritanceSpec(AST interfaceInheritanceSpecNode, Binding binding, Scope childScope) {
// <interface_inheritance_spec> ::= ":" <interface_name> { "," <interface_name> }*
AST interfaceNameNode = interfaceInheritanceSpecNode.getFirstChild();
BindingType corbaBinding = findCorbaBinding(binding);
List<Scope> inheritedScopes = new ArrayList<>();
while (interfaceNameNode != null) {
// check for porttypes in current & parent scopes
Scope interfaceScope = null;
PortType intf = null;
if (ScopedNameVisitor.isFullyScopedName(interfaceNameNode)) {
interfaceScope = ScopedNameVisitor.getFullyScopedName(new Scope(), interfaceNameNode);
intf = findPortType(interfaceScope);
}
Scope currentScope = getScope();
while (intf == null && currentScope != currentScope.getParent()) {
if (ScopedNameVisitor.isFullyScopedName(interfaceNameNode)) {
interfaceScope = ScopedNameVisitor.getFullyScopedName(currentScope, interfaceNameNode);
} else {
interfaceScope = new Scope(currentScope, interfaceNameNode.toString());
}
intf = findPortType(interfaceScope);
currentScope = currentScope.getParent();
}
if (intf == null) {
if (ScopedNameVisitor.isFullyScopedName(interfaceNameNode)) {
interfaceScope = ScopedNameVisitor.getFullyScopedName(new Scope(), interfaceNameNode);
} else {
interfaceScope = new Scope(new Scope(), interfaceNameNode);
}
intf = findPortType(interfaceScope);
}
if (intf == null) {
throw new RuntimeException("[InterfaceVisitor] Unknown Interface: " + interfaceNameNode.toString());
}
Scope defnScope = interfaceScope.getParent();
Definition defn = manager.getWSDLDefinition(mapper.map(defnScope));
inheritedScopes.add(interfaceScope);
if (defn != null && !defn.getTargetNamespace().equals(definition.getTargetNamespace())) {
String key = defnScope.toString("_");
String fileName = getWsdlVisitor().getOutputDir() + System.getProperty("file.separator") + key;
manager.addWSDLDefinitionImport(definition, defn, key, fileName);
}
Binding inheritedBinding = findBinding(intf);
BindingType inheritedCorbaBinding = findCorbaBinding(inheritedBinding);
corbaBinding.getBases().add(inheritedCorbaBinding.getRepositoryID());
// add all the operations of the inherited port type.
for (Operation op : CastUtils.cast(intf.getOperations(), Operation.class)) {
// check to see all the inherited namespaces are added.
String inputNS = op.getInput().getMessage().getQName().getNamespaceURI();
manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(inputNS), inputNS);
// Make sure we import the wsdl for the input namespace
if (definition.getImports().get(inputNS) == null && !mapper.isDefaultMapping() && !definition.getTargetNamespace().equals(inputNS)) {
manager.addWSDLDefinitionImport(definition, manager.getWSDLDefinition(inputNS), mapper.mapNSToPrefix(inputNS), manager.getImportedWSDLDefinitionFile(inputNS));
}
if (op.getOutput() != null) {
String outputNS = op.getOutput().getMessage().getQName().getNamespaceURI();
manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(outputNS), outputNS);
// Make sure we import the wsdl for the output namespace
if (definition.getImports().get(outputNS) == null && !mapper.isDefaultMapping() && !definition.getTargetNamespace().equals(outputNS)) {
manager.addWSDLDefinitionImport(definition, manager.getWSDLDefinition(outputNS), mapper.mapNSToPrefix(outputNS), manager.getImportedWSDLDefinitionFile(outputNS));
}
}
for (Iterator<Fault> faults = CastUtils.cast(op.getFaults().values().iterator()); faults.hasNext(); ) {
String faultNS = faults.next().getMessage().getQName().getNamespaceURI();
manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(faultNS), faultNS);
// Make sure we import the wsdl for the fault namespace
if (definition.getImports().get(faultNS) == null && !mapper.isDefaultMapping() && !definition.getTargetNamespace().equals(faultNS)) {
manager.addWSDLDefinitionImport(definition, manager.getWSDLDefinition(faultNS), mapper.mapNSToPrefix(faultNS), manager.getImportedWSDLDefinitionFile(faultNS));
}
}
portType.addOperation(op);
}
// add all the binding extensions of the inherited corba binding
for (Iterator<BindingOperation> it = CastUtils.cast(inheritedBinding.getBindingOperations().iterator()); it.hasNext(); ) {
binding.addBindingOperation(it.next());
}
interfaceNameNode = interfaceNameNode.getNextSibling();
}
if ((!inheritedScopes.isEmpty()) && (wsdlVisitor.getInheritedScopeMap() != null)) {
wsdlVisitor.getInheritedScopeMap().put(childScope, inheritedScopes);
}
return interfaceInheritanceSpecNode.getNextSibling();
}
use of javax.wsdl.Fault in project cxf by apache.
the class ServiceWSDLBuilderTest method testPingMeOperation.
@Test
public void testPingMeOperation() throws Exception {
setupWSDL(WSDL_PATH);
PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(), "Greeter"));
Operation pingMe = portType.getOperation("pingMe", "pingMeRequest", "pingMeResponse");
assertNotNull(pingMe);
assertEquals("pingMe", pingMe.getName());
Input input = pingMe.getInput();
assertNotNull(input);
assertEquals("pingMeRequest", input.getName());
Message message = input.getMessage();
assertNotNull(message);
assertEquals("pingMeRequest", message.getQName().getLocalPart());
assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
assertEquals(1, message.getParts().size());
assertEquals("in", message.getPart("in").getName());
Output output = pingMe.getOutput();
assertNotNull(output);
assertEquals("pingMeResponse", output.getName());
message = output.getMessage();
assertNotNull(message);
assertEquals("pingMeResponse", message.getQName().getLocalPart());
assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
assertEquals(message.getParts().size(), 1);
assertEquals("out", message.getPart("out").getName());
assertEquals(1, pingMe.getFaults().size());
Fault fault = pingMe.getFault("pingMeFault");
assertNotNull(fault);
assertEquals("pingMeFault", fault.getName());
message = fault.getMessage();
assertNotNull(message);
assertEquals("pingMeFault", message.getQName().getLocalPart());
assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
assertEquals(1, message.getParts().size());
assertEquals("faultDetail", message.getPart("faultDetail").getName());
assertNull(message.getPart("faultDetail").getTypeName());
}
Aggregations