Search in sources :

Example 11 with Description

use of org.geotoolkit.wps.xml.v200.Description in project axis-axis2-java-core by apache.

the class AxisService method printWSDL2.

/**
 * Prints WSDL2.0 data for the service with the given host IP address.
 * @param out The output stream for the data to be written for. NOTE: the stream is not closed after the operation,
 *            it is the responsibility of the caller to close the stream after usage.
 * @param requestIP The host IP address.
 * @throws AxisFault
 */
public void printWSDL2(OutputStream out, String requestIP) throws AxisFault {
    // If we're looking for pre-existing WSDL, use that.
    if (isUseUserWSDL()) {
        printUserWSDL2(out, null, requestIP);
        return;
    }
    AxisService2WSDL20 axisService2WSDL2 = new AxisService2WSDL20(this);
    // If we find a WSDLSupplier with WSDL 2.0 content, use that
    WSDLSupplier supplier = getUserDefinedWSDLSupplier("wsdl2");
    if (supplier == null) {
        supplier = (WSDLSupplier) getParameterValue(Constants.WSDL_SUPPLIER_PARAM);
        if (supplier instanceof WSDL20SupplierTemplate) {
            ((WSDL20SupplierTemplate) supplier).init(this);
        }
    }
    if (supplier != null) {
        Object wsdlContent = supplier.getWSDL(this);
        if (wsdlContent instanceof Description) {
            try {
                Description definition = (Description) wsdlContent;
                if (definition != null) {
                    // TODO  -- Need to implement this method for WSDL 2.0
                    // changeImportAndIncludeLocations(definition);
                    printDescriptionObject(definition, out, requestIP);
                }
            } catch (Exception e) {
                printWSDLError(out, e);
            }
        // wsdlContent can be a OMElement
        } else if (wsdlContent instanceof OMElement) {
            OMElement wsdlElement = (OMElement) wsdlContent;
            QName wsdlName = wsdlElement.getQName();
            if (wsdlName != null && wsdlName.getLocalPart().equals("description") && wsdlName.getNamespaceURI().equals("http://www.w3.org/ns/wsdl")) {
                // here ?
                try {
                    XMLPrettyPrinter.prettify(wsdlElement, out);
                    out.flush();
                } catch (Exception e) {
                    throw AxisFault.makeFault(e);
                }
            }
        }
        return;
    }
    try {
        if (requestIP != null) {
            axisService2WSDL2.setEPRs(calculateEPRs(requestIP));
        }
        OMElement wsdlElement = axisService2WSDL2.generateOM();
        wsdlElement.serialize(out);
        out.flush();
    } catch (Exception e) {
        throw AxisFault.makeFault(e);
    }
}
Also used : WSDL20SupplierTemplate(org.apache.axis2.dataretrieval.WSDL20SupplierTemplate) Description(org.apache.woden.wsdl20.Description) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) WSDLSupplier(org.apache.axis2.dataretrieval.WSDLSupplier) SocketException(java.net.SocketException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) DataRetrievalException(org.apache.axis2.dataretrieval.DataRetrievalException) SAXException(org.xml.sax.SAXException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WSDLException(javax.wsdl.WSDLException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 12 with Description

use of org.geotoolkit.wps.xml.v200.Description in project axis-axis2-java-core by apache.

the class AxisService method printUserWSDL2.

public void printUserWSDL2(OutputStream out, String wsdlName, String ip) throws AxisFault {
    Description description = null;
    // first find the correct wsdl definition
    Parameter wsdlParameter = getParameter(WSDLConstants.WSDL_20_DESCRIPTION);
    if (wsdlParameter != null) {
        description = (Description) wsdlParameter.getValue();
        try {
            org.apache.woden.WSDLFactory factory = org.apache.woden.WSDLFactory.newInstance();
            org.apache.woden.WSDLWriter writer = factory.newWSDLWriter();
            writer.writeWSDL(description.toElement(), out);
        } catch (org.apache.woden.WSDLException e) {
            throw AxisFault.makeFault(e);
        }
    }
}
Also used : Description(org.apache.woden.wsdl20.Description)

Example 13 with Description

use of org.geotoolkit.wps.xml.v200.Description in project geotoolkit by Geomatys.

the class WebProcessingClient method getDescribeProcess.

/**
 * Perform a DescribeProcess request on the specified identifiers.
 *
 * @param processIDs List of process Identifiers
 * @return ProcessDescriptions : WPS process description
 */
public ProcessOfferings getDescribeProcess(final List<String> processIDs) throws Exception {
    ProcessOfferings description;
    // Thread to prevent infinite request on a server
    final DescribeProcessRequest describe = createDescribeProcess();
    describe.setTimeout(getTimeOutValue());
    describe.getContent().setIdentifier(processIDs);
    try (final InputStream request = describe.getResponseStream()) {
        final Unmarshaller unmarshaller = WPSMarshallerPool.getInstance().acquireUnmarshaller();
        Object response = unmarshaller.unmarshal(request);
        WPSMarshallerPool.getInstance().recycle(unmarshaller);
        if (response instanceof ProcessOfferings) {
            description = (ProcessOfferings) response;
        } else if (response instanceof ExceptionResponse) {
            ExceptionResponse report = (ExceptionResponse) response;
            throw report.toException();
        } else {
            throw new Exception("Unexpected response type from the WPS server: " + (response == null ? "null" : response.getClass()));
        }
    }
    return description;
}
Also used : ExceptionResponse(org.geotoolkit.ows.xml.ExceptionResponse) ProcessOfferings(org.geotoolkit.wps.xml.v200.ProcessOfferings) Unmarshaller(javax.xml.bind.Unmarshaller) CapabilitiesException(org.geotoolkit.client.CapabilitiesException)

Aggregations

Description (org.apache.woden.wsdl20.Description)10 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 WSDLException (org.apache.woden.WSDLException)5 File (java.io.File)4 URISyntaxException (java.net.URISyntaxException)3 Map (java.util.Map)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 SAXException (org.xml.sax.SAXException)3 FileOutputStream (java.io.FileOutputStream)2 WSDLException (javax.wsdl.WSDLException)2 AxisFault (org.apache.axis2.AxisFault)2 WSDLReader (org.apache.woden.WSDLReader)2 WSDLSource (org.apache.woden.WSDLSource)2 WSDLWriter (org.apache.woden.WSDLWriter)2 ProcessOfferings (org.geotoolkit.wps.xml.v200.ProcessOfferings)2 Document (org.w3c.dom.Document)2 APIMgtWSDLException (org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException)2 APIMgtWSDLException (org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException)2 InputStream (java.io.InputStream)1