Search in sources :

Example 1 with HelperContextResolver

use of com.sun.xml.ws.db.sdo.HelperContextResolver in project metro-jax-ws by eclipse-ee4j.

the class SDODatabindingTestBase method sdoConfig.

protected SDOConfig sdoConfig(Set<SchemaInfo> schemas, boolean server) {
    final SDOConfig config = new SDOConfig();
    config.context = server ? SDOHelperContext.getHelperContext("server") : // SDODatabindingContext.getLocalHelperContext();
    SDOHelperContext.getHelperContext();
    config.resolver = new HelperContextResolver() {

        public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
            return config.context;
        }
    };
    for (SchemaInfo xi : schemas) ((SDOXSDHelper) config.context.getXSDHelper()).define(xi.getSchemaSource(), null);
    return config;
}
Also used : HelperContext(commonj.sdo.helper.HelperContext) SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) QName(javax.xml.namespace.QName) HelperContextResolver(com.sun.xml.ws.db.sdo.HelperContextResolver) SchemaInfo(com.sun.xml.ws.db.sdo.SchemaInfo)

Example 2 with HelperContextResolver

use of com.sun.xml.ws.db.sdo.HelperContextResolver in project metro-jax-ws by eclipse-ee4j.

the class SDORuntimeBasicTest method testAddNumbers.

public void testAddNumbers() throws Exception {
    DatabindingConfig srvConfig = new DatabindingConfig();
    File f = getSchema("AddNumbers.xsd");
    Class<AddNumbersPortType> sei = AddNumbersPortType.class;
    Class<AddNumbersServiceImpl> seb = AddNumbersServiceImpl.class;
    // SDODatabindingContext.getLocalHelperContext();
    final HelperContext chc = SDOHelperContext.getHelperContext("client");
    HelperContextResolver chcr = new HelperContextResolver() {

        // @Override
        public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
            return chc;
        }
    };
    SDOUtils.defineSchema(chc, f);
    Set<SchemaInfo> schemas = SDOUtils.getSchemas(f);
    final HelperContext shc = SDOHelperContext.getHelperContext("server");
    HelperContextResolver shcr = new HelperContextResolver() {

        // @Override
        public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
            return shc;
        }
    };
    srvConfig.setEndpointClass(seb);
    DatabindingModeFeature dbm = databindingMode();
    WebServiceFeature[] features = { dbm };
    srvConfig.setFeatures(features);
    srvConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
    // srvConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_FILE, f);
    srvConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, shcr);
    DatabindingConfig cliConfig = new DatabindingConfig();
    cliConfig.setContractClass(sei);
    cliConfig.setFeatures(features);
    cliConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
    // cliConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_FILE, f);
    cliConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, chcr);
    AddNumbersPortType proxy = createProxy(sei, srvConfig, cliConfig, false);
    Object obj = proxy.addNumbers(4, -83);
    assertTrue(obj instanceof Integer);
    Integer resp = (Integer) obj;
    assertEquals(Integer.valueOf(-79), resp);
}
Also used : HelperContext(commonj.sdo.helper.HelperContext) SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) QName(javax.xml.namespace.QName) AddNumbersServiceImpl(com.sun.xml.ws.sdo.test.AddNumbersServiceImpl) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) AddNumbersPortType(com.sun.xml.ws.sdo.test.AddNumbersPortType) DatabindingConfig(com.sun.xml.ws.api.databinding.DatabindingConfig) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) HelperContextResolver(com.sun.xml.ws.db.sdo.HelperContextResolver) File(java.io.File) Map(java.util.Map) SchemaInfo(com.sun.xml.ws.db.sdo.SchemaInfo)

Example 3 with HelperContextResolver

use of com.sun.xml.ws.db.sdo.HelperContextResolver in project metro-jax-ws by eclipse-ee4j.

the class SDORuntimeBasicTest method testEchoSDO.

public void testEchoSDO() throws Exception {
    Class<HelloSDO_ProxyInterface> sei = HelloSDO_ProxyInterface.class;
    Class<HelloSDO_ProxyInterfaceImpl> seb = HelloSDO_ProxyInterfaceImpl.class;
    DatabindingConfig srvConfig = new DatabindingConfig();
    final HelperContext shc = SDOHelperContext.getHelperContext("server");
    HelperContextResolver shcr = new HelperContextResolver() {

        // @Override
        public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
            return shc;
        }
    };
    File f = getSchema("MySDO.xsd");
    Set<SchemaInfo> schemas = SDOUtils.getSchemas(f);
    srvConfig.setEndpointClass(seb);
    DatabindingModeFeature dbm = databindingMode();
    WebServiceFeature[] features = { dbm };
    srvConfig.setFeatures(features);
    srvConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
    srvConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, shcr);
    DatabindingConfig cliConfig = new DatabindingConfig();
    // SDODatabindingContext.getLocalHelperContext();
    final HelperContext chc = SDOHelperContext.getHelperContext("client");
    HelperContextResolver chcr = new HelperContextResolver() {

        // @Override
        public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
            return chc;
        }
    };
    cliConfig.setContractClass(sei);
    cliConfig.setFeatures(features);
    cliConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
    cliConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, chcr);
    HelloSDO_ProxyInterface proxy = createProxy(sei, srvConfig, cliConfig, false);
    SDOUtils.defineSchema(chc, f);
    MySDO mySDO = createMySDO(chc, "Gigi", 20);
    Object obj = proxy.echoSDO(mySDO);
    assertTrue(obj instanceof MySDO);
    mySDO = (MySDO) obj;
    assertEquals(21, mySDO.getIntPart());
    assertEquals("Gary", mySDO.getStringPart());
    String wrapperName = srvConfig.properties().get(BindingContext.class.getName()).getClass().getName();
    assertTrue(wrapperName != null && wrapperName.endsWith("SDOContextWrapper"));
}
Also used : HelloSDO_ProxyInterface(com.sun.xml.ws.sdo.test.HelloSDO_ProxyInterface) HelperContext(commonj.sdo.helper.HelperContext) SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) QName(javax.xml.namespace.QName) MySDO(com.sun.xml.ws.sdo.test.helloSDO.MySDO) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) BindingContext(com.sun.xml.ws.spi.db.BindingContext) DatabindingConfig(com.sun.xml.ws.api.databinding.DatabindingConfig) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) HelperContextResolver(com.sun.xml.ws.db.sdo.HelperContextResolver) Map(java.util.Map) File(java.io.File) HelloSDO_ProxyInterfaceImpl(com.sun.xml.ws.sdo.test.HelloSDO_ProxyInterfaceImpl) SchemaInfo(com.sun.xml.ws.db.sdo.SchemaInfo)

Example 4 with HelperContextResolver

use of com.sun.xml.ws.db.sdo.HelperContextResolver in project metro-jax-ws by eclipse-ee4j.

the class SDORuntimeBasicTest method testEchoSDO_DocLitWrapNoWrapper.

public void testEchoSDO_DocLitWrapNoWrapper() throws Exception {
    Class<HelloSDO_DocLitWrap> sei = HelloSDO_DocLitWrap.class;
    Class<HelloSDO_DocLitWrapImpl> seb = HelloSDO_DocLitWrapImpl.class;
    DatabindingConfig srvConfig = new DatabindingConfig();
    final HelperContext shc = SDOHelperContext.getHelperContext("server");
    HelperContextResolver shcr = new HelperContextResolver() {

        public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
            return shc;
        }
    };
    File f = getSchema("MySDO.xsd");
    Set<SchemaInfo> schemas = SDOUtils.getSchemas(f);
    srvConfig.setEndpointClass(seb);
    DatabindingModeFeature dbm = databindingMode();
    WebServiceFeature[] features = { dbm };
    srvConfig.setFeatures(features);
    srvConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
    srvConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, shcr);
    srvConfig.properties().put("com.sun.xml.ws.api.model.SuppressDocLitWrapperGeneration", true);
    DatabindingConfig cliConfig = new DatabindingConfig();
    // SDODatabindingContext.getLocalHelperContext();
    final HelperContext chc = SDOHelperContext.getHelperContext("client");
    HelperContextResolver chcr = new HelperContextResolver() {

        public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
            return chc;
        }
    };
    cliConfig.setContractClass(sei);
    cliConfig.setFeatures(features);
    cliConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
    cliConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, chcr);
    cliConfig.properties().put("com.sun.xml.ws.api.model.SuppressDocLitWrapperGeneration", true);
    HelloSDO_DocLitWrap proxy = createProxy(sei, srvConfig, cliConfig, false);
    SDOUtils.defineSchema(chc, f);
    String s = "Gigi";
    int i = 20;
    MySDO mySDO = createMySDO(chc, s, i);
    assertEquals(s, proxy.returnS(mySDO));
    assertEquals(i, proxy.returnI(mySDO));
    Object obj = proxy.echoSDO(mySDO);
    assertTrue(obj instanceof MySDO);
    mySDO = (MySDO) obj;
    assertEquals(21, mySDO.getIntPart());
    assertEquals("Gary", mySDO.getStringPart());
    String wrapperName = srvConfig.properties().get(BindingContext.class.getName()).getClass().getName();
    assertTrue(wrapperName != null && wrapperName.endsWith("SDOContextWrapper"));
    {
        MySDO[] a = { createMySDO(chc, "a", 1), createMySDO(chc, "b", 2), createMySDO(chc, "c", 3) };
        List<MySDO> lreq = Arrays.asList(a);
        List<String> lres = proxy.testList1(lreq);
        assertEquals(lres.size(), lreq.size());
    }
    {
        MySDO[] a = { createMySDO(chc, "a", 1), createMySDO(chc, "b", 2), createMySDO(chc, "c", 3) };
        List<String> l1 = Arrays.asList(new String[] { "w", "x", "y", "z" });
        List<MySDO> l2 = Arrays.asList(a);
        List<String> lres = proxy.testList2(l1, l2);
        assertEquals(lres.size(), l1.size() + l2.size());
    }
    {
        MySDO[] a = { createMySDO(chc, "g", 5), createMySDO(chc, "j", 6), createMySDO(chc, "k", 7), createMySDO(chc, "l", 8), createMySDO(chc, "h", 9) };
        String[] res = proxy.arrayList01(a);
        assertEquals(res.length, a.length);
    }
}
Also used : HelperContext(commonj.sdo.helper.HelperContext) SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) QName(javax.xml.namespace.QName) MySDO(com.sun.xml.ws.sdo.test.helloSDO.MySDO) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) BindingContext(com.sun.xml.ws.spi.db.BindingContext) HelloSDO_DocLitWrapImpl(com.sun.xml.ws.sdo.test.HelloSDO_DocLitWrapImpl) DatabindingConfig(com.sun.xml.ws.api.databinding.DatabindingConfig) HelloSDO_DocLitWrap(com.sun.xml.ws.sdo.test.HelloSDO_DocLitWrap) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) List(java.util.List) HelperContextResolver(com.sun.xml.ws.db.sdo.HelperContextResolver) Map(java.util.Map) File(java.io.File) SchemaInfo(com.sun.xml.ws.db.sdo.SchemaInfo)

Aggregations

HelperContextResolver (com.sun.xml.ws.db.sdo.HelperContextResolver)4 SchemaInfo (com.sun.xml.ws.db.sdo.SchemaInfo)4 HelperContext (commonj.sdo.helper.HelperContext)4 QName (javax.xml.namespace.QName)4 SDOHelperContext (org.eclipse.persistence.sdo.helper.SDOHelperContext)4 DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)3 DatabindingConfig (com.sun.xml.ws.api.databinding.DatabindingConfig)3 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)3 File (java.io.File)3 Map (java.util.Map)3 MySDO (com.sun.xml.ws.sdo.test.helloSDO.MySDO)2 BindingContext (com.sun.xml.ws.spi.db.BindingContext)2 AddNumbersPortType (com.sun.xml.ws.sdo.test.AddNumbersPortType)1 AddNumbersServiceImpl (com.sun.xml.ws.sdo.test.AddNumbersServiceImpl)1 HelloSDO_DocLitWrap (com.sun.xml.ws.sdo.test.HelloSDO_DocLitWrap)1 HelloSDO_DocLitWrapImpl (com.sun.xml.ws.sdo.test.HelloSDO_DocLitWrapImpl)1 HelloSDO_ProxyInterface (com.sun.xml.ws.sdo.test.HelloSDO_ProxyInterface)1 HelloSDO_ProxyInterfaceImpl (com.sun.xml.ws.sdo.test.HelloSDO_ProxyInterfaceImpl)1 List (java.util.List)1