Java Code Examples for javax.xml.ws.WebServiceFeature

The following examples show how to use javax.xml.ws.WebServiceFeature. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * 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 2
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 3
Source Project: hottub   Source File: WSServiceDelegate.java    License: 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
@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 5
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 6
Source Project: hottub   Source File: BindingImpl.java    License: 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 7
Source Project: TencentKona-8   Source File: BindingImpl.java    License: 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 8
/**
 * 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 9
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 10
/**
 * 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 11
Source Project: hottub   Source File: WebServiceFeatureList.java    License: 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 12
Source Project: TencentKona-8   Source File: BindingImpl.java    License: 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 13
Source Project: cxf   Source File: ServiceImpl.java    License: 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 14
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 15
Source Project: TencentKona-8   Source File: PolicyUtil.java    License: 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 16
Source Project: hottub   Source File: WSEndpointReference.java    License: 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 17
Source Project: fido2   Source File: Soap.java    License: GNU Lesser General Public License v2.1 4 votes vote down vote up
public Soap(URL wsdlLocation, WebServiceFeature... features) {
    super(wsdlLocation, SOAP_QNAME, features);
}
 
Example 18
HTTPBindingImpl(WebServiceFeature ... features) {
    super(BindingID.XML_HTTP, features);
}
 
Example 19
Source Project: fido2   Source File: Soap.java    License: GNU Lesser General Public License v2.1 4 votes vote down vote up
public Soap(WebServiceFeature... features) {
    super(__getWsdlLocation(), SOAP_QNAME, features);
}
 
Example 20
public void setFeatures(WebServiceFeature[] features) {
        setFeatures(new WebServiceFeatureList(features));
}
 
Example 21
Source Project: onvif   Source File: PACSService.java    License: Apache License 2.0 4 votes vote down vote up
public PACSService(WebServiceFeature ... features) {
    super(WSDL_LOCATION, SERVICE, features);
}
 
Example 22
Source Project: tutorials   Source File: EmployeeService_Service.java    License: MIT License 4 votes vote down vote up
public EmployeeService_Service(URL wsdlLocation, WebServiceFeature... features) {
    super(wsdlLocation, EMPLOYEESERVICE_QNAME, features);
}
 
Example 23
Source Project: hottub   Source File: WSDLFeaturedObject.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Nullable
<F extends WebServiceFeature> F getFeature(@NotNull Class<F> featureType);
 
Example 24
Source Project: onvif   Source File: PtzService.java    License: Apache License 2.0 4 votes vote down vote up
public PtzService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
    super(wsdlLocation, serviceName, features);
}
 
Example 25
public void setFeatures(WebServiceFeature[] features) {
        setFeatures(new WebServiceFeatureList(features));
}
 
Example 26
@WebEndpoint(
   name = "RecipeExecutorServiceSOAP11"
)
public RecipeExecutorPortType getRecipeExecutorServiceSOAP11(WebServiceFeature... features) {
   return (RecipeExecutorPortType)super.getPort(RecipeExecutorServiceSOAP11, RecipeExecutorPortType.class, features);
}
 
Example 27
public Builder feature(WebServiceFeature... f) {
    config.setFeatures(f);
    return this;
}
 
Example 28
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;
}
 
Example 29
Source Project: onvif   Source File: ReplayService.java    License: Apache License 2.0 4 votes vote down vote up
public ReplayService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
    super(wsdlLocation, serviceName, features);
}
 
Example 30
protected com.oracle.webservices.internal.api.message.MessageContextFactory newFactory(WebServiceFeature... f) {
    return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
}