use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.
the class JaxWsClientProxy method mapException.
Exception mapException(Method method, BindingOperationInfo boi, Exception ex) {
if (method != null) {
for (Class<?> excls : method.getExceptionTypes()) {
if (excls.isInstance(ex)) {
return ex;
}
}
} else if (boi != null) {
for (BindingFaultInfo fi : boi.getFaults()) {
Class<?> c = fi.getFaultInfo().getProperty(Class.class.getName(), Class.class);
if (c != null && c.isInstance(ex)) {
return ex;
}
}
if (ex instanceof IOException) {
return ex;
}
}
if (ex instanceof Fault && ex.getCause() instanceof IOException) {
return new WebServiceException(ex.getMessage(), ex.getCause());
}
if (getBinding() instanceof HTTPBinding) {
HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
exception.initCause(ex);
return exception;
} else if (getBinding() instanceof SOAPBinding) {
try {
SOAPFault soapFault = createSoapFault((SOAPBinding) getBinding(), ex);
if (soapFault == null) {
throw new WebServiceException(ex);
}
SOAPFaultException exception = new SOAPFaultException(soapFault);
if (ex instanceof Fault && ex.getCause() != null) {
exception.initCause(ex.getCause());
} else {
exception.initCause(ex);
}
return exception;
} catch (SOAPException e) {
return new WebServiceException(ex);
}
}
return new WebServiceException(ex);
}
use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.
the class InternalContextUtils method getActionFromServiceModel.
/**
* Get action from service model.
*
* @param message the current message
* @param fault the fault if one is set
*/
private static String getActionFromServiceModel(Message message, Exception fault) {
String action = null;
BindingOperationInfo bindingOpInfo = message.getExchange().getBindingOperationInfo();
if (bindingOpInfo != null) {
if (bindingOpInfo.isUnwrappedCapable()) {
bindingOpInfo = bindingOpInfo.getUnwrappedOperation();
}
if (fault == null) {
action = (String) message.get(ContextUtils.ACTION);
if (StringUtils.isEmpty(action)) {
action = (String) message.get(SoapBindingConstants.SOAP_ACTION);
}
if (action == null || "".equals(action)) {
MessageInfo msgInfo = ContextUtils.isRequestor(message) ? bindingOpInfo.getOperationInfo().getInput() : bindingOpInfo.getOperationInfo().getOutput();
String cachedAction = (String) msgInfo.getProperty(ContextUtils.ACTION);
if (cachedAction == null) {
action = getActionFromMessageAttributes(msgInfo);
} else {
action = cachedAction;
}
if (action == null && ContextUtils.isRequestor(message)) {
SoapOperationInfo soi = getSoapOperationInfo(bindingOpInfo);
action = soi == null ? null : soi.getAction();
action = StringUtils.isEmpty(action) ? null : action;
}
}
} else {
Throwable t = fault.getCause();
// http://www.w3.org/2005/02/addressing/wsdl schema
for (BindingFaultInfo bfi : bindingOpInfo.getFaults()) {
FaultInfo fi = bfi.getFaultInfo();
if (fi.size() == 0) {
continue;
}
if (t != null && matchFault(t, fi)) {
if (fi.getExtensionAttributes() == null) {
continue;
}
String attr = (String) fi.getExtensionAttributes().get(Names.WSAW_ACTION_QNAME);
if (attr == null) {
attr = (String) fi.getExtensionAttributes().get(new QName(Names.WSA_NAMESPACE_WSDL_NAME_OLD, Names.WSAW_ACTION_NAME));
}
if (attr != null) {
action = attr;
break;
}
}
}
}
}
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("action determined from service model: " + action);
}
return action;
}
use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.
the class EndpointPolicyImpl method initializeVocabulary.
synchronized void initializeVocabulary(Message m) {
if (vocabulary != null) {
return;
}
List<Assertion> v = new ArrayList<>();
List<Assertion> fv = null;
if (requestor) {
fv = new ArrayList<>();
}
// vocabulary of alternative chosen for endpoint
if (getChosenAlternative() != null) {
for (Assertion a : getChosenAlternative()) {
if (a.isOptional()) {
continue;
}
v.add(a);
if (null != fv) {
fv.add(a);
}
}
}
// (in case of a client endpoint) messages
for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
EffectivePolicy p;
if (!this.requestor) {
p = engine.getEffectiveServerRequestPolicy(ei, boi, m);
Collection<Assertion> c = engine.getAssertions(p, false);
if (c != null) {
addAll(v, c);
}
} else {
p = engine.getEffectiveClientResponsePolicy(ei, boi, m);
Collection<Assertion> c = engine.getAssertions(p, false);
if (c != null) {
addAll(v, c);
if (null != fv) {
addAll(fv, c);
}
}
if (boi.getFaults() != null && null != fv) {
for (BindingFaultInfo bfi : boi.getFaults()) {
p = engine.getEffectiveClientFaultPolicy(ei, boi, bfi, m);
c = engine.getAssertions(p, false);
if (c != null) {
addAll(fv, c);
}
}
}
}
}
if (requestor) {
faultVocabulary = fv;
}
vocabulary = v;
}
use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.
the class PolicyAnnotationListener method addPolicies.
private void addPolicies(AbstractServiceFactoryBean factory, Endpoint ep, Class<?> cls) {
List<Policy> list = CastUtils.cast((List<?>) ep.getEndpointInfo().getInterface().removeProperty(EXTRA_POLICIES));
if (list != null) {
addPolicies(factory, ep, cls, list, Policy.Placement.BINDING);
}
ServiceInfo service = ep.getService().getServiceInfos().get(0);
for (BindingOperationInfo binfo : ep.getBinding().getBindingInfo().getOperations()) {
List<Policy> later = CastUtils.cast((List<?>) binfo.getOperationInfo().removeProperty(EXTRA_POLICIES));
if (later != null) {
for (Policy p : later) {
switch(p.placement()) {
case DEFAULT:
case BINDING_OPERATION:
addPolicy(binfo, service, p, cls, binfo.getName().getLocalPart() + "BindingOpPolicy");
break;
case BINDING_OPERATION_INPUT:
addPolicy(binfo.getInput(), service, p, cls, binfo.getName().getLocalPart() + "BindingOpInputPolicy");
break;
case BINDING_OPERATION_OUTPUT:
addPolicy(binfo.getOutput(), service, p, cls, binfo.getName().getLocalPart() + "BindingOpOutputPolicy");
break;
case BINDING_OPERATION_FAULT:
{
for (BindingFaultInfo f : binfo.getFaults()) {
if (p.faultClass().equals(f.getFaultInfo().getProperty(Class.class.getName()))) {
addPolicy(f, service, p, cls, f.getFaultInfo().getName().getLocalPart() + "BindingOpFaultPolicy");
}
}
break;
}
default:
}
}
}
}
}
use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.
the class PolicyVerificationInFaultInterceptor method handle.
/**
* Determines the effective policy, and checks if one of its alternatives
* is supported.
*
* @param message
* @throws PolicyException if none of the alternatives is supported
*/
protected void handle(Message message) {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
if (null == aim) {
return;
}
if (!MessageUtils.isRequestor(message)) {
LOG.fine("Not a requestor.");
return;
}
Exchange exchange = message.getExchange();
assert null != exchange;
BindingOperationInfo boi = exchange.getBindingOperationInfo();
if (null == boi) {
LOG.fine("No binding operation info.");
return;
}
Endpoint e = exchange.getEndpoint();
if (null == e) {
LOG.fine("No endpoint.");
return;
}
EndpointInfo ei = e.getEndpointInfo();
Bus bus = exchange.getBus();
PolicyEngine pe = bus.getExtension(PolicyEngine.class);
if (null == pe) {
return;
}
Exception ex = message.getContent(Exception.class);
if (null == ex) {
ex = exchange.get(Exception.class);
}
BindingFaultInfo bfi = getBindingFaultInfo(message, ex, boi);
if (bfi == null) {
return;
}
getTransportAssertions(message);
EffectivePolicy effectivePolicy = pe.getEffectiveClientFaultPolicy(ei, boi, bfi, message);
if (effectivePolicy != null) {
aim.checkEffectivePolicy(effectivePolicy.getPolicy());
LOG.fine("Verified policies for inbound message.");
}
}
Aggregations