use of javax.wsdl.BindingOperation in project cxf by apache.
the class WSDLToIDLAction method collectIdlDefns.
private void collectIdlDefns(Binding binding) throws Exception {
boolean isOneway = false;
Iterator<?> iterator = binding.getBindingOperations().iterator();
while (iterator.hasNext()) {
BindingOperation bindingOperation = (BindingOperation) iterator.next();
if (bindingOperation.getBindingOutput() == null) {
isOneway = true;
}
addOperation(bindingOperation, isOneway);
}
}
use of javax.wsdl.BindingOperation in project cxf by apache.
the class OperationVisitor method visit.
public void visit(AST node) {
// <op_dcl> ::= [<op_attribute>] <op_type_spec>
// <identifier> <parameter_dcls>
// [<raises_expr>] [<context_expr>]
// <op_attribute> ::= "oneway"
// <op_type_spec> ::= <param_type_spec>
// | "void"
// <parameter_dcls> ::= "(" <param_dcl> {"," <param_dcl>}* ")"
// | "(" ")"
// <raises_expr> ::= "raises" "(" <scoped_name> {"," <scoped_name>}* ")"
// <context_expr> ::= "context" "(" <string_literal> {"," <string_literal>}* ")"
QName operationQName = new QName(schema.getTargetNamespace(), node.toString());
boolean isDuplicate = false;
if (schema.getElements().containsKey(operationQName)) {
isDuplicate = true;
}
Operation operation = generateOperation(operationQName.getLocalPart(), isDuplicate);
BindingOperation bindingOperation = null;
if (isDuplicate) {
bindingOperation = generateBindingOperation(binding, operation, operationQName.getLocalPart());
} else {
bindingOperation = generateBindingOperation(binding, operation, operation.getName());
}
XmlSchemaSequence inputWrappingSequence = new XmlSchemaSequence();
XmlSchemaElement inputElement = generateWrapper(new QName(schema.getTargetNamespace(), operation.getName()), inputWrappingSequence);
inputMsg = generateInputMessage(operation, bindingOperation);
generateInputPart(inputMsg, inputElement);
// <op_attribute>
node = node.getFirstChild();
XmlSchemaSequence outputWrappingSequence = null;
XmlSchemaElement outputElement = null;
if (node != null && (node.getType() == IDLTokenTypes.LITERAL_oneway)) {
// oneway operations map to operations with only input message
// no outputMsg nor outputPart need be created
node = node.getNextSibling();
} else {
// normal operations map to request-response operations
// with input and output messages
outputWrappingSequence = new XmlSchemaSequence();
outputElement = generateWrapper(new QName(schema.getTargetNamespace(), operation.getName() + RESPONSE_SUFFIX), outputWrappingSequence);
outputMsg = generateOutputMessage(operation, bindingOperation);
generateOutputPart(outputMsg, outputElement);
}
// <op_type_spec>
visitOpTypeSpec(node, outputWrappingSequence);
// <parameter_dcls>
node = TypesUtils.getCorbaTypeNameNode(node);
while (ParamDclVisitor.accept(node)) {
ParamDclVisitor visitor = new ParamDclVisitor(getScope(), definition, schema, wsdlVisitor, inputWrappingSequence, outputWrappingSequence, corbaOperation);
visitor.visit(node);
node = node.getNextSibling();
}
// <raises_expr>
if (node != null && node.getType() == IDLTokenTypes.LITERAL_raises) {
node = node.getFirstChild();
while (node != null) {
//
ScopedNameVisitor visitor = new ScopedNameVisitor(getScope(), definition, schema, wsdlVisitor);
visitor.setExceptionMode(true);
visitor.visit(node);
CorbaTypeImpl corbaType = visitor.getCorbaType();
XmlSchemaType schemaType = visitor.getSchemaType();
// REVISIT, schema type ends with Type for exceptions, so strip it to get the element name.
int pos = schemaType.getQName().getLocalPart().indexOf("Type");
QName elementQName = new QName(schemaType.getQName().getNamespaceURI(), schemaType.getQName().getLocalPart().substring(0, pos));
createFaultMessage(corbaType, operation, bindingOperation, elementQName);
node = node.getNextSibling();
visitor.setExceptionMode(false);
}
}
}
use of javax.wsdl.BindingOperation 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.BindingOperation in project cxf by apache.
the class JAXWSDefinitionBuilder method isRPCEncoded.
private boolean isRPCEncoded(Definition def) {
Iterator<?> ite1 = def.getBindings().values().iterator();
while (ite1.hasNext()) {
Binding binding = (Binding) ite1.next();
String bindingStyle = SOAPBindingUtil.getBindingStyle(binding);
Iterator<?> ite2 = binding.getBindingOperations().iterator();
while (ite2.hasNext()) {
BindingOperation bop = (BindingOperation) ite2.next();
String bopStyle = SOAPBindingUtil.getSOAPOperationStyle(bop);
String outputUse = "";
if (SOAPBindingUtil.getBindingOutputSOAPBody(bop) != null) {
outputUse = SOAPBindingUtil.getBindingOutputSOAPBody(bop).getUse();
}
String inputUse = "";
if (SOAPBindingUtil.getBindingInputSOAPBody(bop) != null) {
inputUse = SOAPBindingUtil.getBindingInputSOAPBody(bop).getUse();
}
if ((SOAPBinding.Style.RPC.name().equalsIgnoreCase(bindingStyle) || SOAPBinding.Style.RPC.name().equalsIgnoreCase(bopStyle)) && (SOAPBinding.Use.ENCODED.name().equalsIgnoreCase(inputUse) || SOAPBinding.Use.ENCODED.name().equalsIgnoreCase(outputUse))) {
return true;
}
}
}
return false;
}
use of javax.wsdl.BindingOperation in project cxf by apache.
the class WSDLToSoapProcessor method addBindingOperation.
@SuppressWarnings("unchecked")
private void addBindingOperation() throws ToolException {
/**
* This method won't do unique operation name checking on portType The
* WS-I Basic Profile[17] R2304 requires that operations within a
* wsdl:portType have unique values for their name attribute so mapping
* of WS-I compliant WSDLdescriptions will not generate Java interfaces
* with overloaded methods. However, for backwards compatibility, JAX-WS
* supports operation name overloading provided the overloading does not
* cause conflicts (as specified in the Java Language Specification[25])
* in the mapped Java service endpoint interface declaration.
*/
List<Operation> ops = portType.getOperations();
for (Operation op : ops) {
BindingOperation bindingOperation = wsdlDefinition.createBindingOperation();
setSoapOperationExtElement(bindingOperation);
bindingOperation.setName(op.getName());
if (op.getInput() != null) {
bindingOperation.setBindingInput(getBindingInput(op.getInput()));
}
if (op.getOutput() != null) {
bindingOperation.setBindingOutput(getBindingOutput(op.getOutput()));
}
if (op.getFaults() != null && op.getFaults().size() > 0) {
addSoapFaults(op, bindingOperation);
}
bindingOperation.setOperation(op);
binding.addBindingOperation(bindingOperation);
}
}
Aggregations