use of javax.xml.ws.handler.PortInfo in project nhin-d by DirectProject.
the class DirectSOAPHandlerResolverTest method testGetHandlerChain.
/**
* Test the getHandlerChain method.
*/
public void testGetHandlerChain() {
PortInfo portInfo = null;
List<Handler> output = null;
DirectSOAPHandlerResolver handler = new DirectSOAPHandlerResolver();
output = handler.getHandlerChain(portInfo);
assertNotNull("List is null", output);
assertTrue("List contains 0 elements", !output.isEmpty());
assertEquals("List contains more than expected elements", 1, output.size());
assertTrue("List does not contain expected element", output.get(0) instanceof DirectSOAPHandler);
}
use of javax.xml.ws.handler.PortInfo in project scout.rt by eclipse.
the class PortProducer method provide.
/**
* Creates a new Port to interact with the webservice endpoint.
*/
@Override
public PORT provide() {
try {
// Create the service
final Constructor<? extends Service> constructor = m_serviceClazz.getConstructor(URL.class, QName.class);
@SuppressWarnings("unchecked") final SERVICE service = (SERVICE) constructor.newInstance(m_wsdlLocation, new QName(m_targetNamespace, m_serviceName));
// Install the handler chain
service.setHandlerResolver(new HandlerResolver() {
@Override
public List<Handler> getHandlerChain(final PortInfo portInfo) {
final List<Handler<? extends MessageContext>> handlerChain = new ArrayList<>();
m_initializer.initHandlers(handlerChain);
for (int i = 0; i < handlerChain.size(); i++) {
handlerChain.set(i, proxyHandler(handlerChain.get(i)));
}
@SuppressWarnings("unchecked") final List<Handler> handlers = TypeCastUtility.castValue(handlerChain, List.class);
return handlers;
}
});
// Install implementor specific webservice features
final List<WebServiceFeature> webServiceFeatures = new ArrayList<>();
m_initializer.initWebServiceFeatures(webServiceFeatures);
// Create the port
return service.getPort(m_portTypeClazz, CollectionUtility.toArray(webServiceFeatures, WebServiceFeature.class));
} catch (final ReflectiveOperationException e) {
throw new WebServiceException("Failed to instantiate webservice stub.", e);
}
}
use of javax.xml.ws.handler.PortInfo in project scout.rt by eclipse.
the class ServicePool method createElement.
@Override
protected SERVICE createElement() {
try {
// Create the service
final Constructor<? extends Service> constructor = m_serviceClazz.getConstructor(URL.class, QName.class);
@SuppressWarnings("unchecked") final SERVICE service = (SERVICE) constructor.newInstance(m_wsdlLocation, new QName(m_targetNamespace, m_serviceName));
// Install the handler chain
service.setHandlerResolver(new HandlerResolver() {
@Override
public List<Handler> getHandlerChain(final PortInfo portInfo) {
final List<Handler<? extends MessageContext>> handlerChain = new ArrayList<>();
m_initializer.initHandlers(handlerChain);
for (int i = 0; i < handlerChain.size(); i++) {
handlerChain.set(i, proxyHandler(handlerChain.get(i)));
}
@SuppressWarnings("unchecked") final List<Handler> handlers = TypeCastUtility.castValue(handlerChain, List.class);
return handlers;
}
});
return service;
} catch (ReflectiveOperationException e) {
throw new WebServiceException("Failed to instantiate webservice stub.", e);
}
}
use of javax.xml.ws.handler.PortInfo in project jbossws-cxf by jbossws.
the class HandlerChainClient method testService1.
public String testService1(String reqStr) throws Exception {
PortInfo info = new PortInfo() {
@Override
public String getBindingID() {
return "http://schemas.xmlsoap.org/wsdl/soap/http";
}
@Override
public QName getPortName() {
return null;
}
@Override
public QName getServiceName() {
return null;
}
};
HandlerResolver resolver = service1.getHandlerResolver();
@SuppressWarnings("rawtypes") List<Handler> handlerChain = resolver.getHandlerChain(info);
if ("[LogHandler, AuthorizationHandler, RoutingHandler, MimeHandler]".equals(handlerChain.toString()) == false)
throw new IllegalStateException("Unexpected resolver handlers: " + handlerChain);
Endpoint port = service1.getPort(Endpoint.class);
return port.echo(reqStr);
}
use of javax.xml.ws.handler.PortInfo in project openolat by klemens.
the class ViteroManager method checkConnection.
public boolean checkConnection(final String url, final String login, final String password, final int customerId) throws VmsNotAvailableException {
try {
LicenceService ss = new LicenceService();
ss.setHandlerResolver(new HandlerResolver() {
@SuppressWarnings("rawtypes")
@Override
public List<Handler> getHandlerChain(PortInfo portInfo) {
List<Handler> handlerList = new ArrayList<Handler>();
handlerList.add(new ViteroSecurityHandler(login, password));
return handlerList;
}
});
Licence port = ss.getLicenceSoap11();
String endPoint = UriBuilder.fromUri(url).path("services").path("LicenseService").build().toString();
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);
GetModulesForCustomerRequest request = new GetModulesForCustomerRequest();
request.setCustomerid(customerId);
Modulestype modulesType = port.getModulesForCustomer(request);
return modulesType != null;
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case unsufficientRights:
log.error("Unsufficient rights", f);
break;
default:
logAxisError("Cannot check connection", f);
}
return false;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.warn("Error checking connection", e);
return false;
}
}
Aggregations