use of javax.wsdl.BindingOperation 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;
}
use of javax.wsdl.BindingOperation in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getHttpBindingOperations.
/**
* Retrieves all the operations defined in the provided Binding.
*
* @param binding WSDL binding
* @return a set of {@link WSDLOperation} defined in the provided Binding
*/
private Set<WSDLOperation> getHttpBindingOperations(Binding binding) {
Set<WSDLOperation> allBindingOperations = new HashSet<>();
if (binding.getExtensibilityElements() != null && binding.getExtensibilityElements().size() > 0) {
if (binding.getExtensibilityElements().get(0) instanceof HTTPBinding) {
HTTPBinding httpBinding = (HTTPBinding) binding.getExtensibilityElements().get(0);
String verb = httpBinding.getVerb();
for (Object opObj : binding.getBindingOperations()) {
if (opObj instanceof BindingOperation) {
BindingOperation bindingOperation = (BindingOperation) opObj;
WSDLOperation wsdlOperation = getOperation(bindingOperation, verb);
if (wsdlOperation != null) {
allBindingOperations.add(wsdlOperation);
}
}
}
}
}
return allBindingOperations;
}
use of javax.wsdl.BindingOperation in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getParameters.
/**
* Returns parameters, given http binding operation, verb and content type
*
* @param bindingOperation {@link BindingOperation} object
* @param verb HTTP verb
* @param contentType Content type
* @return parameters, given http binding operation, verb and content type
*/
private List<WSDLOperationParam> getParameters(BindingOperation bindingOperation, String verb, String contentType) {
List<WSDLOperationParam> params = new ArrayList<>();
Operation operation = bindingOperation.getOperation();
// or content type is not provided
if (APIMWSDLUtils.canContainBody(verb) && !APIMWSDLUtils.hasFormDataParams(contentType)) {
WSDLOperationParam param = new WSDLOperationParam();
param.setName("Payload");
param.setParamType(WSDLOperationParam.ParamTypeEnum.BODY);
params.add(param);
if (log.isDebugEnabled()) {
log.debug("Adding default Param for operation:" + operation.getName() + ", contentType: " + contentType);
}
return params;
}
if (operation != null) {
Input input = operation.getInput();
if (input != null) {
Message message = input.getMessage();
if (message != null) {
Map map = message.getParts();
map.forEach((name, partObj) -> {
WSDLOperationParam param = new WSDLOperationParam();
param.setName(name.toString());
if (log.isDebugEnabled()) {
log.debug("Identified param for operation: " + operation.getName() + " param: " + name);
}
if (APIMWSDLUtils.canContainBody(verb)) {
if (log.isDebugEnabled()) {
log.debug("Operation " + operation.getName() + " can contain a body.");
}
// In POST, PUT operations, parameters always in body according to HTTP Binding spec
if (APIMWSDLUtils.hasFormDataParams(contentType)) {
param.setParamType(WSDLOperationParam.ParamTypeEnum.FORM_DATA);
if (log.isDebugEnabled()) {
log.debug("Param " + name + " type was set to formData.");
}
}
// no else block since if content type is not form-data related, there can be only one
// parameter which is payload body. This is handled in the first if block which is
// if (canContainBody(verb) && !hasFormDataParams(contentType)) { .. }
} else {
// In GET operations, parameters always query or path as per HTTP Binding spec
if (isUrlReplacement(bindingOperation)) {
param.setParamType(WSDLOperationParam.ParamTypeEnum.PATH);
if (log.isDebugEnabled()) {
log.debug("Param " + name + " type was set to Path.");
}
} else {
param.setParamType(WSDLOperationParam.ParamTypeEnum.QUERY);
if (log.isDebugEnabled()) {
log.debug("Param " + name + " type was set to Query.");
}
}
}
Part part = (Part) partObj;
param.setDataType(part.getTypeName().getLocalPart());
if (log.isDebugEnabled()) {
log.debug("Param " + name + " data type was set to " + param.getDataType());
}
params.add(param);
});
}
}
}
return params;
}
use of javax.wsdl.BindingOperation in project tomee by apache.
the class JaxRpcServiceInfoBuilder method buildOperations.
private Set<QName> buildOperations(Binding binding, Class serviceEndpointInterface, boolean lightweight) throws OpenEJBException {
Set<QName> wrappedElementQNames = new HashSet<QName>();
for (Object op : binding.getBindingOperations()) {
BindingOperation bindingOperation = (BindingOperation) op;
String operationName = bindingOperation.getOperation().getName();
if (lightweight) {
// Lightweight mappings are solely based on the Java method
Method method = getMethodForOperation(operationName, serviceEndpointInterface);
// Build the operation info using the method
LightweightOperationInfoBuilder operationInfoBuilder = new LightweightOperationInfoBuilder(bindingOperation, method);
JaxRpcOperationInfo operationInfo = operationInfoBuilder.buildOperationInfo();
serviceInfo.operations.add(operationInfo);
} else {
// Heavyweight mappings are solely based on the Java to XML mapping declarations
ServiceEndpointMethodMapping methodMapping = getMethodMappingForOperation(operationName, serviceEndpointInterface);
// Build the operation info using the Java to XML method mapping
HeavyweightOperationInfoBuilder operationInfoBuilder = new HeavyweightOperationInfoBuilder(bindingOperation, methodMapping, javaWsdlMapping, schemaInfo);
JaxRpcOperationInfo operationInfo = operationInfoBuilder.buildOperationInfo();
serviceInfo.operations.add(operationInfo);
// remember wrapped elements for type mapping
Set<QName> wrappedElementQNamesForOper = operationInfoBuilder.getWrapperElementQNames();
wrappedElementQNames.addAll(wrappedElementQNamesForOper);
}
}
return wrappedElementQNames;
}
use of javax.wsdl.BindingOperation in project cxf by apache.
the class JAXWSDefinitionBuilderTest method testBuildDefinitionWithXMLBinding.
@Test
public void testBuildDefinitionWithXMLBinding() {
String qname = "http://apache.org/hello_world_xml_http/bare";
String wsdlUrl = getClass().getResource("resources/hello_world_xml_bare.wsdl").toString();
JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder();
builder.setBus(BusFactory.getDefaultBus());
builder.setContext(env);
Definition def = builder.build(wsdlUrl);
assertNotNull(def);
Map<?, ?> services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
Service service = (Service) services.get(new QName(qname, "XMLService"));
assertNotNull(service);
Map<?, ?> ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Port port = service.getPort("XMLPort");
assertNotNull(port);
assertEquals(1, port.getExtensibilityElements().size());
Object obj = port.getExtensibilityElements().get(0);
if (obj instanceof JAXBExtensibilityElement) {
obj = ((JAXBExtensibilityElement) obj).getValue();
}
assertTrue(obj.getClass().getName() + " is not an AddressType", obj instanceof AddressType);
Binding binding = port.getBinding();
assertNotNull(binding);
assertEquals(new QName(qname, "Greeter_XMLBinding"), binding.getQName());
BindingOperation operation = binding.getBindingOperation("sayHi", null, null);
assertNotNull(operation);
BindingInput input = operation.getBindingInput();
assertNotNull(input);
assertEquals(1, input.getExtensibilityElements().size());
obj = input.getExtensibilityElements().get(0);
if (obj instanceof JAXBExtensibilityElement) {
obj = ((JAXBExtensibilityElement) obj).getValue();
}
assertTrue(obj.getClass().getName() + " is not an XMLBindingMessageFormat", obj instanceof XMLBindingMessageFormat);
}
Aggregations