use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class PerRequestFactory method create.
public Object create(Exchange ex) throws Throwable {
try {
if (svcClass.isInterface()) {
throw new Fault(new Message("SVC_CLASS_IS_INTERFACE", BUNDLE, svcClass.getName()));
}
if (Modifier.isAbstract(svcClass.getModifiers())) {
throw new Fault(new Message("SVC_CLASS_IS_ABSTRACT", BUNDLE, svcClass.getName()));
}
Object o = svcClass.newInstance();
Bus b = ex.getBus();
ResourceManager resourceManager = b.getExtension(ResourceManager.class);
if (resourceManager != null) {
ResourceInjector injector = new ResourceInjector(resourceManager);
injector.inject(o);
injector.construct(o);
}
return o;
} catch (InstantiationException e) {
throw new Fault(new Message("COULD_NOT_INSTANTIATE", BUNDLE), e);
} catch (IllegalAccessException e) {
throw new Fault(new Message("ILLEGAL_ACCESS", BUNDLE), e);
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class SoapFault method createFault.
public static SoapFault createFault(Fault f, SoapVersion v) {
if (f instanceof SoapFault) {
// if it's one of our internal codes, map it to the proper soap code
if (f.getFaultCode().getNamespaceURI().equals(Fault.FAULT_CODE_CLIENT.getNamespaceURI())) {
QName fc = f.getFaultCode();
if (Fault.FAULT_CODE_CLIENT.equals(fc)) {
fc = v.getSender();
} else if (Fault.FAULT_CODE_SERVER.equals(fc)) {
fc = v.getReceiver();
}
f.setFaultCode(fc);
}
if (v == Soap12.getInstance()) {
updateSoap12FaultCodes((SoapFault) f);
}
return (SoapFault) f;
}
QName fc = f.getFaultCode();
if (Fault.FAULT_CODE_CLIENT.equals(fc)) {
fc = v.getSender();
} else if (Fault.FAULT_CODE_SERVER.equals(fc)) {
fc = v.getReceiver();
}
SoapFault soapFault = new SoapFault(new Message(f.getMessage(), (ResourceBundle) null), f.getCause(), fc);
if (v == Soap12.getInstance()) {
updateSoap12FaultCodes(soapFault);
}
soapFault.setDetail(f.getDetail());
return soapFault;
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class MustUnderstandInterceptor method handleMessage.
public void handleMessage(SoapMessage soapMessage) {
Set<QName> paramHeaders = HeaderUtil.getHeaderQNameInOperationParam(soapMessage);
if (soapMessage.getHeaders().isEmpty() && paramHeaders.isEmpty()) {
return;
}
SoapVersion soapVersion = soapMessage.getVersion();
Set<Header> mustUnderstandHeaders = new HashSet<>();
Set<URI> serviceRoles = new HashSet<>();
Set<QName> notUnderstandHeaders = new HashSet<>();
Set<Header> ultimateReceiverHeaders = new HashSet<>();
Set<QName> mustUnderstandQNames = new HashSet<>();
initServiceSideInfo(mustUnderstandQNames, soapMessage, serviceRoles, paramHeaders);
buildMustUnderstandHeaders(mustUnderstandHeaders, soapMessage, serviceRoles, ultimateReceiverHeaders);
checkUnderstand(mustUnderstandHeaders, mustUnderstandQNames, notUnderstandHeaders);
if (!notUnderstandHeaders.isEmpty()) {
if (!isRequestor(soapMessage)) {
soapMessage.put(MustUnderstandInterceptor.UNKNOWNS, notUnderstandHeaders);
soapMessage.getInterceptorChain().add(ending);
} else {
throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, notUnderstandHeaders), soapVersion.getMustUnderstand());
}
}
if (!ultimateReceiverHeaders.isEmpty() && !isRequestor(soapMessage)) {
checkUltimateReceiverHeaders(ultimateReceiverHeaders, mustUnderstandQNames, soapMessage);
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class JaxWsServiceFactoryBean method initializeWSDLOperationsForProvider.
protected void initializeWSDLOperationsForProvider() {
Class<?> c = getProviderParameterType(getServiceClass());
if (c == null) {
throw new ServiceConstructionException(new Message("INVALID_PROVIDER_EXC", LOG));
}
if (getEndpointInfo() == null && isFromWsdl()) {
// most likely, they specified a WSDL, but for some reason
// did not give a valid ServiceName/PortName. For provider,
// we'll allow this since everything is bound directly to
// the invoke method, however, this CAN cause other problems
// such as addresses in the wsdl not getting updated and such
// so we'll WARN about it.....
List<QName> enames = new ArrayList<>();
for (ServiceInfo si : getService().getServiceInfos()) {
for (EndpointInfo ep : si.getEndpoints()) {
enames.add(ep.getName());
}
}
LOG.log(Level.WARNING, "COULD_NOT_FIND_ENDPOINT", new Object[] { getEndpointName(), enames });
}
try {
Method invoke = getServiceClass().getMethod("invoke", c);
QName catchAll = new QName("http://cxf.apache.org/jaxws/provider", "invoke");
// Bind every operation to the invoke method.
for (ServiceInfo si : getService().getServiceInfos()) {
si.setProperty("soap.force.doclit.bare", Boolean.TRUE);
if (!isFromWsdl()) {
for (EndpointInfo ei : si.getEndpoints()) {
ei.setProperty("soap.no.validate.parts", Boolean.TRUE);
}
}
for (BindingInfo bind : si.getBindings()) {
for (BindingOperationInfo bop : bind.getOperations()) {
OperationInfo o = bop.getOperationInfo();
if (bop.isUnwrappedCapable()) {
// force to bare, no unwrapping
bop.getOperationInfo().setUnwrappedOperation(null);
bop.setUnwrappedOperation(null);
}
if (o.getInput() != null) {
final List<MessagePartInfo> messageParts;
if (o.getInput().getMessagePartsNumber() == 0) {
MessagePartInfo inf = o.getInput().addMessagePart(o.getName());
inf.setConcreteName(o.getName());
messageParts = o.getInput().getMessageParts();
bop.getInput().setMessageParts(messageParts);
} else {
messageParts = o.getInput().getMessageParts();
}
for (MessagePartInfo inf : messageParts) {
inf.setTypeClass(c);
break;
}
}
if (o.getOutput() != null) {
final List<MessagePartInfo> messageParts;
if (o.getOutput().getMessagePartsNumber() == 0) {
MessagePartInfo inf = o.getOutput().addMessagePart(o.getName());
inf.setConcreteName(new QName(o.getName().getNamespaceURI(), o.getName().getLocalPart() + "Response"));
messageParts = o.getOutput().getMessageParts();
bop.getOutput().setMessageParts(messageParts);
} else {
messageParts = o.getOutput().getMessageParts();
}
for (MessagePartInfo inf : messageParts) {
inf.setTypeClass(c);
break;
}
}
getMethodDispatcher().bind(o, invoke);
}
BindingOperationInfo bop = bind.getOperation(catchAll);
if (bop == null) {
OperationInfo op = bind.getInterface().getOperation(catchAll);
if (op == null) {
op = bind.getInterface().addOperation(catchAll);
String name = catchAll.getLocalPart();
MessageInfo mInfo = op.createMessage(new QName(catchAll.getNamespaceURI(), name + "Request"), MessageInfo.Type.INPUT);
op.setInput(catchAll.getLocalPart() + "Request", mInfo);
MessagePartInfo mpi = mInfo.addMessagePart("parameters");
mpi.setElement(true);
mpi.setTypeClass(c);
mpi.setTypeQName(Constants.XSD_ANYTYPE);
mInfo = op.createMessage(new QName(catchAll.getNamespaceURI(), name + "Response"), MessageInfo.Type.OUTPUT);
op.setOutput(name + "Response", mInfo);
mpi = mInfo.addMessagePart("parameters");
mpi.setElement(true);
mpi.setTypeClass(c);
mpi.setTypeQName(Constants.XSD_ANYTYPE);
BindingOperationInfo bo = new BindingOperationInfo(bind, op);
op.setProperty("operation.is.synthetic", Boolean.TRUE);
bo.setProperty("operation.is.synthetic", Boolean.TRUE);
bind.addOperation(bo);
}
}
}
}
} catch (SecurityException | NoSuchMethodException e) {
throw new ServiceConstructionException(e);
}
}
use of org.apache.cxf.common.i18n.Message in project cxf by apache.
the class ProviderImpl method createEndpoint.
// new in 2.2
public Endpoint createEndpoint(String bindingId, Class<?> implementorClass, Invoker invoker, WebServiceFeature... features) {
if (EndpointUtils.isValidImplementor(implementorClass)) {
Bus bus = BusFactory.getThreadDefaultBus();
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
if (features != null) {
factory.getJaxWsServiceFactory().setWsFeatures(Arrays.asList(features));
}
if (invoker != null) {
factory.setInvoker(new JAXWSMethodInvoker(invoker));
try {
invoker.inject(new WebServiceContextImpl());
} catch (Exception e) {
throw new WebServiceException(new Message("ENDPOINT_CREATION_FAILED_MSG", LOG).toString(), e);
}
}
EndpointImpl ep = new EndpointImpl(bus, null, factory);
ep.setImplementorClass(implementorClass);
return ep;
}
throw new WebServiceException(new Message("INVALID_IMPLEMENTOR_EXC", LOG).toString());
}
Aggregations