本文整理汇总了Java中javax.xml.ws.handler.PortInfo类的典型用法代码示例。如果您正苦于以下问题:Java PortInfo类的具体用法?Java PortInfo怎么用?Java PortInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PortInfo类属于javax.xml.ws.handler包,在下文中一共展示了PortInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHandlerChain
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
@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;
}
}
示例2: buildWsClient
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
public <I> I buildWsClient(T wsServiceImplementation, Class<I> ifaceImplementationClass, final List<Handler>extraHandlers, Map<String,Object> ctxSettings){
final WsSettings settings = WsSettingsLoader.loadSettings();
wsServiceImplementation.setHandlerResolver(new HandlerResolver() {
@Override
public List<Handler> getHandlerChain(PortInfo portInfo) {
final List<Handler> handlerList = new ArrayList<Handler>();
handlerList.add(new AuthHandler(settings.getUsername(), settings.getPassword()));
handlerList.addAll(extraHandlers);
return handlerList;
}
});
final I serviceIface = wsServiceImplementation.getPort(ifaceImplementationClass);
final BindingProvider bindingProvider = (BindingProvider) serviceIface;
final Map<String, Object> req_ctx = bindingProvider.getRequestContext();
req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, settings.getWsUrl());
req_ctx.putAll(ctxSettings);
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, settings.getWsUrl());
return serviceIface;
}
示例3: testServiceAndPortNoComposite
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
/**
* Test creating a service without a sparse composite. This verifies pre-existing default
* behavior.
*/
public void testServiceAndPortNoComposite() {
QName serviceQName = new QName(namespaceURI, svcLocalPart);
QName portQName = new QName(namespaceURI, portLocalPart);
Service service = Service.create(serviceQName);
HandlerResolver resolver = service.getHandlerResolver();
assertNotNull(resolver);
PortInfo pi = new DummyPortInfo();
List<Handler> list = resolver.getHandlerChain(pi);
assertEquals(0, list.size());
ClientMetadataHandlerChainTestSEI port = service.getPort(portQName, ClientMetadataHandlerChainTestSEI.class);
// Verify that ports created under the service have no handlers from the sparse composite
BindingProvider bindingProvider = (BindingProvider) port;
Binding binding = (Binding) bindingProvider.getBinding();
List<Handler> portHandlers = binding.getHandlerChain();
assertEquals(0, portHandlers.size());
}
示例4: testCachingOnClient
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
/**
* Validate that handler information can NOT be cached on the client. That is because the client
* can specify handler information per instance of a service delegate. Those service
* delegates could share a ServiceDescription, but since each service delegate could specify
* unique handler information, we can't use common handler information stored on the
* ServiceDescription
*/
public void testCachingOnClient() {
ServiceDescription serviceDesc = DescriptionFactory.createServiceDescription(RoleBasedMUServiceImpl.class);
HandlerResolverImpl handlerResolver1 = new HandlerResolverImpl(serviceDesc, "sd1");
HandlerResolverImpl handlerResolver2 = new HandlerResolverImpl(serviceDesc, "sd2");
EndpointDescription epDesc = serviceDesc.getEndpointDescriptions()[0];
PortInfo portInfo = epDesc.getPortInfo();
List<String> roles1 = handlerResolver1.getRoles(portInfo);
List<String> roles2 = handlerResolver2.getRoles(portInfo);
assertNotNull(roles1);
assertNotNull(roles2);
assertTrue(roles1 != roles2);
}
示例5: testHandlerResolverNoKey
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
/**
* Test that setting the handler chain type on a sparse composite, but not
* specifying that composite during construction of the HandlerResolver (i.e. no
* Delegate key specified) results in no hanlders returned from this resolver.
*/
public void testHandlerResolverNoKey() {
QName serviceQName = new QName(namespaceURI, svcLocalPart);
// Create a composite with a JAXB Handler Config
DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
HandlerChainsType handlerChainsType = getHandlerChainsType();
sparseComposite.setHandlerChainsType(handlerChainsType);
Object serviceDelegateKey = "CompositeKey";
ServiceDescription serviceDesc =
DescriptionFactory.createServiceDescription(null, serviceQName, HandlerResolverTestService.class, sparseComposite, serviceDelegateKey);
HandlerResolver resolver = new HandlerResolverImpl(serviceDesc);
assertNotNull(resolver);
PortInfo pi = new DummyPortInfo();
List<Handler> list = resolver.getHandlerChain(pi);
assertEquals(0, list.size());
}
示例6: testHandlerResolverInvalidPortInfo
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
/**
* The sparse composite has handler config information for the key that the HandlerResolver
* is created with, so that handler resolver contains those handlers. However, the
* portInfo specified on the getHandlerChain does NOT match the QName in the config file
* so no handlers should be returned.
*/
public void testHandlerResolverInvalidPortInfo() {
QName serviceQName = new QName(namespaceURI, svcLocalPart);
QName portQName = new QName(namespaceURI, portWrongLocalPart);
// Create a composite with a JAXB Handler Config
DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
HandlerChainsType handlerChainsType = getHandlerChainsType();
sparseComposite.setHandlerChainsType(handlerChainsType);
Object serviceDelegateKey = "CompositeKey";
// The getHandlerChain will do handler lifecycle management as well, so there needs to be
// and EnpdointDescription (representing the Port) under the ServiceDescription
ServiceDescription serviceDesc =
DescriptionFactory.createServiceDescription(null, serviceQName, HandlerResolverTestService.class, sparseComposite, serviceDelegateKey);
EndpointDescription endpointDesc =
DescriptionFactory.updateEndpoint(serviceDesc, HandlerResolverTestSEI.class, portQName, DescriptionFactory.UpdateType.GET_PORT);
HandlerResolver resolver = new HandlerResolverImpl(serviceDesc, serviceDelegateKey);
assertNotNull(resolver);
PortInfo pi = new DummyPortInfo();
List<Handler> list = resolver.getHandlerChain(pi);
assertEquals(0, list.size());
}
示例7: testHandlerResolverValidPortInfo
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
/**
* The sparse composite has handler config information for the key that the HandlerResolver
* is created with, so that handler resolver contains those handlers.
*/
public void testHandlerResolverValidPortInfo() {
QName serviceQName = new QName(namespaceURI, svcLocalPart);
QName portQName = new QName(namespaceURI, portLocalPart);
// Create a composite with a JAXB Handler Config
DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
HandlerChainsType handlerChainsType = getHandlerChainsType();
sparseComposite.setHandlerChainsType(handlerChainsType);
Object serviceDelegateKey = "CompositeKey";
// The getHandlerChain will do handler lifecycle management as well, so there needs to be
// and EnpdointDescription (representing the Port) under the ServiceDescription
ServiceDescription serviceDesc =
DescriptionFactory.createServiceDescription(null, serviceQName, HandlerResolverTestService.class, sparseComposite, serviceDelegateKey);
EndpointDescription endpointDesc =
DescriptionFactory.updateEndpoint(serviceDesc, HandlerResolverTestSEI.class, portQName, DescriptionFactory.UpdateType.GET_PORT);
HandlerResolver resolver = new HandlerResolverImpl(serviceDesc, serviceDelegateKey);
assertNotNull(resolver);
PortInfo pi = new DummyPortInfo();
List<Handler> list = resolver.getHandlerChain(pi);
assertEquals(2, list.size());
}
示例8: storeContent
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
/**
* Sends the specified content file to the WebService
*
* @param name The name of the content to be stored
* @param content The content to be stored
* @return The message that tthe server sent back
*/
public String storeContent(String name, DataHandler content) {
ContentStoreHttpPortService service = new ContentStoreHttpPortService();
service.setHandlerResolver(new HandlerResolver() {
@Override
public List<Handler> getHandlerChain(PortInfo portInfo) {
List<Handler> handlerList = new ArrayList<>();
handlerList.add(wsSecurityHandler);
return handlerList;
}
});
ContentStoreHttpPort contentStorePort = service.getContentStoreHttpPortSoap11();
SOAPBinding binding = (SOAPBinding) ((BindingProvider) contentStorePort).getBinding();
binding.setMTOMEnabled(true);
StoreContentRequest request = objectFactory.createStoreContentRequest();
request.setName(name);
request.setContent(content);
StoreContentResponse response = contentStorePort.storeContent(request);
return response.getMessage();
}
示例9: loadContent
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
/**
* Loads the content with the specified name from the WebService
*
* @param name The name of the content
* @return The loaded content
* @throws IOException If an IO error occurs
*/
public DataHandler loadContent(String name) throws IOException {
ContentStoreHttpPortService service = new ContentStoreHttpPortService();
service.setHandlerResolver(new HandlerResolver() {
@Override
public List<Handler> getHandlerChain(PortInfo portInfo) {
List<Handler> handlerList = new ArrayList<>();
handlerList.add(wsSecurityHandler);
return handlerList;
}
});
ContentStoreHttpPort loadContentPort = service.getContentStoreHttpPortSoap11();
SOAPBinding binding = (SOAPBinding) ((BindingProvider) loadContentPort).getBinding();
binding.setMTOMEnabled(true);
LoadContentRequest request = objectFactory.createLoadContentRequest();
request.setName(name);
LoadContentResponse response = loadContentPort.loadContent(request);
DataHandler content = response.getContent();
return content;
}
示例10: addWsSecurityAndHttpConfigWithClientCert
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
public static void addWsSecurityAndHttpConfigWithClientCert(Service ss, final String username,
final String password, final String p12, final String jks, final String passwordP12,
final String passwordJks){
String url = WsClientConfig.getDocboxServiceUrl();
final boolean clientcert = url.contains("ihe");
ss.setHandlerResolver(new HandlerResolver() {
@SuppressWarnings("rawtypes")
public List<Handler> getHandlerChain(PortInfo portInfo){
List<Handler> handlerList = new ArrayList<Handler>();
handlerList.add(new SecurityHandler(username, password, clientcert, p12, jks,
passwordP12, passwordJks));
return handlerList;
}
});
}
示例11: addVersionInformationToClient
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
/**
* This method adds a version SOAP Handler into the handler chain of a web
* service. The version SOAP Handler is responsible to add a version
* information in the header of the outbound SOAP message.
*
* @param service
* set HandlerResolver for service by invoking service
* <code>setHandlerResolver</code> method.
* @return service with handler chain for handling version information.
*/
public Service addVersionInformationToClient(Service service) {
service.setHandlerResolver(new HandlerResolver() {
@SuppressWarnings("rawtypes")
@Override
public List<Handler> getHandlerChain(PortInfo portInfo) {
List<Handler> handlerList = new ArrayList<Handler>();
handlerList.add(new VersionHandler(version));
return handlerList;
}
});
return service;
}
示例12: getHandlersForPortInfo
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
public HandlerAnnotationInfo getHandlersForPortInfo(PortInfo info){
HandlerAnnotationInfo handlerInfo = new HandlerAnnotationInfo();
List<Handler> handlerClassList = new ArrayList<Handler>();
Set<String> roles = new HashSet<String>();
for(HandlerChainType hchain : handlerChains) {
boolean hchainMatched = false;
if((!hchain.isConstraintSet()) ||
JAXWSUtils.matchQNames(info.getServiceName(), hchain.getServiceNamePattern()) ||
JAXWSUtils.matchQNames(info.getPortName(), hchain.getPortNamePattern()) ||
hchain.getProtocolBindings().contains(info.getBindingID()) ){
hchainMatched = true;
}
if(hchainMatched) {
for(HandlerType handler : hchain.getHandlers()) {
try {
Handler handlerClass = (Handler) loadClass(annotatedClass.getClassLoader(),
handler.getHandlerClass()).newInstance();
callHandlerPostConstruct(handlerClass);
handlerClassList.add(handlerClass);
} catch (InstantiationException ie){
throw new RuntimeException(ie);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
roles.addAll(handler.getSoapRoles());
}
}
}
handlerInfo.setHandlers(handlerClassList);
handlerInfo.setRoles(roles);
return handlerInfo;
}
示例13: equals
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
/**
* Object.equals is overridden here so that PortInfo objects
* can be compared when using them as keys in the map in
* HandlerResolverImpl. This method relies on the equals()
* methods of java.lang.String and javax.xml.namespace.QName.
*
* @param obj The PortInfo object to test for equality.
* @return True if they match, and false if they do not or
* if the object passed in is not a PortInfo.
*/
public boolean equals(Object obj) {
if (obj instanceof PortInfo) {
PortInfo info = (PortInfo) obj;
if (bindingId.toString().equals(info.getBindingID()) &&
portName.equals(info.getPortName()) &&
serviceName.equals(info.getServiceName())) {
return true;
}
}
return false;
}
示例14: getResolver
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
HandlerResolver getResolver() {
return new HandlerResolver() {
public List<Handler> getHandlerChain(PortInfo portInfo) {
return new ArrayList<Handler>(
handlerModel.getHandlersForPortInfo(portInfo).getHandlers());
}
};
}
示例15: createHandlerResolver
import javax.xml.ws.handler.PortInfo; //导入依赖的package包/类
protected HandlerResolver createHandlerResolver(XRoadClientConfig config, RovaServiceDetails details) {
headerHandler = new HeaderHandler(config, details);
return new HandlerResolver() {
@Override
public List<Handler> getHandlerChain(PortInfo portInfo) {
List<Handler> handlers = new ArrayList<>();
handlers.add(headerHandler);
return handlers;
}
};
}