javax.xml.ws.WebServiceFeature Java Examples

The following examples show how to use javax.xml.ws.WebServiceFeature. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProviderImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public <T> T getPort(EndpointReference endpointReference, Class<T> clazz, WebServiceFeature... webServiceFeatures) {
    /*
    final @NotNull MemberSubmissionEndpointReference msepr =
            EndpointReferenceUtil.transform(MemberSubmissionEndpointReference.class, endpointReference);
            WSService service = new WSServiceDelegate(msepr.toWSDLSource(), msepr.serviceName.name, Service.class);
            */
    if(endpointReference == null)
        throw new WebServiceException(ProviderApiMessages.NULL_EPR());
    WSEndpointReference wsepr =  new WSEndpointReference(endpointReference);
    WSEndpointReference.Metadata metadata = wsepr.getMetaData();
    WSService service;
    if(metadata.getWsdlSource() != null)
        service = (WSService) createServiceDelegate(metadata.getWsdlSource(), metadata.getServiceName(), Service.class);
    else
        throw new WebServiceException("WSDL metadata is missing in EPR");
    return service.getPort(wsepr, clazz, webServiceFeatures);
}
 
Example #2
Source File: WSServiceDelegate.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> T getPort(Class<T> portInterface, WebServiceFeature... features) {
    //get the portType from SEI
    QName portTypeName = RuntimeModeler.getPortTypeName(portInterface, getMetadadaReader(new WebServiceFeatureList(features), portInterface.getClassLoader()));
    WSDLService tmpWsdlService = this.wsdlService;
    if (tmpWsdlService == null) {
        // assigning it to local variable and not setting it back to this.wsdlService intentionally
        // as we don't want to include the service instance with information gathered from sei
        tmpWsdlService = getWSDLModelfromSEI(portInterface);
        //still null? throw error need wsdl metadata to create a proxy
        if(tmpWsdlService == null) {
            throw new WebServiceException(ProviderApiMessages.NO_WSDL_NO_PORT(portInterface.getName()));
        }
    }
    //get the first port corresponding to the SEI
    WSDLPort port = tmpWsdlService.getMatchingPort(portTypeName);
    if (port == null) {
        throw new WebServiceException(ClientMessages.UNDEFINED_PORT_TYPE(portTypeName));
    }
    QName portName = port.getName();
    return getPort(portName, portInterface,features);
}
 
Example #3
Source File: WSServiceDelegate.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public <T> T getPort(Class<T> portInterface, WebServiceFeature... features) {
    //get the portType from SEI
    QName portTypeName = RuntimeModeler.getPortTypeName(portInterface, getMetadadaReader(new WebServiceFeatureList(features), portInterface.getClassLoader()));
    WSDLService tmpWsdlService = this.wsdlService;
    if (tmpWsdlService == null) {
        // assigning it to local variable and not setting it back to this.wsdlService intentionally
        // as we don't want to include the service instance with information gathered from sei
        tmpWsdlService = getWSDLModelfromSEI(portInterface);
        //still null? throw error need wsdl metadata to create a proxy
        if(tmpWsdlService == null) {
            throw new WebServiceException(ProviderApiMessages.NO_WSDL_NO_PORT(portInterface.getName()));
        }
    }
    //get the first port corresponding to the SEI
    WSDLPort port = tmpWsdlService.getMatchingPort(portTypeName);
    if (port == null) {
        throw new WebServiceException(ClientMessages.UNDEFINED_PORT_TYPE(portTypeName));
    }
    QName portName = port.getName();
    return getPort(portName, portInterface,features);
}
 
Example #4
Source File: SelectOptimalEncodingFeatureConfigurator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Process SelectOptimalEncoding policy assertions.
 *
 * @param key Key that identifies the endpoint scope.
 * @param policyMap The policy map.
 * @throws PolicyException If retrieving the policy triggered an exception.
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_ASSERTION)) {
            Iterator <AssertionSet> assertions = policy.iterator();
            while(assertions.hasNext()){
                AssertionSet assertionSet = assertions.next();
                Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                while(policyAssertion.hasNext()){
                    PolicyAssertion assertion = policyAssertion.next();
                    if(SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())){
                        String value = assertion.getAttributeValue(enabled);
                        boolean isSelectOptimalEncodingEnabled = value == null || Boolean.valueOf(value.trim());
                        features.add(new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled));
                    }
                }
            }
        }
    }
    return features;
}
 
Example #5
Source File: DatabindingFactoryImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
String databindingMode(DatabindingConfig config) {
        if ( config.getMappingInfo() != null &&
             config.getMappingInfo().getDatabindingMode() != null)
                return config.getMappingInfo().getDatabindingMode();
if ( config.getFeatures() != null) for (WebServiceFeature f : config.getFeatures()) {
    if (f instanceof DatabindingModeFeature) {
        DatabindingModeFeature dmf = (DatabindingModeFeature) f;
        config.properties().putAll(dmf.getProperties());
        return dmf.getMode();
    }
}
        return null;
}
 
Example #6
Source File: PolicyUtil.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Iterates through the ports in the WSDL model, for each policy in the policy
 * map that is attached at endpoint scope computes a list of corresponding
 * WebServiceFeatures and sets them on the port.
 *
 * @param model The WSDL model
 * @param policyMap The policy map
 * @throws PolicyException If the list of WebServiceFeatures could not be computed
 */
public static void configureModel(final WSDLModel model, PolicyMap policyMap) throws PolicyException {
    LOGGER.entering(model, policyMap);
    for (WSDLService service : model.getServices().values()) {
        for (WSDLPort port : service.getPorts()) {
            final Collection<WebServiceFeature> features = getPortScopedFeatures(policyMap, service.getName(), port.getName());
            for (WebServiceFeature feature : features) {
                port.addFeature(feature);
                port.getBinding().addFeature(feature);
            }
        }
    }
    LOGGER.exiting();
}
 
Example #7
Source File: WSEndpointReference.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Dispatch} that can be used to talk to this EPR.
 *
 * <p>
 * All the normal WS-Addressing processing happens automatically,
 * such as setting the endpoint address to {@link #getAddress() the address},
 * and sending the reference parameters associated with this EPR as
 * headers, etc.
 */
public @NotNull <T> Dispatch<T> createDispatch(
    @NotNull Service jaxwsService,
    @NotNull Class<T> type,
    @NotNull Service.Mode mode,
    WebServiceFeature... features) {

    // TODO: implement it in a better way
    return jaxwsService.createDispatch(toSpec(),type,mode,features);
}
 
Example #8
Source File: BindingImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void setInputMessageFeatures(@NotNull final QName operationName, WebServiceFeature... newFeatures) {
    if (newFeatures != null) {
        WebServiceFeatureList featureList = inputMessageFeatures.get(operationName);
        if (featureList == null) {
            featureList = new WebServiceFeatureList();
        }
        for (WebServiceFeature f : newFeatures) {
            featureList.add(f);
        }
        inputMessageFeatures.put(operationName, featureList);
    }
}
 
Example #9
Source File: BindingImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setFaultMessageFeatures(@NotNull final QName operationName, @NotNull final QName messageName, WebServiceFeature... newFeatures) {
    if (newFeatures != null) {
        final MessageKey key = new MessageKey(operationName, messageName);
        WebServiceFeatureList featureList = faultMessageFeatures.get(key);
        if (featureList == null) {
            featureList = new WebServiceFeatureList();
        }
        for (WebServiceFeature f : newFeatures) {
            featureList.add(f);
        }
        faultMessageFeatures.put(key, featureList);
    }
}
 
Example #10
Source File: WebServiceFeatureList.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean addNoValidate(@NotNull WebServiceFeature f) {
    if (!wsfeatures.containsKey(f.getClass())) {
        wsfeatures.put(f.getClass(), f);

        if (f instanceof ImpliesWebServiceFeature)
            ((ImpliesWebServiceFeature) f).implyFeatures(this);

        return true;
    }

    return false;
}
 
Example #11
Source File: ServiceImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public <T> T getPort(Class<T> serviceEndpointInterface, WebServiceFeature... features) {
    try {
        return createPort(null, null, serviceEndpointInterface, features);
    } catch (ServiceConstructionException e) {
        throw new WebServiceException(e);
    }
}
 
Example #12
Source File: WSEndpointReference.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Dispatch} that can be used to talk to this EPR.
 *
 * <p>
 * All the normal WS-Addressing processing happens automatically,
 * such as setting the endpoint address to {@link #getAddress() the address},
 * and sending the reference parameters associated with this EPR as
 * headers, etc.
 */
public @NotNull Dispatch<Object> createDispatch(
    @NotNull Service jaxwsService,
    @NotNull JAXBContext context,
    @NotNull Service.Mode mode,
    WebServiceFeature... features) {

    // TODO: implement it in a better way
    return jaxwsService.createDispatch(toSpec(),context,mode,features);
}
 
Example #13
Source File: BindingImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setInputMessageFeatures(@NotNull final QName operationName, WebServiceFeature... newFeatures) {
    if (newFeatures != null) {
        WebServiceFeatureList featureList = inputMessageFeatures.get(operationName);
        if (featureList == null) {
            featureList = new WebServiceFeatureList();
        }
        for (WebServiceFeature f : newFeatures) {
            featureList.add(f);
        }
        inputMessageFeatures.put(operationName, featureList);
    }
}
 
Example #14
Source File: WebServiceFeatureList.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public @Nullable
    <F extends WebServiceFeature> F get(@NotNull Class<F> featureType) {
    WebServiceFeature f = featureType.cast(wsfeatures.get(featureType));
    if (f == null && parent != null) {
        return parent.getFeatures().get(featureType);
    }
    return (F) f;
}
 
Example #15
Source File: WebServiceFeatureList.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds the corresponding features to the list for feature annotations(i.e
 * which have {@link WebServiceFeatureAnnotation} meta annotation)
 *
 * @param annIt collection of annotations(that can have non-feature annotations)
 */
public void parseAnnotations(Iterable<Annotation> annIt) {
    for(Annotation ann : annIt) {
        WebServiceFeature feature = getFeature(ann);
        if (feature != null) {
            add(feature);
        }
    }
}
 
Example #16
Source File: WebServiceFeatureList.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static public WebServiceFeature[] toFeatureArray(WSBinding binding) {
    //TODO scchen convert BindingID  to WebServiceFeature[]
    if(!binding.isFeatureEnabled(EnvelopeStyleFeature.class)) {
        WebServiceFeature[] f = { binding.getSOAPVersion().toFeature() };
        binding.getFeatures().mergeFeatures(f, false);
    }
    return binding.getFeatures().toArray();
}
 
Example #17
Source File: FeatureListUtil.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isFeatureEnabled(@NotNull Class<? extends WebServiceFeature> featureType,
        @Nullable WebServiceFeatureList list1, @Nullable WebServiceFeatureList list2)
        throws WebServiceException {
    final WebServiceFeature mergedFeature = mergeFeature(featureType, list1, list2);
    return (mergedFeature != null) && mergedFeature.isEnabled();
}
 
Example #18
Source File: MessageContextFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected com.oracle.webservices.internal.api.message.MessageContextFactory newFactory(WebServiceFeature... f) {
    return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
}
 
Example #19
Source File: ExecutorServices_Service.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
@WebEndpoint(
   name = "ExecutorServicesPort"
)
public ExecutorServices getExecutorServicesPort(WebServiceFeature... features) {
   return (ExecutorServices)super.getPort(ExecutorServicesPort, ExecutorServices.class, features);
}
 
Example #20
Source File: WebServiceFeatureList.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public WebServiceFeature next() {
    if (!features.empty()) {
        return features.pop();
    }
    throw new NoSuchElementException();
}
 
Example #21
Source File: WebServiceFeatureList.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static public boolean isFeatureEnabled(Class<? extends WebServiceFeature> type, WebServiceFeature[] features) {
    WebServiceFeature ftr = getFeature(features, type);
    return ftr != null && ftr.isEnabled();
}
 
Example #22
Source File: MessageContextFactory.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static public MessageContextFactory createFactory(WebServiceFeature ... f) {
    return createFactory(null, f);
}
 
Example #23
Source File: PrescriberServices_Service.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
@WebEndpoint(
   name = "PrescriberServicesPort"
)
public PrescriberServices getPrescriberServicesPort(WebServiceFeature... features) {
   return (PrescriberServices)super.getPort(PrescriberServicesPort, PrescriberServices.class, features);
}
 
Example #24
Source File: DatabindingConfig.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void setFeatures(Iterable<WebServiceFeature> features) {
        this.features = WebServiceFeatureList.toList(features);
}
 
Example #25
Source File: WSServiceDelegate.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Dispatch<Object> createDispatch(QName portName, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeature... webServiceFeatures) {
    return createDispatch(portName, jaxbContext, mode, new WebServiceFeatureList(webServiceFeatures));
}
 
Example #26
Source File: WSServiceDelegate.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public WSServiceDelegate(URL wsdlDocumentLocation, QName serviceName, Class<? extends Service> serviceClass, WebServiceFeature... features) {
    this(wsdlDocumentLocation, serviceName, serviceClass, new WebServiceFeatureList(features));
}
 
Example #27
Source File: ReplayService.java    From onvif with Apache License 2.0 4 votes vote down vote up
public ReplayService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
    super(wsdlLocation, serviceName, features);
}
 
Example #28
Source File: WebServiceFeatureList.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public WebServiceFeature put(Class<? extends WebServiceFeature> key, WebServiceFeature value) {
    return wsfeatures.put(key, value);
}
 
Example #29
Source File: HTTPBindingImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
HTTPBindingImpl(WebServiceFeature ... features) {
    super(BindingID.XML_HTTP, features);
}
 
Example #30
Source File: DeploymentDescriptorParser.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private List<A> parseAdapters(XMLStreamReader reader) {
    if (!reader.getName().equals(QNAME_ENDPOINTS)) {
        failWithFullName("runtime.parser.invalidElement", reader);
    }

    List<A> adapters = new ArrayList<A>();

    Attributes attrs = XMLStreamReaderUtil.getAttributes(reader);
    String version = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_VERSION);
    if (!ATTRVALUE_SUPPORTED_VERSIONS.contains(version)) {
        failWithLocalName("runtime.parser.invalidVersionNumber", reader, version);
    }

    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {

        if (reader.getName().equals(QNAME_ENDPOINT)) {
            attrs = XMLStreamReaderUtil.getAttributes(reader);

            String name = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_NAME);
            if (!names.add(name)) {
                logger.warning(
                        WsservletMessages.SERVLET_WARNING_DUPLICATE_ENDPOINT_NAME(/*name*/));
            }

            String implementationName =
                    getMandatoryNonEmptyAttribute(reader, attrs, ATTR_IMPLEMENTATION);
            Class<?> implementorClass = getImplementorClass(implementationName, reader);

            MetadataReader metadataReader = null;
            ExternalMetadataFeature externalMetadataFeature = null;

            // parse subelements to instantiate externalMetadataReader, if necessary ...
            XMLStreamReaderUtil.nextElementContent(reader);
            if (reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
                externalMetadataFeature = configureExternalMetadataReader(reader);
                if (externalMetadataFeature != null) {
                    metadataReader = externalMetadataFeature.getMetadataReader(implementorClass.getClassLoader(), false);
                }
            }

            QName serviceName = getQNameAttribute(attrs, ATTR_SERVICE);
            if (serviceName == null) {
                serviceName = EndpointFactory.getDefaultServiceName(implementorClass, metadataReader);
            }

            QName portName = getQNameAttribute(attrs, ATTR_PORT);
            if (portName == null) {
                portName = EndpointFactory.getDefaultPortName(serviceName, implementorClass, metadataReader);
            }

            //get enable-mtom attribute value
            String enable_mtom = getAttribute(attrs, ATTR_ENABLE_MTOM);
            String mtomThreshold = getAttribute(attrs, ATTR_MTOM_THRESHOLD_VALUE);
            String dbMode = getAttribute(attrs, ATTR_DATABINDING);
            String bindingId = getAttribute(attrs, ATTR_BINDING);
            if (bindingId != null) {
                // Convert short-form tokens to API's binding ids
                bindingId = getBindingIdForToken(bindingId);
            }
            WSBinding binding = createBinding(bindingId, implementorClass, enable_mtom, mtomThreshold, dbMode);
            if (externalMetadataFeature != null) {
                    binding.getFeatures().mergeFeatures(new WebServiceFeature[]{externalMetadataFeature},
                    true);
            }

            String urlPattern = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_URL_PATTERN);

            // TODO use 'docs' as the metadata. If wsdl is non-null it's the primary.
            boolean handlersSetInDD = setHandlersAndRoles(binding, reader, serviceName, portName);

            EndpointFactory.verifyImplementorClass(implementorClass, metadataReader);
            SDDocumentSource primaryWSDL = getPrimaryWSDL(reader, attrs, implementorClass, metadataReader);

            WSEndpoint<?> endpoint = WSEndpoint.create(
                    implementorClass, !handlersSetInDD,
                    null,
                    serviceName, portName, container, binding,
                    primaryWSDL, docs.values(), createEntityResolver(), false
            );
            adapters.add(adapterFactory.createAdapter(name, urlPattern, endpoint));
        } else {
            failWithLocalName("runtime.parser.invalidElement", reader);
        }
    }
    return adapters;
}