use of org.apache.cxf.service.model.BindingFaultInfo 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.BindingFaultInfo in project jbossws-cxf by jbossws.
the class PolicySetsAnnotationListener method addPolicies.
private void addPolicies(AbstractServiceFactoryBean factory, Endpoint ep, Class<?> seiCls, Class<?> implCls) {
EndpointPolicyAttachments epa = null;
Class<?> cls = seiCls;
if (ep.getEndpointInfo().getInterface() != null) {
epa = getEndpointPolicyAttachment(seiCls);
}
if (epa == null) {
cls = implCls;
epa = getEndpointPolicyAttachment(implCls);
}
if (epa != null) {
final BindingInfo binf = ep.getBinding().getBindingInfo();
final ServiceInfo si = ep.getService().getServiceInfos().get(0);
final InterfaceInfo inf = ep.getEndpointInfo().getInterface();
for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.BINDING)) {
addPolicy(binf, si, pa, cls, binf.getName().getLocalPart() + "BindingPolicy");
}
for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.PORT_TYPE)) {
addPolicy(inf, si, pa, cls, inf.getName().getLocalPart() + "PortTypePolicy");
}
for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.SERVICE)) {
addPolicy(si, si, pa, cls, si.getName().getLocalPart() + "ServicePolicy");
}
for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.SERVICE_PORT)) {
addPolicy(ep.getEndpointInfo(), si, pa, cls, ep.getEndpointInfo().getName().getLocalPart() + "PortPolicy");
}
for (BindingOperationInfo binfo : binf.getOperations()) {
for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.BINDING_OPERATION)) {
addPolicy(binfo, si, pa, cls, binfo.getName().getLocalPart() + "BindingOpPolicy");
}
for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.BINDING_OPERATION_INPUT)) {
addPolicy(binfo.getInput(), si, pa, cls, binfo.getName().getLocalPart() + "BindingOpInputPolicy");
}
for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.BINDING_OPERATION_OUTPUT)) {
addPolicy(binfo.getOutput(), si, pa, cls, binfo.getName().getLocalPart() + "BindingOpOutputPolicy");
}
for (PolicyAttachment pa : epa.getPolicyAttachments(Placement.BINDING_OPERATION_FAULT)) {
for (BindingFaultInfo f : binfo.getFaults()) {
addPolicy(f, si, pa, cls, f.getFaultInfo().getName().getLocalPart() + "BindingOpFaultPolicy");
}
}
}
}
}
use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.
the class SoapBindingFactoryTest method testSoap12Factory.
@Test
public void testSoap12Factory() throws Exception {
Definition d = createDefinition("/wsdl_soap/hello_world_soap12.wsdl");
Bus bus = getMockBus();
BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP12, bus);
expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
ServiceInfo serviceInfo = builder.buildServices(d, new QName("http://apache.org/hello_world_soap12_http", "SOAPService")).get(0);
BindingInfo bi = serviceInfo.getBindings().iterator().next();
assertTrue(bi instanceof SoapBindingInfo);
SoapBindingInfo sbi = (SoapBindingInfo) bi;
assertEquals("document", sbi.getStyle());
assertEquals(WSDLConstants.NS_SOAP_HTTP_TRANSPORT, sbi.getTransportURI());
assertTrue(sbi.getSoapVersion() instanceof Soap12);
BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "sayHi"));
SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("sayHiAction", sboi.getAction());
BindingMessageInfo input = boi.getInput();
SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
assertEquals("literal", bodyInfo.getUse());
List<MessagePartInfo> parts = bodyInfo.getParts();
assertNotNull(parts);
assertEquals(1, parts.size());
boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "pingMe"));
sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("", sboi.getAction());
Collection<BindingFaultInfo> faults = boi.getFaults();
assertEquals(1, faults.size());
BindingFaultInfo faultInfo = boi.getFault(new QName("http://apache.org/hello_world_soap12_http", "pingMeFault"));
assertNotNull(faultInfo);
}
use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.
the class JaxWsEndpointImpl method extractWsdlExtensibilities.
private void extractWsdlExtensibilities(EndpointInfo endpoint) {
List<ExtensibilityElement> portExtensors = getExtensors(endpoint);
List<ExtensibilityElement> bindingExtensors = getExtensors(endpoint.getBinding());
// check the extensions under <wsdl:binding>
checkRespectBindingFeature(bindingExtensors);
Collection<BindingOperationInfo> bindingOperations = endpoint.getBinding().getOperations();
if (null != bindingOperations) {
Iterator<BindingOperationInfo> iterator = bindingOperations.iterator();
while (iterator.hasNext()) {
BindingOperationInfo operationInfo = iterator.next();
BindingMessageInfo inputInfo = operationInfo.getInput();
BindingMessageInfo outputnfo = operationInfo.getOutput();
Collection<BindingFaultInfo> faults = operationInfo.getFaults();
// check the extensions under <wsdl:operation>
checkRespectBindingFeature(getExtensors(operationInfo));
// check the extensions under <wsdl:input>
checkRespectBindingFeature(getExtensors(inputInfo));
// check the extensions under <wsdl:output>
checkRespectBindingFeature(getExtensors(outputnfo));
if (null != faults) {
Iterator<BindingFaultInfo> faultIterator = faults.iterator();
while (faultIterator.hasNext()) {
BindingFaultInfo faultInfo = faultIterator.next();
// check the extensions under <wsdl:fault>
checkRespectBindingFeature(getExtensors(faultInfo));
}
}
}
}
if (hasUsingAddressing(bindingExtensors) || hasUsingAddressing(portExtensors)) {
WSAddressingFeature feature = new WSAddressingFeature();
if (addressingRequired(bindingExtensors) || addressingRequired(portExtensors)) {
feature.setAddressingRequired(true);
}
addAddressingFeature(feature);
}
extractWsdlEprs(endpoint);
}
use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.
the class MessageModeOutInterceptor method validateFaultDetail.
private void validateFaultDetail(Element detail, Schema schema, BindingOperationInfo bop) throws Exception {
if (detail != null) {
Element el = DOMUtils.getFirstElement(detail);
while (el != null) {
QName qn = DOMUtils.getElementQName(el);
for (BindingFaultInfo bfi : bop.getFaults()) {
if (bfi.getFaultInfo().getMessagePartByIndex(0).getConcreteName().equals(qn)) {
// Found a fault with the correct QName, we can validate it
schema.newValidator().validate(new DOMSource(DOMUtils.getDomElement(el)));
}
}
el = DOMUtils.getNextElement(el);
}
}
}
Aggregations