Search in sources :

Example 51 with WSDLException

use of javax.wsdl.WSDLException in project cxf by apache.

the class ServiceWSDLBuilder method getSchemaImplementation.

private Schema getSchemaImplementation(Definition def) {
    ExtensionRegistry reg = def.getExtensionRegistry();
    ExtensibilityElement extension;
    try {
        extension = reg.createExtension(javax.wsdl.Types.class, WSDLConstants.QNAME_SCHEMA);
    } catch (WSDLException e) {
        throw new RuntimeException("Problem creating schema implementation", e);
    }
    // try to cast the resulting extension:
    try {
        return Schema.class.cast(extension);
    } catch (ClassCastException e) {
        throw new RuntimeException("Schema implementation problem", e);
    }
}
Also used : Types(javax.wsdl.Types) WSDLException(javax.wsdl.WSDLException) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry)

Example 52 with WSDLException

use of javax.wsdl.WSDLException in project cxf by apache.

the class OASISCatalogTest method testWSDLLocatorWithoutCatalog.

@Test
public void testWSDLLocatorWithoutCatalog() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/catalog/hello_world_services.wsdl");
    assertNotNull(wsdl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    OASISCatalogManager catalog = new OASISCatalogManager();
    CatalogWSDLLocator wsdlLocator = new CatalogWSDLLocator(wsdl.toString(), catalog);
    try {
        wsdlReader.readWSDL(wsdlLocator);
        fail("Test did not fail as expected");
    } catch (WSDLException e) {
    // ignore
    }
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLException(javax.wsdl.WSDLException) OASISCatalogManager(org.apache.cxf.catalog.OASISCatalogManager) CatalogWSDLLocator(org.apache.cxf.wsdl11.CatalogWSDLLocator) URL(java.net.URL) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Example 53 with WSDLException

use of javax.wsdl.WSDLException in project cxf by apache.

the class WSDLToCorbaBinding method generateCORBAServiceForBinding.

private void generateCORBAServiceForBinding(Definition definition, PortType portType, Binding binding) throws Exception {
    if (extReg == null) {
        extReg = def.getExtensionRegistry();
    }
    String interfaceName = portType.getQName().getLocalPart();
    interfaceName = mangleInterfaceName(interfaceName);
    String serviceName = interfaceName + "CORBAService";
    String portName = interfaceName + "CORBAPort";
    String prefix = definition.getPrefix(definition.getTargetNamespace());
    if (prefix == null) {
        prefix = "";
    }
    String corbaPrefix = definition.getPrefix(CorbaConstants.NU_WSDL_CORBA);
    if (corbaPrefix == null) {
        corbaPrefix = "corba";
        def.addNamespace(corbaPrefix, CorbaConstants.NU_WSDL_CORBA);
    }
    // Build the service and port information and add it to the wsdl
    Service service = def.createService();
    Port servicePort = def.createPort();
    servicePort.setName(portName);
    servicePort.setBinding(binding);
    try {
        AddressType addressType = (AddressType) def.getExtensionRegistry().createExtension(Port.class, CorbaConstants.NE_CORBA_ADDRESS);
        String addr;
        if (getAddressFile() != null) {
            File addrFile = new File(getAddressFile());
            try {
                FileReader fileReader = new FileReader(addrFile);
                try (BufferedReader bufferedReader = new BufferedReader(fileReader)) {
                    addr = bufferedReader.readLine();
                }
            } catch (Exception ex) {
                throw new ToolException(ex.getMessage(), ex);
            }
        } else {
            addr = getAddress();
        }
        if (addr == null) {
            addr = "file:./" + interfaceName + ".ref";
        }
        addressType.setLocation(addr);
        servicePort.addExtensibilityElement((ExtensibilityElement) addressType);
    } catch (WSDLException ex) {
        throw new Exception("Failed to create CORBA address for service", ex);
    }
    QName serviceQName = new QName(definition.getTargetNamespace(), serviceName, prefix);
    service.setQName(serviceQName);
    service.addPort(servicePort);
    definition.addService(service);
}
Also used : WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) BufferedReader(java.io.BufferedReader) Service(javax.wsdl.Service) FileReader(java.io.FileReader) ToolException(org.apache.cxf.tools.common.ToolException) AddressType(org.apache.cxf.binding.corba.wsdl.AddressType) File(java.io.File) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException)

Example 54 with WSDLException

use of javax.wsdl.WSDLException in project cxf by apache.

the class WSDLToCorbaBinding method addCorbaOperationExtElement.

private void addCorbaOperationExtElement(BindingOperation bo, Operation op) throws Exception {
    final OperationType operationType;
    try {
        operationType = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException wse) {
        LOG.log(Level.SEVERE, "Failed to create a Binding Operation extension", wse);
        throw new Exception(LOG.toString(), wse);
    }
    operationType.setName(op.getName());
    List<ParamType> params = new ArrayList<>();
    List<ArgType> returns = new ArrayList<>();
    wsdlParameter.processParameters(this, op, def, xmlSchemaList, params, returns, true);
    for (ParamType paramtype : params) {
        operationType.getParam().add(paramtype);
    }
    for (ArgType retType : returns) {
        operationType.setReturn(retType);
    }
    Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
    for (Fault fault : faults) {
        RaisesType raisestype = new RaisesType();
        CorbaType extype = convertFaultToCorbaType(xmlSchemaType, fault);
        if (extype != null) {
            raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));
            operationType.getRaises().add(raisestype);
        }
    }
    bo.addExtensibilityElement((ExtensibilityElement) operationType);
}
Also used : ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) RaisesType(org.apache.cxf.binding.corba.wsdl.RaisesType) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) WSDLException(javax.wsdl.WSDLException) ArrayList(java.util.ArrayList) Fault(javax.wsdl.Fault) BindingFault(javax.wsdl.BindingFault) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 55 with WSDLException

use of javax.wsdl.WSDLException in project cxf by apache.

the class WSDLToProcessor method parseWSDL.

public void parseWSDL(String wsdlUrl) {
    try {
        Bus bus = BusFactory.getThreadDefaultBus();
        WSDLManager mgr = bus.getExtension(WSDLManager.class);
        wsdlDefinition = mgr.getDefinition(wsdlUrl);
        WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
        builder.buildMockServices(wsdlDefinition);
        schemas = mgr.getSchemasForDefinition(wsdlDefinition);
        // remove this as we're going to be modifying it
        mgr.removeDefinition(wsdlDefinition);
    } catch (WSDLException we) {
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("FAIL_TO_CREATE_WSDL_DEFINITION", LOG);
        throw new ToolException(msg, we);
    }
}
Also used : Bus(org.apache.cxf.Bus) WSDLException(javax.wsdl.WSDLException) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) WSDLManager(org.apache.cxf.wsdl.WSDLManager) ToolException(org.apache.cxf.tools.common.ToolException)

Aggregations

WSDLException (javax.wsdl.WSDLException)56 ToolException (org.apache.cxf.tools.common.ToolException)18 WSDLReader (javax.wsdl.xml.WSDLReader)14 IOException (java.io.IOException)13 Definition (javax.wsdl.Definition)12 Message (org.apache.cxf.common.i18n.Message)12 QName (javax.xml.namespace.QName)11 WSDLWriter (javax.wsdl.xml.WSDLWriter)10 APIMgtWSDLException (org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException)7 File (java.io.File)6 Writer (java.io.Writer)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)6 Document (org.w3c.dom.Document)6 URL (java.net.URL)5 WSDLManager (org.apache.cxf.wsdl.WSDLManager)5 XMLStreamException (javax.xml.stream.XMLStreamException)4 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3