Search in sources :

Example 1 with JSR109WebServicePackager

use of org.eclipse.persistence.tools.dbws.JSR109WebServicePackager in project eclipselink by eclipse-ee4j.

the class SOAP12TestSuite method setUp.

@BeforeClass
public static void setUp() throws WSDLException {
    try {
        conn = buildConnection();
    } catch (Exception e) {
        e.printStackTrace();
    }
    String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    if (ddlCreate) {
        runDdl(conn, CREATE_SOAP12_TABLE, ddlDebug);
    }
    builder.setProjectName(SOAP12_TEST);
    builder.setTargetNamespace(SOAP12_NAMESPACE);
    TableOperationModel mtomOp = new TableOperationModel();
    mtomOp.additionalOperations = new ArrayList<OperationModel>();
    mtomOp.setName(SOAP12_TEST);
    mtomOp.setTablePattern(SOAP12);
    mtomOp.setBinaryAttachment(true);
    mtomOp.setAttachmentType("MTOM");
    builder.getOperations().add(mtomOp);
    builder.quiet = true;
    // builder.setLogLevel(SessionLog.FINE_LABEL);
    builder.setLogLevel(SessionLog.OFF_LABEL);
    builder.setDriver(DATABASE_DRIVER);
    builder.setPlatformClassname(DATABASE_PLATFORM);
    builder.getProperties().put(SESSIONS_FILENAME_KEY, NO_SESSIONS_FILENAME);
    builder.setUsername(username);
    builder.setPassword(password);
    builder.setUrl(url);
    builder.setPackager(new JSR109WebServicePackager(null, "WebServiceTestPackager", noArchive) {

        @Override
        public void start() {
        }
    });
    builder.build(DBWS_SCHEMA_STREAM, __nullStream, DBWS_SERVICE_STREAM, DBWS_OR_STREAM, DBWS_OX_STREAM, __nullStream, __nullStream, DBWS_WSDL_STREAM, __nullStream, __nullStream, __nullStream, __nullStream, null);
    SOAP12TestSuite soap12TestSuite = new SOAP12TestSuite();
    soap12TestSuite.mtomEnabled = true;
    endpoint = Endpoint.create(soap12TestSuite);
    endpoint.publish(ENDPOINT_ADDRESS);
    QName serviceQName = new QName(SOAP12_SERVICE_NAMESPACE, SOAP12_SERVICE);
    portQName = new QName(SOAP12_SERVICE_NAMESPACE, SOAP12_PORT);
    testService = Service.create(serviceQName);
    testService.addPort(portQName, SOAP12HTTP_BINDING, ENDPOINT_ADDRESS);
    dispatch = testService.createDispatch(portQName, SOAPMessage.class, MESSAGE, new MTOMFeature(100));
}
Also used : JSR109WebServicePackager(org.eclipse.persistence.tools.dbws.JSR109WebServicePackager) QName(javax.xml.namespace.QName) MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) TableOperationModel(org.eclipse.persistence.tools.dbws.TableOperationModel) SOAPMessage(jakarta.xml.soap.SOAPMessage) WSDLException(javax.wsdl.WSDLException) JAXBException(jakarta.xml.bind.JAXBException) OperationModel(org.eclipse.persistence.tools.dbws.OperationModel) TableOperationModel(org.eclipse.persistence.tools.dbws.TableOperationModel) BeforeClass(org.junit.BeforeClass)

Example 2 with JSR109WebServicePackager

use of org.eclipse.persistence.tools.dbws.JSR109WebServicePackager in project eclipselink by eclipse-ee4j.

the class UpdateFaultTestSuite method setUp.

@BeforeClass
public static void setUp() throws WSDLException {
    try {
        conn = buildConnection();
    } catch (Exception e) {
        e.printStackTrace();
    }
    String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    if (ddlCreate) {
        runDdl(conn, CREATE_SFAULT_TABLE, ddlDebug);
        try {
            Statement stmt = conn.createStatement();
            for (int i = 0; i < POPULATE_SFAULT_TABLE.length; i++) {
                stmt.addBatch(POPULATE_SFAULT_TABLE[i]);
            }
            stmt.executeBatch();
        } catch (SQLException e) {
            if (ddlDebug) {
                e.printStackTrace();
            }
        }
    }
    builder.setProjectName(SFAULT_TEST);
    builder.setTargetNamespace(SFAULT_NAMESPACE);
    TableOperationModel sFaultOp = new TableOperationModel();
    sFaultOp.additionalOperations = new ArrayList<OperationModel>();
    sFaultOp.setName(SFAULT_TEST);
    sFaultOp.setTablePattern(SFAULT);
    builder.getOperations().add(sFaultOp);
    builder.quiet = true;
    // builder.setLogLevel(SessionLog.FINE_LABEL);
    builder.setLogLevel(SessionLog.OFF_LABEL);
    builder.setDriver(DATABASE_DRIVER);
    builder.setPlatformClassname(DATABASE_PLATFORM);
    builder.getProperties().put(SESSIONS_FILENAME_KEY, NO_SESSIONS_FILENAME);
    builder.setUsername(username);
    builder.setPassword(password);
    builder.setUrl(url);
    builder.setPackager(new JSR109WebServicePackager(null, "WebServiceTestPackager", noArchive) {

        @Override
        public void start() {
        }
    });
    builder.build(DBWS_SCHEMA_STREAM, __nullStream, DBWS_SERVICE_STREAM, DBWS_OR_STREAM, DBWS_OX_STREAM, __nullStream, __nullStream, DBWS_WSDL_STREAM, __nullStream, __nullStream, __nullStream, __nullStream, null);
    endpoint = Endpoint.create(new UpdateFaultTestSuite());
    endpoint.publish(ENDPOINT_ADDRESS);
    QName serviceQName = new QName(SFAULT_SERVICE_NAMESPACE, SFAULT_SERVICE);
    portQName = new QName(SFAULT_SERVICE_NAMESPACE, SFAULT_PORT);
    testService = Service.create(serviceQName);
    testService.addPort(portQName, SOAP11HTTP_BINDING, ENDPOINT_ADDRESS);
}
Also used : JSR109WebServicePackager(org.eclipse.persistence.tools.dbws.JSR109WebServicePackager) SQLException(java.sql.SQLException) Statement(java.sql.Statement) QName(javax.xml.namespace.QName) TableOperationModel(org.eclipse.persistence.tools.dbws.TableOperationModel) SOAPException(jakarta.xml.soap.SOAPException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) TransformerException(javax.xml.transform.TransformerException) SQLException(java.sql.SQLException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) WSDLException(javax.wsdl.WSDLException) JAXBException(jakarta.xml.bind.JAXBException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Endpoint(jakarta.xml.ws.Endpoint) OperationModel(org.eclipse.persistence.tools.dbws.OperationModel) TableOperationModel(org.eclipse.persistence.tools.dbws.TableOperationModel) BeforeClass(org.junit.BeforeClass)

Example 3 with JSR109WebServicePackager

use of org.eclipse.persistence.tools.dbws.JSR109WebServicePackager in project eclipselink by eclipse-ee4j.

the class MTOMTestSuite method setUp.

@BeforeClass
public static void setUp() throws WSDLException {
    try {
        conn = buildConnection();
    } catch (Exception e) {
        e.printStackTrace();
    }
    String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    if (ddlCreate) {
        runDdl(conn, CREATE_MTOM_TABLE, ddlDebug);
    }
    builder.setProjectName(MTOM_TEST);
    builder.setTargetNamespace(MTOM_NAMESPACE);
    TableOperationModel mtomOp = new TableOperationModel();
    mtomOp.additionalOperations = new ArrayList<OperationModel>();
    mtomOp.setName(MTOM_TEST);
    mtomOp.setTablePattern(MTOM);
    mtomOp.setBinaryAttachment(true);
    mtomOp.setAttachmentType("MTOM");
    builder.getOperations().add(mtomOp);
    builder.quiet = true;
    // builder.setLogLevel(SessionLog.FINE_LABEL);
    builder.setLogLevel(SessionLog.OFF_LABEL);
    builder.setDriver(DATABASE_DRIVER);
    builder.setPlatformClassname(DATABASE_PLATFORM);
    builder.getProperties().put(SESSIONS_FILENAME_KEY, NO_SESSIONS_FILENAME);
    builder.setUsername(username);
    builder.setPassword(password);
    builder.setUrl(url);
    builder.setPackager(new JSR109WebServicePackager(null, "WebServiceTestPackager", noArchive) {

        @Override
        public void start() {
        }
    });
    builder.build(DBWS_SCHEMA_STREAM, __nullStream, DBWS_SERVICE_STREAM, DBWS_OR_STREAM, DBWS_OX_STREAM, __nullStream, __nullStream, DBWS_WSDL_STREAM, __nullStream, __nullStream, __nullStream, __nullStream, null);
    MTOMTestSuite mtomTestSuite = new MTOMTestSuite();
    mtomTestSuite.mtomEnabled = true;
    endpoint = Endpoint.create(mtomTestSuite);
    endpoint.publish(ENDPOINT_ADDRESS);
    QName serviceQName = new QName(MTOM_SERVICE_NAMESPACE, MTOM_SERVICE);
    portQName = new QName(MTOM_SERVICE_NAMESPACE, MTOM_PORT);
    testService = Service.create(serviceQName);
    testService.addPort(portQName, SOAP11HTTP_BINDING, ENDPOINT_ADDRESS);
    dispatch = testService.createDispatch(portQName, SOAPMessage.class, MESSAGE, new MTOMFeature(100));
}
Also used : JSR109WebServicePackager(org.eclipse.persistence.tools.dbws.JSR109WebServicePackager) QName(javax.xml.namespace.QName) MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) TableOperationModel(org.eclipse.persistence.tools.dbws.TableOperationModel) SOAPMessage(jakarta.xml.soap.SOAPMessage) WSDLException(javax.wsdl.WSDLException) JAXBException(jakarta.xml.bind.JAXBException) OperationModel(org.eclipse.persistence.tools.dbws.OperationModel) TableOperationModel(org.eclipse.persistence.tools.dbws.TableOperationModel) BeforeClass(org.junit.BeforeClass)

Example 4 with JSR109WebServicePackager

use of org.eclipse.persistence.tools.dbws.JSR109WebServicePackager in project eclipselink by eclipse-ee4j.

the class OptLockTestSuite method setUp.

@BeforeClass
public static void setUp() throws WSDLException {
    try {
        conn = buildConnection();
    } catch (Exception e) {
        e.printStackTrace();
    }
    String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
    if ("true".equalsIgnoreCase(ddlCreateProp)) {
        ddlCreate = true;
    }
    String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
    if ("true".equalsIgnoreCase(ddlDropProp)) {
        ddlDrop = true;
    }
    String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
    if ("true".equalsIgnoreCase(ddlDebugProp)) {
        ddlDebug = true;
    }
    if (ddlCreate) {
        runDdl(conn, CREATE_OPTLOCK_TABLE, ddlDebug);
        try {
            Statement stmt = conn.createStatement();
            for (int i = 0; i < POPULATE_OPTLOCK_TABLE.length; i++) {
                stmt.addBatch(POPULATE_OPTLOCK_TABLE[i]);
            }
            stmt.executeBatch();
        } catch (SQLException e) {
            if (ddlDebug) {
                e.printStackTrace();
            }
        }
    }
    builder.setProjectName(OPTLOCK_TEST);
    builder.setTargetNamespace(OPTLOCK_NAMESPACE);
    TableOperationModel tModel = new TableOperationModel();
    tModel.setName(OPTLOCK);
    tModel.setTablePattern(OPTLOCK);
    builder.getOperations().add(tModel);
    builder.quiet = true;
    // builder.setLogLevel(SessionLog.FINE_LABEL);
    builder.setLogLevel(SessionLog.OFF_LABEL);
    builder.setDriver(DATABASE_DRIVER);
    builder.setPlatformClassname(DATABASE_PLATFORM);
    builder.getProperties().put(SESSIONS_FILENAME_KEY, NO_SESSIONS_FILENAME);
    builder.setUsername(username);
    builder.setPassword(password);
    builder.setUrl(url);
    builder.setPackager(new JSR109WebServicePackager(null, "WebServiceTestPackager", noArchive) {

        @Override
        public void start() {
        }
    });
    builder.build(DBWS_SCHEMA_STREAM, __nullStream, DBWS_SERVICE_STREAM, DBWS_OR_STREAM, DBWS_OX_STREAM, __nullStream, __nullStream, DBWS_WSDL_STREAM, __nullStream, __nullStream, __nullStream, __nullStream, null);
    endpoint = Endpoint.create(new OptLockTestSuite());
    endpoint.publish(ENDPOINT_ADDRESS);
    QName serviceQName = new QName(OPTLOCK_SERVICE_NAMESPACE, OPTLOCK_SERVICE);
    portQName = new QName(OPTLOCK_SERVICE_NAMESPACE, OPTLOCK_PORT);
    testService = Service.create(serviceQName);
    testService.addPort(portQName, SOAP11HTTP_BINDING, ENDPOINT_ADDRESS);
}
Also used : JSR109WebServicePackager(org.eclipse.persistence.tools.dbws.JSR109WebServicePackager) SQLException(java.sql.SQLException) Statement(java.sql.Statement) QName(javax.xml.namespace.QName) TableOperationModel(org.eclipse.persistence.tools.dbws.TableOperationModel) SOAPException(jakarta.xml.soap.SOAPException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) SAXException(org.xml.sax.SAXException) TransformerException(javax.xml.transform.TransformerException) SQLException(java.sql.SQLException) IOException(java.io.IOException) WSDLException(javax.wsdl.WSDLException) JAXBException(jakarta.xml.bind.JAXBException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Endpoint(jakarta.xml.ws.Endpoint) BeforeClass(org.junit.BeforeClass)

Example 5 with JSR109WebServicePackager

use of org.eclipse.persistence.tools.dbws.JSR109WebServicePackager in project eclipselink by eclipse-ee4j.

the class SimpleTableWithNestedSQLTestSuite method checkWSDL.

@Test
public void checkWSDL() throws WSDLException {
    DBWS_BUILDER_XML_USERNAME = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<dbws-builder xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<properties>" + "<property name=\"projectName\">simpletable2</property>" + "<property name=\"logLevel\">off</property>" + "<property name=\"username\">";
    DBWS_BUILDER_XML_PASSWORD = "</property><property name=\"password\">";
    DBWS_BUILDER_XML_URL = "</property><property name=\"url\">";
    DBWS_BUILDER_XML_DRIVER = "</property><property name=\"driver\">";
    DBWS_BUILDER_XML_PLATFORM = "</property><property name=\"platformClassname\">";
    DBWS_BUILDER_XML_MAIN = "</property>" + "</properties>" + "<table " + "schemaPattern=\"%\" " + "tableNamePattern=\"simpletable2\" " + ">" + "<sql " + "name=\"findByName\" " + "isCollection=\"true\" " + "returnType=\"simpletable2Type\" " + ">" + "<text><![CDATA[select * from SIMPLETABLE2 where NAME like ?]]></text>" + "<binding name=\"NAME\" type=\"xsd:string\"/>" + "</sql>" + "</table>" + "</dbws-builder>";
    String username = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
    String password = System.getProperty(DATABASE_PASSWORD_KEY, DEFAULT_DATABASE_PASSWORD);
    String url = System.getProperty(DATABASE_URL_KEY, DEFAULT_DATABASE_URL);
    String builderString = DBWS_BUILDER_XML_USERNAME + username + DBWS_BUILDER_XML_PASSWORD + password + DBWS_BUILDER_XML_URL + url + DBWS_BUILDER_XML_DRIVER + DATABASE_DRIVER + DBWS_BUILDER_XML_PLATFORM + DATABASE_PLATFORM + DBWS_BUILDER_XML_MAIN;
    XMLContext context = new XMLContext(new DBWSBuilderModelProject());
    XMLUnmarshaller unmarshaller = context.createUnmarshaller();
    DBWSBuilderModel builderModel = (DBWSBuilderModel) unmarshaller.unmarshal(new StringReader(builderString));
    DBWSBuilder builder = new DBWSBuilder();
    builder.quiet = true;
    // builder.setLogLevel(SessionLog.FINE_LABEL);
    builder.setLogLevel(SessionLog.OFF_LABEL);
    builder.setPlatformClassname(DATABASE_PLATFORM);
    builder.properties = builderModel.properties;
    builder.getProperties().put(SESSIONS_FILENAME_KEY, NO_SESSIONS_FILENAME);
    builder.operations = builderModel.operations;
    builder.setPackager(new JSR109WebServicePackager(null, "WebServiceTestPackager", noArchive) {

        @Override
        public void start() {
        // do nothing - don't have to verify existence of 'stageDir' when
        // all the streams are in-memory
        }
    });
    ByteArrayOutputStream dbwsServiceStream = new ByteArrayOutputStream();
    ByteArrayOutputStream wsdlStream = new ByteArrayOutputStream();
    builder.build(__nullStream, __nullStream, dbwsServiceStream, __nullStream, __nullStream, __nullStream, __nullStream, wsdlStream, __nullStream, __nullStream, __nullStream, __nullStream, null);
    // for the nested sql operation 'findByName'
    try {
        StringWriter sw = new StringWriter();
        StreamSource wsdlStreamSource = new StreamSource(new StringReader(wsdlStream.toString()));
        Transformer t = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(MATCH_SCHEMA)));
        StreamResult streamResult = new StreamResult(sw);
        t.transform(wsdlStreamSource, streamResult);
        sw.toString();
        SchemaModelProject schemaProject = new SchemaModelProject();
        XMLContext xmlContext2 = new XMLContext(schemaProject);
        unmarshaller = xmlContext2.createUnmarshaller();
        Schema schema = (Schema) unmarshaller.unmarshal(new StringReader(sw.toString()));
        ComplexType findByNameResponseType = schema.getTopLevelComplexTypes().get(FINDBYNAME_RESPONSETYPE);
        Element result = findByNameResponseType.getSequence().getElements().get(0);
        Element unnamed = result.getComplexType().getSequence().getElements().get(0);
        assertTrue("wrong refType for " + FINDBYNAME_RESPONSETYPE, TABLE_ALIAS.equals(unnamed.getRef()));
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) XMLContext(org.eclipse.persistence.oxm.XMLContext) SchemaModelProject(org.eclipse.persistence.internal.oxm.schema.SchemaModelProject) StreamSource(javax.xml.transform.stream.StreamSource) Schema(org.eclipse.persistence.internal.oxm.schema.model.Schema) Element(org.eclipse.persistence.internal.oxm.schema.model.Element) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SQLException(java.sql.SQLException) WSDLException(javax.wsdl.WSDLException) DBWSBuilder(org.eclipse.persistence.tools.dbws.DBWSBuilder) JSR109WebServicePackager(org.eclipse.persistence.tools.dbws.JSR109WebServicePackager) StringWriter(java.io.StringWriter) DBWSBuilderModel(org.eclipse.persistence.tools.dbws.DBWSBuilderModel) StringReader(java.io.StringReader) DBWSBuilderModelProject(org.eclipse.persistence.tools.dbws.DBWSBuilderModelProject) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) ComplexType(org.eclipse.persistence.internal.oxm.schema.model.ComplexType) Test(org.junit.Test)

Aggregations

JSR109WebServicePackager (org.eclipse.persistence.tools.dbws.JSR109WebServicePackager)10 JAXBException (jakarta.xml.bind.JAXBException)9 WSDLException (javax.wsdl.WSDLException)9 SQLException (java.sql.SQLException)7 QName (javax.xml.namespace.QName)7 BeforeClass (org.junit.BeforeClass)7 SOAPException (jakarta.xml.soap.SOAPException)6 IOException (java.io.IOException)6 TransformerException (javax.xml.transform.TransformerException)6 SAXException (org.xml.sax.SAXException)6 Endpoint (jakarta.xml.ws.Endpoint)5 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)5 StringReader (java.io.StringReader)5 Statement (java.sql.Statement)5 XMLContext (org.eclipse.persistence.oxm.XMLContext)5 XMLUnmarshaller (org.eclipse.persistence.oxm.XMLUnmarshaller)5 DBWSBuilderModel (org.eclipse.persistence.tools.dbws.DBWSBuilderModel)5 DBWSBuilderModelProject (org.eclipse.persistence.tools.dbws.DBWSBuilderModelProject)5 TableOperationModel (org.eclipse.persistence.tools.dbws.TableOperationModel)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4