Search in sources :

Example 1 with DatabindingModeFeature

use of com.oracle.webservices.api.databinding.DatabindingModeFeature in project metro-jax-ws by eclipse-ee4j.

the class SDODatabindingTestBase method invmSetup.

protected WebServiceFeature[] invmSetup(final URL wsdlURL, final Class sei, final Class seb, final QName serviceName, final QName portName) {
    DatabindingModeFeature dbmf = new DatabindingModeFeature("eclipselink.sdo");
    Class implementorClass = seb;
    boolean handlersSetInDD = false;
    Container container = Container.NONE;
    Map<String, SDDocumentSource> docs = new HashMap<String, SDDocumentSource>();
    SDDocumentSource primaryWSDL = SDDocumentSource.create(wsdlURL);
    docs.put(wsdlURL.toString(), primaryWSDL);
    ExternalMetadataFeature exm = ExternalMetadataFeature.builder().setReader(new com.sun.xml.ws.model.ReflectAnnotationReader() {

        public <A extends Annotation> A getAnnotation(final Class<A> annType, final Class<?> cls) {
            if (WebService.class.equals(annType)) {
                final WebService ws = cls.getAnnotation(WebService.class);
                return (A) new jakarta.jws.WebService() {

                    public Class<? extends Annotation> annotationType() {
                        return WebService.class;
                    }

                    @Override
                    public String endpointInterface() {
                        return sei.getName();
                    }

                    @Override
                    public String name() {
                        return (ws != null) ? ws.name() : null;
                    }

                    @Override
                    public String portName() {
                        return (ws != null) ? ws.portName() : null;
                    }

                    @Override
                    public String serviceName() {
                        return (ws != null) ? ws.serviceName() : null;
                    }

                    @Override
                    public String targetNamespace() {
                        return (ws != null) ? ws.targetNamespace() : null;
                    }

                    @Override
                    public String wsdlLocation() {
                        return (ws != null) ? ws.wsdlLocation() : null;
                    }
                };
            }
            return cls.getAnnotation(annType);
        }
    }).build();
    BindingID bindingID = BindingID.parse(implementorClass);
    WSBinding binding = bindingID.createBinding(dbmf, exm);
    final WSEndpoint<?> endpoint = WSEndpoint.create(implementorClass, !handlersSetInDD, null, serviceName, portName, container, binding, primaryWSDL, docs.values(), XmlUtil.createEntityResolver(null), false);
    ComponentFeature cf = new ComponentFeature(new com.sun.xml.ws.api.Component() {

        public <S> S getSPI(Class<S> spiType) {
            if (TransportTubeFactory.class.equals(spiType))
                return (S) new TransportTubeFactory() {

                    public Tube doCreate(ClientTubeAssemblerContext context) {
                        return new InVmTransportTube(context.getCodec(), context.getBinding(), wsdlURL, endpoint);
                    }
                };
            return null;
        }
    });
    WebServiceFeature[] f = { dbmf, cf };
    return f;
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) Tube(com.sun.xml.ws.api.pipe.Tube) HashMap(java.util.HashMap) WebService(jakarta.jws.WebService) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) BindingID(com.sun.xml.ws.api.BindingID) TransportTubeFactory(com.sun.xml.ws.api.pipe.TransportTubeFactory) Container(com.sun.xml.ws.api.server.Container) SDDocumentSource(com.sun.xml.ws.api.server.SDDocumentSource) Annotation(java.lang.annotation.Annotation) ExternalMetadataFeature(com.oracle.webservices.api.databinding.ExternalMetadataFeature) WebService(jakarta.jws.WebService) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) ComponentFeature(com.sun.xml.ws.api.ComponentFeature) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)

Example 2 with DatabindingModeFeature

use of com.oracle.webservices.api.databinding.DatabindingModeFeature 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 3 with DatabindingModeFeature

use of com.oracle.webservices.api.databinding.DatabindingModeFeature in project metro-jax-ws by eclipse-ee4j.

the class SDOHRAppServiceTest method testSDO_HRAppServiceNoWrapper.

// Bug 14071356
public void testSDO_HRAppServiceNoWrapper() throws Exception {
    Set<SchemaInfo> schemas = SDOUtils.getSchemas(getResource("wsdl/HRAppService.wsdl").getFile());
    DatabindingConfig srvConfig = new DatabindingConfig();
    Class<HRAppServiceNoWrapper> sei = HRAppServiceNoWrapper.class;
    Class<HRAppServiceImpl> seb = HRAppServiceImpl.class;
    SDOConfig cSdo = sdoConfig(schemas, false);
    SDOConfig sSdo = sdoConfig(schemas, true);
    srvConfig.setContractClass(sei);
    srvConfig.setEndpointClass(seb);
    DatabindingModeFeature dbm = new DatabindingModeFeature("eclipselink.sdo");
    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, sSdo.resolver);
    srvConfig.properties().put("com.sun.xml.ws.api.model.SuppressDocLitWrapperGeneration", true);
    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, cSdo.resolver);
    cliConfig.properties().put("com.sun.xml.ws.api.model.SuppressDocLitWrapperGeneration", true);
    HRAppServiceNoWrapper proxy = createProxy(sei, srvConfig, cliConfig, debug);
    java.math.BigDecimal totalComp = proxy.getTotalComp(new BigInteger("222"));
    assertEquals("222", totalComp.toString());
    totalComp = proxy.getTotalComp(new BigInteger("333"));
    assertEquals("333", totalComp.toString());
    doTestGetDeptno("1", proxy);
    doTestGetDeptno("2", proxy);
    doTestGetDeptno("2000", proxy);
    List<Emp> emps = proxy.getManagerAndPeers(new BigInteger("100"));
    assertEquals(3, emps.size());
    for (int i = 0; i < emps.size(); i++) {
        assertEquals("name" + i, emps.get(i).getEname());
        assertEquals("job" + i, emps.get(i).getJob());
    }
    HelperContext context = cSdo.context;
    {
        Emp emp = (Emp) context.getDataFactory().create(Emp.class);
        ProcessControl processControl = (ProcessControl) context.getDataFactory().create(ProcessControl.class);
        processControl.setReturnMode("Full");
        emp.setEname("name0");
        List<Emp> empIn = new Vector<Emp>();
        empIn.add(emp);
        emp = (Emp) context.getDataFactory().create(Emp.class);
        emp.setEname("name1");
        empIn.add(emp);
        List<Emp> ret = proxy.processEmps("myoperation", empIn, processControl);
        for (int i = 0; i < ret.size(); i++) {
            assertEquals(ret.get(i).getEname(), empIn.get(i).getEname());
            assertEquals("myoperation", ret.get(i).getJob());
        }
    }
    {
        Emp emp = createEmployee(200, "1", "name", "1000", "fry cook", context);
        Emp ret = proxy.createEmp(emp);
        assertEquals(ret.getEname(), emp.getEname());
        assertEquals(ret.getEmpno(), emp.getEmpno());
        assertEquals(ret.getDeptno(), emp.getDeptno());
        assertEquals(ret.getJob(), emp.getJob());
        doTestGetDeptno("1", proxy);
        doTestGetDeptno("2", proxy);
        doTestGetDeptno("2000", proxy);
    }
}
Also used : ProcessControl(com.sun.xml.ws.sdo.sample.service.types.ProcessControl) HelperContext(commonj.sdo.helper.HelperContext) SDOHelperContext(org.eclipse.persistence.sdo.helper.SDOHelperContext) Emp(com.sun.xml.ws.sdo.sample.service.types.Emp) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint) DatabindingConfig(com.sun.xml.ws.api.databinding.DatabindingConfig) BigDecimal(java.math.BigDecimal) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) BigInteger(java.math.BigInteger) List(java.util.List) SchemaInfo(com.sun.xml.ws.db.sdo.SchemaInfo)

Example 4 with DatabindingModeFeature

use of com.oracle.webservices.api.databinding.DatabindingModeFeature 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 5 with DatabindingModeFeature

use of com.oracle.webservices.api.databinding.DatabindingModeFeature 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)

Aggregations

DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)21 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)19 DatabindingConfig (com.sun.xml.ws.api.databinding.DatabindingConfig)15 QName (javax.xml.namespace.QName)7 SchemaInfo (com.sun.xml.ws.db.sdo.SchemaInfo)6 Databinding (com.oracle.webservices.api.databinding.Databinding)4 DatabindingFactory (com.oracle.webservices.api.databinding.DatabindingFactory)4 WebServiceFeatureList (com.sun.xml.ws.binding.WebServiceFeatureList)4 HelperContext (commonj.sdo.helper.HelperContext)4 Map (java.util.Map)4 SDOHelperContext (org.eclipse.persistence.sdo.helper.SDOHelperContext)4 HelperContextResolver (com.sun.xml.ws.db.sdo.HelperContextResolver)3 BindingContext (com.sun.xml.ws.spi.db.BindingContext)3 File (java.io.File)3 List (java.util.List)3 JavaCallInfo (com.oracle.webservices.api.databinding.JavaCallInfo)2 MessageContext (com.oracle.webservices.api.message.MessageContext)2 BindingID (com.sun.xml.ws.api.BindingID)2 DummyAnnotations (com.sun.xml.ws.base.DummyAnnotations)2 MySDO (com.sun.xml.ws.sdo.test.helloSDO.MySDO)2