use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ResponseWrapperTest method testBuildFields.
@Test
public void testBuildFields() {
// Test String[]
Class<?> testingClass = GreeterArray.class;
OperationInfo opInfo = getOperation(testingClass, "sayStringArray");
assertNotNull(opInfo);
ResponseWrapper responseWrapper = new ResponseWrapper();
MessageInfo message = opInfo.getUnwrappedOperation().getOutput();
Method method = (Method) opInfo.getProperty("operation.method");
JavaField field = responseWrapper.buildFields(method, message).get(0);
assertEquals("_return", field.getParaName());
assertEquals("String[]", field.getType());
// Test int[]
opInfo = getOperation(testingClass, "sayIntArray");
assertNotNull(opInfo);
message = opInfo.getUnwrappedOperation().getOutput();
method = (Method) opInfo.getProperty("operation.method");
field = responseWrapper.buildFields(method, message).get(0);
assertEquals("_return", field.getParaName());
assertEquals("int[]", field.getType());
// Test TestDataBean[]
opInfo = getOperation(testingClass, "sayTestDataBeanArray");
assertNotNull(opInfo);
message = opInfo.getUnwrappedOperation().getOutput();
method = (Method) opInfo.getProperty("operation.method");
field = responseWrapper.buildFields(method, message).get(0);
assertEquals("_return", field.getParaName());
assertEquals("org.apache.cxf.tools.fortest.withannotation.doc.TestDataBean[]", field.getType());
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class UniqueBodyValidator method isValidEndpoint.
private boolean isValidEndpoint(EndpointInfo endpoint) {
BindingInfo binding = endpoint.getBinding();
Map<QName, QName> uniqueNames = new HashMap<>();
Map<QName, Set<String>> actions = new HashMap<>();
Collection<BindingOperationInfo> bos = binding.getOperations();
for (BindingOperationInfo bo : bos) {
OperationInfo op = binding.getInterface().getOperation(bo.getName());
if (op.getInput() != null && op.getInput().getMessagePartsNumber() == 1) {
MessagePartInfo part = op.getInput().getFirstMessagePart();
if (part.getElementQName() == null) {
continue;
}
QName mName = part.getElementQName();
String action = getWSAAction(op.getInput());
QName opName = uniqueNames.get(mName);
Set<String> opActions = actions.get(mName);
if (opName != null && opActions != null && !opActions.contains(action)) {
opName = null;
}
if (opName != null) {
Message msg = new Message("NON_UNIQUE_BODY", LOG, endpoint.getName(), op.getName(), opName, mName);
addErrorMessage(msg.toString());
return false;
}
uniqueNames.put(mName, op.getName());
if (action != null) {
if (opActions == null) {
opActions = new HashSet<>();
actions.put(mName, opActions);
}
opActions.add(action);
}
}
for (BindingFaultInfo fault : bo.getFaults()) {
if (fault.getFaultInfo().getMessagePartsNumber() > 1) {
Message msg = new Message("FAULT_WITH_MULTIPLE_PARTS", LOG, fault.getFaultInfo().getName().getLocalPart());
addErrorMessage(msg.toString());
return false;
}
}
}
return true;
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class MethodMapperTest method testMapOneWayOperation.
@Test
public void testMapOneWayOperation() throws Exception {
OperationInfo operation = getOperation();
MessageInfo inputMessage = operation.createMessage(new QName("urn:test:ns", "testInputMessage"), MessageInfo.Type.INPUT);
operation.setInput("input", inputMessage);
JavaMethod method = new MethodMapper().map(operation);
assertNotNull(method);
assertTrue(method.isOneWay());
}
use of org.apache.cxf.service.model.OperationInfo in project jbossws-cxf by jbossws.
the class JBossWSInvokerTest method getTestExchange.
// build up a fake exchange instance, the minimum required to let the flow proceed till the JBossWSInvoker
private Exchange getTestExchange() {
Exchange exchange = new ExchangeImpl();
Message message = new MessageImpl();
message.setExchange(exchange);
exchange.setInMessage(message);
exchange.put(BindingOperationInfo.class, new BindingOperationInfo());
Service service = new ServiceImpl();
MethodDispatcher md = new MethodDispatcher() {
@Override
public Method getMethod(BindingOperationInfo op) {
return this.getClass().getMethods()[0];
}
@Override
public BindingOperationInfo getBindingOperation(Method m, Endpoint endpoint) {
return null;
}
@Override
public void bind(OperationInfo o, Method... methods) {
}
};
service.put(MethodDispatcher.class.getName(), md);
exchange.put(Service.class, service);
return exchange;
}
use of org.apache.cxf.service.model.OperationInfo in project Activiti by Activiti.
the class CxfWSDLImporter method importService.
protected WSService importService(ServiceInfo service) {
String name = service.getName().getLocalPart();
String location = "";
for (EndpointInfo endpoint : service.getEndpoints()) {
location = endpoint.getAddress();
}
WSService wsService = new WSService(this.namespace + name, location, this.wsdlLocation);
for (OperationInfo operation : service.getInterface().getOperations()) {
WSOperation wsOperation = this.importOperation(operation, wsService);
wsService.addOperation(wsOperation);
this.wsOperations.put(this.namespace + operation.getName().getLocalPart(), wsOperation);
}
return wsService;
}
Aggregations