use of javax.xml.ws.WebServiceException in project cxf by apache.
the class AnnotationHandlerChainBuilder method processHandlerChainElement.
private void processHandlerChainElement(Element el, List<Handler> chain, QName portQName, QName serviceQName, String bindingID) {
Node node = el.getFirstChild();
while (node != null) {
Node cur = node;
node = node.getNextSibling();
if (cur instanceof Element) {
el = (Element) cur;
if (!el.getNamespaceURI().equals("http://java.sun.com/xml/ns/javaee")) {
String xml = StaxUtils.toString(el);
throw new WebServiceException(BundleUtils.getFormattedString(BUNDLE, "NOT_VALID_ELEMENT_IN_HANDLER", xml));
}
String name = el.getLocalName();
if ("port-name-pattern".equals(name)) {
if (!patternMatches(el, portQName)) {
return;
}
} else if ("service-name-pattern".equals(name)) {
if (!patternMatches(el, serviceQName)) {
return;
}
} else if ("protocol-bindings".equals(name)) {
if (!protocolMatches(el, bindingID)) {
return;
}
} else if ("handler".equals(name)) {
processHandlerElement(el, chain);
}
}
}
}
use of javax.xml.ws.WebServiceException in project cxf by apache.
the class HandlerChainBuilder method buildHandlerChain.
protected List<Handler> buildHandlerChain(PortComponentHandlerType ht, ClassLoader classLoader) {
List<Handler> handlerChain = new ArrayList<>();
try {
final boolean fineLog = LOG.isLoggable(Level.FINE);
if (fineLog) {
LOG.log(Level.FINE, "loading handler", trimString(ht.getHandlerName().getValue()));
}
Class<? extends Handler> handlerClass = Class.forName(trimString(ht.getHandlerClass().getValue()), true, classLoader).asSubclass(Handler.class);
Handler<?> handler = handlerClass.newInstance();
if (fineLog) {
LOG.fine("adding handler to chain: " + handler);
}
configureHandler(handler, ht);
handlerChain.add(handler);
} catch (Exception e) {
throw new WebServiceException(BUNDLE.getString("HANDLER_INSTANTIATION_EXC"), e);
}
return handlerChain;
}
use of javax.xml.ws.WebServiceException in project cxf by apache.
the class LogicalMessageImpl method getPayload.
public Object getPayload(JAXBContext arg0) {
try {
Source s = getPayload();
if (s instanceof DOMSource) {
DOMSource ds = (DOMSource) s;
ds.setNode(org.apache.cxf.helpers.DOMUtils.getDomElement(ds.getNode()));
Node parent = ds.getNode().getParentNode();
Node next = ds.getNode().getNextSibling();
if (parent instanceof DocumentFragment) {
parent.removeChild(ds.getNode());
}
try {
return JAXBUtils.unmarshall(arg0, ds);
} finally {
if (parent instanceof DocumentFragment) {
parent.insertBefore(ds.getNode(), next);
}
}
}
return JAXBUtils.unmarshall(arg0, getPayload());
} catch (JAXBException e) {
throw new WebServiceException(e);
}
}
use of javax.xml.ws.WebServiceException in project cxf by apache.
the class SOAPMessageContextImpl method getHeaders.
public Object[] getHeaders(QName name, JAXBContext context, boolean allRoles) {
SOAPMessage msg = getMessage();
SOAPHeader header;
try {
header = msg.getSOAPPart().getEnvelope().getHeader();
if (header == null || !header.hasChildNodes()) {
return new Object[0];
}
List<Object> ret = new ArrayList<>();
Iterator<SOAPHeaderElement> it = CastUtils.cast(header.examineAllHeaderElements());
while (it.hasNext()) {
SOAPHeaderElement she = it.next();
if ((allRoles || roles.contains(she.getActor())) && name.equals(she.getElementQName())) {
ret.add(JAXBUtils.unmarshall(context, she));
}
}
return ret.toArray(new Object[ret.size()]);
} catch (SOAPException e) {
throw new WebServiceException(e);
} catch (JAXBException e) {
throw new WebServiceException(e);
}
}
use of javax.xml.ws.WebServiceException in project cxf by apache.
the class EndpointReferenceTest method testEndpointGetEndpointReferenceInvalid.
@Test
public void testEndpointGetEndpointReferenceInvalid() throws Exception {
GreeterImpl greeter = new GreeterImpl();
try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String) null)) {
endpoint.publish("http://localhost:8080/test");
try {
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
Document doc = StaxUtils.read(is);
Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:ReferenceParameters", "");
endpoint.getEndpointReference(MyEndpointReference.class, referenceParameters);
fail("Did not get expected WebServiceException");
} catch (WebServiceException e) {
// do nothing
}
endpoint.stop();
}
}
Aggregations