Search in sources :

Example 1 with WebServiceFeatureList

use of com.sun.xml.ws.binding.WebServiceFeatureList in project metro-jax-ws by eclipse-ee4j.

the class WSServiceDelegate method getPort.

@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);
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) WSDLService(com.sun.xml.ws.api.model.wsdl.WSDLService) WebServiceFeatureList(com.sun.xml.ws.binding.WebServiceFeatureList) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort)

Example 2 with WebServiceFeatureList

use of com.sun.xml.ws.binding.WebServiceFeatureList in project metro-jax-ws by eclipse-ee4j.

the class WSServiceDelegate method getPort.

public <T> T getPort(WSEndpointReference wsepr, Class<T> portInterface, WebServiceFeature... features) {
    // get the portType from SEI, so that it can be used if EPR does n't have endpointName
    WebServiceFeatureList featureList = new WebServiceFeatureList(features);
    QName portTypeName = RuntimeModeler.getPortTypeName(portInterface, getMetadadaReader(featureList, portInterface.getClassLoader()));
    // if port name is not specified in EPR, it will use portTypeName to get it from the WSDL model.
    QName portName = getPortNameFromEPR(wsepr, portTypeName);
    return getPort(wsepr, portName, portInterface, featureList);
}
Also used : QName(javax.xml.namespace.QName) WebServiceFeatureList(com.sun.xml.ws.binding.WebServiceFeatureList)

Example 3 with WebServiceFeatureList

use of com.sun.xml.ws.binding.WebServiceFeatureList in project metro-jax-ws by eclipse-ee4j.

the class SEIPortInfoTest method createSEIPortInfo.

private SEIPortInfo createSEIPortInfo() throws MalformedURLException {
    WSServiceDelegate delegate = (WSServiceDelegate) WSService.create(WSDL_URL, SERVICE_NAME);
    WSDLPort wsdlPort = delegate.getPortModel(delegate.getWsdlService(), PORT_NAME);
    SEIModel model = delegate.buildRuntimeModel(delegate.getServiceName(), PORT_NAME, PORT_INTERFACE, wsdlPort, new WebServiceFeatureList());
    return new SEIPortInfo(delegate, PORT_INTERFACE, (SOAPSEIModel) model, wsdlPort);
}
Also used : SOAPSEIModel(com.sun.xml.ws.model.SOAPSEIModel) SEIModel(com.sun.xml.ws.api.model.SEIModel) WebServiceFeatureList(com.sun.xml.ws.binding.WebServiceFeatureList) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort)

Example 4 with WebServiceFeatureList

use of com.sun.xml.ws.binding.WebServiceFeatureList in project metro-jax-ws by eclipse-ee4j.

the class SDODatabindingTestBase method createProxy.

public static <T> T createProxy(Class<T> proxySEI, Class<?> endpointClass, String db, boolean debug) throws Exception {
    DatabindingConfig srvConfig = new DatabindingConfig();
    srvConfig.setEndpointClass(endpointClass);
    DatabindingModeFeature dbf = new DatabindingModeFeature(db);
    WebServiceFeatureList wsfeatures = new WebServiceFeatureList(endpointClass);
    WebServiceFeature[] f = { dbf };
    // config.setFeatures(wsfeatures.toArray());
    srvConfig.setFeatures(f);
    DatabindingConfig cliConfig = new DatabindingConfig();
    cliConfig.setContractClass(proxySEI);
    cliConfig.setFeatures(f);
    return createProxy(proxySEI, srvConfig, cliConfig, debug);
}
Also used : DatabindingConfig(com.sun.xml.ws.api.databinding.DatabindingConfig) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) WebServiceFeatureList(com.sun.xml.ws.binding.WebServiceFeatureList)

Example 5 with WebServiceFeatureList

use of com.sun.xml.ws.binding.WebServiceFeatureList in project metro-jax-ws by eclipse-ee4j.

the class EndpointFactory method create.

public <T> WSEndpoint<T> create(Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker, @Nullable QName serviceName, @Nullable QName portName, @Nullable Container container, @Nullable WSBinding binding, @Nullable SDDocumentSource primaryWsdl, @Nullable Collection<? extends SDDocumentSource> metadata, EntityResolver resolver, boolean isTransportSynchronous, boolean isStandard) {
    if (implType == null)
        throw new IllegalArgumentException();
    MetadataReader metadataReader = getExternalMetadatReader(implType, binding);
    if (isStandard) {
        verifyImplementorClass(implType, metadataReader);
    }
    if (invoker == null) {
        invoker = InstanceResolver.createDefault(implType).createInvoker();
    }
    // Performance analysis indicates that reading and parsing imported schemas is
    // a major component of Endpoint creation time.  Therefore, modify SDDocumentSource
    // handling to delay iterating collection as long as possible.
    Collection<SDDocumentSource> md = new CollectionCollection<>();
    if (primaryWsdl != null) {
        if (metadata != null) {
            Iterator<? extends SDDocumentSource> it = metadata.iterator();
            if (it.hasNext() && primaryWsdl.equals(it.next()))
                md.addAll(metadata);
            else {
                md.add(primaryWsdl);
                md.addAll(metadata);
            }
        } else
            md.add(primaryWsdl);
    } else if (metadata != null)
        md.addAll(metadata);
    if (container == null)
        container = ContainerResolver.getInstance().getContainer();
    if (serviceName == null)
        serviceName = getDefaultServiceName(implType, metadataReader);
    if (portName == null)
        portName = getDefaultPortName(serviceName, implType, metadataReader);
    {
        // error check
        String serviceNS = serviceName.getNamespaceURI();
        String portNS = portName.getNamespaceURI();
        if (!serviceNS.equals(portNS)) {
            throw new ServerRtException("wrong.tns.for.port", portNS, serviceNS);
        }
    }
    // setting a default binding
    if (binding == null)
        binding = BindingImpl.create(BindingID.parse(implType));
    if (isStandard && primaryWsdl != null) {
        verifyPrimaryWSDL(primaryWsdl, serviceName);
    }
    QName portTypeName = null;
    if (isStandard && implType.getAnnotation(WebServiceProvider.class) == null) {
        portTypeName = RuntimeModeler.getPortTypeName(implType, metadataReader);
    }
    // Categorises the documents as WSDL, Schema etc
    Collection<SDDocumentImpl> docList = categoriseMetadata(md.iterator(), serviceName, portTypeName);
    // Finds the primary WSDL and makes sure that metadata doesn't have
    // two concrete or abstract WSDLs
    SDDocumentImpl primaryDoc = primaryWsdl != null ? SDDocumentImpl.create(primaryWsdl, serviceName, portTypeName) : findPrimary(docList);
    EndpointAwareTube terminal;
    WSDLPort wsdlPort = null;
    AbstractSEIModelImpl seiModel = null;
    // create WSDL model
    if (primaryDoc != null) {
        wsdlPort = getWSDLPort(primaryDoc, docList, serviceName, portName, container, resolver);
    }
    WebServiceFeatureList features = ((BindingImpl) binding).getFeatures();
    if (isStandard) {
        features.parseAnnotations(implType);
    }
    PolicyMap policyMap = null;
    // create terminal pipe that invokes the application
    if (isUseProviderTube(implType, isStandard)) {
        // TODO incase of Provider, provide a way to User for complete control of the message processing by giving
        // ability to turn off the WSDL/Policy based features and its associated tubes.
        // Even in case of Provider, merge all features configured via WSDL/Policy or deployment configuration
        Iterable<WebServiceFeature> configFtrs;
        if (wsdlPort != null) {
            policyMap = wsdlPort.getOwner().getParent().getPolicyMap();
            // Merge features from WSDL and other policy configuration
            configFtrs = wsdlPort.getFeatures();
        } else {
            // No WSDL, so try to merge features from Policy configuration
            policyMap = PolicyResolverFactory.create().resolve(new PolicyResolver.ServerContext(null, container, implType, false));
            configFtrs = PolicyUtil.getPortScopedFeatures(policyMap, serviceName, portName);
        }
        features.mergeFeatures(configFtrs, true);
        terminal = createProviderInvokerTube(implType, binding, invoker, container);
    } else {
        // Create runtime model for non Provider endpoints
        seiModel = createSEIModel(wsdlPort, implType, serviceName, portName, binding, primaryDoc);
        if (binding instanceof SOAPBindingImpl) {
            // set portKnownHeaders on Binding, so that they can be used for MU processing
            ((SOAPBindingImpl) binding).setPortKnownHeaders(((SOAPSEIModel) seiModel).getKnownHeaders());
        }
        // Generate WSDL for SEI endpoints(not for Provider endpoints)
        if (primaryDoc == null) {
            primaryDoc = generateWSDL(binding, seiModel, docList, container, implType);
            // create WSDL model
            wsdlPort = getWSDLPort(primaryDoc, docList, serviceName, portName, container, resolver);
            seiModel.freeze(wsdlPort);
        }
        policyMap = wsdlPort.getOwner().getParent().getPolicyMap();
        // New Features might have been added in WSDL through Policy.
        // Merge features from WSDL and other policy configuration
        // This sets only the wsdl features that are not already set(enabled/disabled)
        features.mergeFeatures(wsdlPort.getFeatures(), true);
        terminal = createSEIInvokerTube(seiModel, invoker, binding);
    }
    // Process @HandlerChain, if handler-chain is not set via Deployment Descriptor
    if (processHandlerAnnotation) {
        processHandlerAnnotation(binding, implType, serviceName, portName);
    }
    // Selects only required metadata for this endpoint from the passed-in metadata
    if (primaryDoc != null) {
        docList = findMetadataClosure(primaryDoc, docList, resolver);
    }
    ServiceDefinitionImpl serviceDefiniton = (primaryDoc != null) ? new ServiceDefinitionImpl(docList, primaryDoc) : null;
    return create(serviceName, portName, binding, container, seiModel, wsdlPort, implType, serviceDefiniton, terminal, isTransportSynchronous, policyMap);
}
Also used : BindingImpl(com.sun.xml.ws.binding.BindingImpl) SOAPBindingImpl(com.sun.xml.ws.binding.SOAPBindingImpl) AbstractSEIModelImpl(com.sun.xml.ws.model.AbstractSEIModelImpl) QName(javax.xml.namespace.QName) MetadataReader(com.sun.xml.ws.api.databinding.MetadataReader) WebServiceFeatureList(com.sun.xml.ws.binding.WebServiceFeatureList) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort) SDDocumentSource(com.sun.xml.ws.api.server.SDDocumentSource) PolicyMap(com.sun.xml.ws.policy.PolicyMap) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) SOAPBindingImpl(com.sun.xml.ws.binding.SOAPBindingImpl)

Aggregations

WebServiceFeatureList (com.sun.xml.ws.binding.WebServiceFeatureList)12 DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)4 DatabindingConfig (com.sun.xml.ws.api.databinding.DatabindingConfig)4 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)4 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)4 QName (javax.xml.namespace.QName)3 BindingID (com.sun.xml.ws.api.BindingID)2 WSDLService (com.sun.xml.ws.api.model.wsdl.WSDLService)2 BindingImpl (com.sun.xml.ws.binding.BindingImpl)2 SOAPBindingImpl (com.sun.xml.ws.binding.SOAPBindingImpl)2 AbstractSEIModelImpl (com.sun.xml.ws.model.AbstractSEIModelImpl)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 WSDLResolver (com.oracle.webservices.api.databinding.WSDLResolver)1 WebServiceAp (com.sun.tools.ws.processor.modeler.annotation.WebServiceAp)1 DatabindingFactory (com.sun.xml.ws.api.databinding.DatabindingFactory)1 MetadataReader (com.sun.xml.ws.api.databinding.MetadataReader)1 WSDLGenInfo (com.sun.xml.ws.api.databinding.WSDLGenInfo)1 SEIModel (com.sun.xml.ws.api.model.SEIModel)1 SDDocumentSource (com.sun.xml.ws.api.server.SDDocumentSource)1 WSDLGeneratorExtension (com.sun.xml.ws.api.wsdl.writer.WSDLGeneratorExtension)1