use of org.apache.cxf.service.model.BindingInfo 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.BindingInfo in project fabric8 by jboss-fuse.
the class ManagedApi method getJSONSchemaForOperation.
@ManagedOperation(description = "get the JSON schema from a given soap endpoint for a given operation", currencyTimeLimit = 60)
public String getJSONSchemaForOperation(String operationName) {
if (!isWSDL()) {
return null;
}
String ret = "";
for (ServiceInfo serviceInfo : endpoint.getService().getServiceInfos()) {
for (BindingInfo bindingInfo : serviceInfo.getBindings()) {
for (BindingOperationInfo boi : bindingInfo.getOperations()) {
if (operationName.equals(boi.getOperationInfo().getName().getLocalPart())) {
ret = ret + getBeginIndentionWithReturn(1) + "\"" + boi.getOperationInfo().getName().getLocalPart() + "\" " + " : " + getBeginIndentionWithReturn(2);
if (boi.getInput() != null && boi.getInput().getMessageParts() != null) {
ret = ret + "\"input\" : " + getBeginIndentionWithReturn(4) + "\"type\" : \"" + boi.getOperationInfo().getInput().getName().getLocalPart() + "\"" + getEndIndentionWithReturn(2) + "," + getEol();
}
if (boi.getOutput() != null && boi.getOutput().getMessageParts() != null) {
ret = ret + getIndention(2) + "\"output\" : " + getBeginIndentionWithReturn(4) + "\"type\" : \"" + boi.getOperationInfo().getOutput().getName().getLocalPart() + "\"" + getEndIndentionWithReturn(2);
}
ret = rollbackColon(ret) + getEndIndentionWithReturn(1) + ",";
ret = ret + getEol() + getIndention(1) + "\"definitions\" : " + getBeginIndentionWithReturn(2);
if (boi.getInput() != null && boi.getInput().getMessageParts() != null) {
ret = ret + "\"" + boi.getOperationInfo().getInput().getName().getLocalPart() + "\" : " + getBeginIndentionWithReturnForList(0);
for (MessagePartInfo mpi : boi.getInput().getMessageParts()) {
Class<?> partClass = mpi.getTypeClass();
if (partClass != null) {
ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(partClass), 3)) + "," + getEol();
}
}
ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturnForList(2) + "," + getEol();
}
if (boi.getOutput() != null && boi.getOutput().getMessageParts() != null) {
ret = ret + getIndention(2) + "\"" + boi.getOperationInfo().getOutput().getName().getLocalPart() + "\" : " + getBeginIndentionWithReturnForList(0);
for (MessagePartInfo mpi : boi.getOutput().getMessageParts()) {
Class<?> partClass = mpi.getTypeClass();
if (partClass != null) {
ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(partClass), 3)) + "," + getEol();
}
}
ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturnForList(2) + ",";
}
}
}
if (ret.length() > 0) {
ret = rollbackColon(ret) + getEndIndentionWithReturn(1);
}
if (ret.length() > 0) {
ret = rollbackColon(ret) + getEndIndentionWithReturn(0);
}
}
}
return ret;
}
use of org.apache.cxf.service.model.BindingInfo in project fabric8 by jboss-fuse.
the class ManagedApi method getJSONSchema.
@ManagedOperation(description = "get the JSON schema from a given endpoint", currencyTimeLimit = 60)
public String getJSONSchema() {
String ret = "";
if (!isWSDL()) {
Set<Class<?>> resourceTypes = getRESTResourceTypes();
if (resourceTypes != null) {
try {
ret = ret + getBeginIndentionWithReturn(1) + "\"" + "definitions" + "\" " + " : {" + getEol();
for (Class<?> cls : resourceTypes) {
if (JsonSchemaLookup.getSingleton().getSchemaForClass(cls).length() > 0) {
ret = ret + getIndention(2) + "\"" + cls.getName() + "\" : " + getEol();
ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(cls), 3)) + "," + getEol();
}
}
ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturn(1);
ret = ret + getEndIndentionWithReturn(0);
} catch (Throwable e) {
LOG.log(Level.WARNING, "getJSONSchema failed.", e);
}
}
} else {
try {
for (ServiceInfo serviceInfo : endpoint.getService().getServiceInfos()) {
for (BindingInfo bindingInfo : serviceInfo.getBindings()) {
ret = ret + getBeginIndentionWithReturn(1) + "\"operations\" : " + getBeginIndentionWithReturn(0);
for (BindingOperationInfo boi : bindingInfo.getOperations()) {
ret = ret + getIndention(2) + "\"" + boi.getOperationInfo().getName().getLocalPart() + "\" " + " : " + getBeginIndentionWithReturn(3);
if (boi.getInput() != null && boi.getInput().getMessageParts() != null) {
ret = ret + "\"input\" : " + getBeginIndentionWithReturn(4) + "\"type\" : \"" + boi.getOperationInfo().getInput().getName().getLocalPart() + "\"" + getEndIndentionWithReturn(3) + "," + getEol();
}
if (boi.getOutput() != null && boi.getOutput().getMessageParts() != null) {
ret = ret + getIndention(3) + "\"output\" : " + getBeginIndentionWithReturn(4) + "\"type\" : \"" + boi.getOperationInfo().getOutput().getName().getLocalPart() + "\"" + getEndIndentionWithReturn(3);
}
ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturn(2) + "," + getEol();
}
if (ret.length() > 0) {
ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturn(1) + ",";
}
Set<String> addedType = new HashSet<String>();
ret = ret + getEol() + getIndention(1) + "\"definitions\" : " + getBeginIndentionWithReturn(0);
for (BindingOperationInfo boi : bindingInfo.getOperations()) {
if (boi.getInput() != null && boi.getInput().getMessageParts() != null && !addedType.contains(boi.getOperationInfo().getInput().getName().getLocalPart())) {
ret = ret + getIndention(2) + "\"" + boi.getOperationInfo().getInput().getName().getLocalPart() + "\" : " + getBeginIndentionWithReturnForList(0);
for (MessagePartInfo mpi : boi.getInput().getMessageParts()) {
Class<?> partClass = mpi.getTypeClass();
if (partClass != null) {
ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(partClass), 3)) + "," + getEol();
}
}
ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturnForList(2) + "," + getEol();
addedType.add(boi.getOperationInfo().getInput().getName().getLocalPart());
}
if (boi.getOutput() != null && boi.getOutput().getMessageParts() != null && !addedType.contains(boi.getOperationInfo().getOutput().getName().getLocalPart())) {
ret = ret + getIndention(2) + "\"" + boi.getOperationInfo().getOutput().getName().getLocalPart() + "\" : " + getBeginIndentionWithReturnForList(0);
for (MessagePartInfo mpi : boi.getOutput().getMessageParts()) {
Class<?> partClass = mpi.getTypeClass();
if (partClass != null) {
ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(partClass), 3)) + "," + getEol();
}
}
ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturnForList(2) + "," + getEol();
addedType.add(boi.getOperationInfo().getOutput().getName().getLocalPart());
}
}
if (ret.length() > 0) {
ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturn(1);
}
if (ret.length() > 0) {
ret = rollbackColon(ret) + getEndIndentionWithReturn(0);
}
}
}
} catch (Throwable e) {
LOG.log(Level.WARNING, "getJSONSchema failed.", e);
}
}
return ret;
}
use of org.apache.cxf.service.model.BindingInfo in project camel by apache.
the class CxfHeaderFilterStrategy method getMessageHeaderFilter.
private MessageHeaderFilter getMessageHeaderFilter(Exchange exchange) {
BindingOperationInfo boi = exchange.getProperty(BindingOperationInfo.class.getName(), BindingOperationInfo.class);
String ns = null;
if (boi != null) {
BindingInfo b = boi.getBinding();
if (b != null) {
ns = b.getBindingId();
}
}
MessageHeaderFilter answer = null;
if (ns != null) {
answer = messageHeaderFiltersMap.get(ns);
}
return answer;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class STSTokenOutInterceptorTest method prepareMessage.
private MessageImpl prepareMessage(Bus bus, STSClient stsClient, String serviceAddress) throws EndpointException {
MessageImpl message = new MessageImpl();
message.put(SecurityConstants.STS_CLIENT, stsClient);
message.put(Message.ENDPOINT_ADDRESS, serviceAddress);
Exchange exchange = new ExchangeImpl();
ServiceInfo si = new ServiceInfo();
Service s = new ServiceImpl(si);
EndpointInfo ei = new EndpointInfo();
Endpoint ep = new EndpointImpl(bus, s, ei);
ei.setBinding(new BindingInfo(si, null));
message.setExchange(exchange);
exchange.put(Endpoint.class, ep);
return message;
}
Aggregations