use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.
the class Helper method testCustomClientConfigurationOnDispatchFromFile.
public boolean testCustomClientConfigurationOnDispatchFromFile() throws Exception {
final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
URL wsdlURL = new URL(address + "?wsdl");
Service service = Service.create(wsdlURL, serviceName);
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
BindingProvider bp = (BindingProvider) dispatch;
@SuppressWarnings("rawtypes") List<Handler> hc = bp.getBinding().getHandlerChain();
hc.add(new UserHandler());
bp.getBinding().setHandlerChain(hc);
ClientConfigUtil.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.
the class Helper method testCustomClientConfigurationOnDispatchUsingFeature.
public boolean testCustomClientConfigurationOnDispatchUsingFeature() throws Exception {
final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
URL wsdlURL = new URL(address + "?wsdl");
final String testConfigName = "MyTestConfig";
try {
// -- add test client configuration
TestUtils.addTestCaseClientConfiguration(testConfigName);
// --
Service service = Service.create(wsdlURL, serviceName);
Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD, new ClientConfigFeature(null, testConfigName));
BindingProvider bp = (BindingProvider) dispatch;
@SuppressWarnings("rawtypes") List<Handler> hc = bp.getBinding().getHandlerChain();
hc.add(new UserHandler());
bp.getBinding().setHandlerChain(hc);
Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
} finally {
// -- remove test client configuration --
TestUtils.removeTestCaseClientConfiguration(testConfigName);
// --
}
}
use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.
the class SOAPBindingTestCase method testClientAccess.
@Test
@RunAsClient
public void testClientAccess() throws Exception {
URL wsdlURL = new URL(baseURL + "?wsdl");
QName qname = new QName("http://org.jboss.ws/jaxws/binding", "SOAPEndpointService");
Service service = Service.create(wsdlURL, qname);
SOAPEndpoint port = service.getPort(SOAPEndpoint.class);
BindingProvider provider = (BindingProvider) port;
@SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.addAll(provider.getBinding().getHandlerChain());
handlerChain.add(new ClientHandler());
handlerChain.add(new ClientHandler2());
provider.getBinding().setHandlerChain(handlerChain);
String nsURI = port.namespace();
assertEquals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE + ":" + SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, nsURI);
}
use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.
the class CXFHandlerResolverImpl method getHandlerChain.
@SuppressWarnings("rawtypes")
public List<Handler> getHandlerChain(PortInfo portInfo) {
synchronized (handlerMap) {
List<Handler> handlerChain = handlerMap.get(portInfo);
if (handlerChain == null) {
QName portQName = portInfo.getPortName();
QName serviceQName = portInfo.getServiceName();
String bindingId = portInfo.getBindingID();
handlerChain = createHandlerChain(portInfo, portQName, serviceQName, bindingId);
handlerMap.put(portInfo, handlerChain);
}
return handlerChain;
}
}
use of javax.xml.ws.handler.Handler in project jbossws-cxf by jbossws.
the class CXFHandlerResolverImpl method createHandlerChain.
@SuppressWarnings("rawtypes")
protected List<Handler> createHandlerChain(PortInfo portInfo, QName portQName, QName serviceQName, String bindingID) {
List<Handler> chain = new ArrayList<Handler>();
InputStream is = getInputStream();
try {
if (is == null) {
throw MESSAGES.handlerConfigFileNotFound(handlerFile);
}
Element el = DOMUtils.parse(is, Holder.builder);
if (!ParserConstants.JAVAEE_NS.equals(el.getNamespaceURI()) || !ParserConstants.HANDLER_CHAINS.equals(el.getLocalName())) {
throw MESSAGES.differentElementExpected(handlerFile, "{" + ParserConstants.JAVAEE_NS + "}" + ParserConstants.HANDLER_CHAINS, "{" + el.getNamespaceURI() + "}" + el.getLocalName());
}
Node node = el.getFirstChild();
while (node != null) {
if (node instanceof Element) {
el = (Element) node;
if (!el.getNamespaceURI().equals(ParserConstants.JAVAEE_NS) || !el.getLocalName().equals(ParserConstants.HANDLER_CHAIN)) {
throw MESSAGES.differentElementExpected(handlerFile, "{" + ParserConstants.JAVAEE_NS + "}" + ParserConstants.HANDLER_CHAIN, "{" + el.getNamespaceURI() + "}" + el.getLocalName());
}
processHandlerChainElement(el, chain, portQName, serviceQName, bindingID);
}
node = node.getNextSibling();
}
} catch (WebServiceException e) {
throw e;
} catch (Exception e) {
throw MESSAGES.noHandlerChainFound(handlerFile, e);
}
assert chain != null;
return sortHandlers(chain);
}
Aggregations