Interacting with adapters from Spring Component, especially db adapter
956386Sep 18 2012 — edited Sep 19 2012hello everybody,
I try to interact with adapters from my Spring component. I actually try to start my query and to receive the result in my Spring Component.
I've already search for documentation about api to communicate with it or documentation about the classes created during the db adapter creation... But .. no result..
So I'm trying to do it my self but I encounter some problems when I'm trying to call the query on the dbAdapter and trying to "play" with the classes created by the db adapter.
Could anyone say me HOW we can interact with adapters from Spring component (in the class bean)?
Also, how can I access to the variables? Is there an equivalent of "getVariableData" and "setVariableData" that I can use in the Spring Component? with which jar and/or import?
I copy/paste what I've already done.
-----
So My Composite contains a Web Service "getStatusByCC" which is linked to a Mediator. The Mediator calls the Spring Component "SprinCallDB" and the Spring Component is linked to a database adapter called "getCreditValidation". The transformation in the mediator component is correct (I test it without the call to the db and it works fine)
First, there is the classes created and added to my project by the db adapter :
-----
Creditcardinfo.java
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for Creditcardinfo complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="Creditcardinfo">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="ccnumber">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <maxLength value="20"/>
* </restriction>
* </simpleType>
* </element>
* <element name="status" minOccurs="0">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <maxLength value="20"/>
* </restriction>
* </simpleType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Creditcardinfo", propOrder = {
"ccnumber",
"status"
})
public class Creditcardinfo {
@XmlElement(required = true)
protected String ccnumber;
protected String status;
/**
* Gets the value of the ccnumber property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCcnumber() {
return ccnumber;
}
/**
* Sets the value of the ccnumber property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCcnumber(String value) {
this.ccnumber = value;
}
/**
* Gets the value of the status property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getStatus() {
return status;
}
/**
* Sets the value of the status property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setStatus(String value) {
this.status = value;
}
}
CreditcardinfoCollection.java
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for CreditcardinfoCollection complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="CreditcardinfoCollection">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Creditcardinfo"
* type="{http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation}Creditcardinfo" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CreditcardinfoCollection", propOrder = {
"creditcardinfo"
})
public class CreditcardinfoCollection {
@XmlElement(name = "Creditcardinfo")
protected List<Creditcardinfo> creditcardinfo;
/**
* Gets the value of the creditcardinfo property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the creditcardinfo property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getCreditcardinfo().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Creditcardinfo }
*
*
*/
public List<Creditcardinfo> getCreditcardinfo() {
if (creditcardinfo == null) {
creditcardinfo = new ArrayList<Creditcardinfo>();
}
return this.creditcardinfo;
}
}
GetCreditValidationSelectCcnb.java
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for getCreditValidationSelect_ccnb complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="getCreditValidationSelect_ccnb">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="ccnb" type="{http://www.w3.org/2001/XMLSchema}string"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getCreditValidationSelect_ccnb", propOrder = {
"ccnb"
})
public class GetCreditValidationSelectCcnb {
@XmlElement(required = true)
protected String ccnb;
/**
* Gets the value of the ccnb property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCcnb() {
return ccnb;
}
/**
* Sets the value of the ccnb property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCcnb(String value) {
this.ccnb = value;
}
}
ObjectFactory.java
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName CreditcardinfoCollectionQNAME = new QName("http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", "CreditcardinfoCollection");
private final static QName GetCreditValidationSelectCcnbInputParametersQNAME = new QName("http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", "getCreditValidationSelect_ccnbInputParameters");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link CreditcardinfoCollection }
*
*/
public CreditcardinfoCollection createCreditcardinfoCollection() {
return new CreditcardinfoCollection();
}
/**
* Create an instance of {@link GetCreditValidationSelectCcnb }
*
*/
public GetCreditValidationSelectCcnb createGetCreditValidationSelectCcnb() {
return new GetCreditValidationSelectCcnb();
}
/**
* Create an instance of {@link Creditcardinfo }
*
*/
public Creditcardinfo createCreditcardinfo() {
return new Creditcardinfo();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link CreditcardinfoCollection }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", name = "CreditcardinfoCollection")
public JAXBElement<CreditcardinfoCollection> createCreditcardinfoCollection(CreditcardinfoCollection value) {
return new JAXBElement<CreditcardinfoCollection>(_CreditcardinfoCollection_QNAME, CreditcardinfoCollection.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link GetCreditValidationSelectCcnb }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", name = "getCreditValidationSelect_ccnbInputParameters")
public JAXBElement<GetCreditValidationSelectCcnb> createGetCreditValidationSelectCcnbInputParameters(GetCreditValidationSelectCcnb value) {
return new JAXBElement<GetCreditValidationSelectCcnb>(_GetCreditValidationSelectCcnbInputParameters_QNAME, GetCreditValidationSelectCcnb.class, null, value);
}
}
package-info.java
@javax.xml.bind.annotation.XmlSchema(namespace = "http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation;
GetCreditValidation_ptt.java
package getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
// !DO NOT EDIT THIS FILE!
// This source file is generated by Oracle tools
// Contents may be subject to change
// For reporting problems, use the following
// Version = Oracle WebServices (11.1.1.0.0, build 111209.0821.28162)
@WebService(targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/CreditCardValidation/validationForCCWithSpring/getCreditValidation",
name="getCreditValidation_ptt")
@XmlSeeAlso(
{ com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation.ObjectFactory.class })
public interface GetCreditValidation_ptt
{
@WebMethod
@SOAPBinding(parameterStyle=ParameterStyle.BARE)
@Action(input="http://xmlns.oracle.com/pcbpel/adapter/db/CreditCardValidation/validationForCCWithSpring/getCreditValidation/getCreditValidation_ptt/getCreditValidationSelectRequest",
output="http://xmlns.oracle.com/pcbpel/adapter/db/CreditCardValidation/validationForCCWithSpring/getCreditValidation/getCreditValidation_ptt/getCreditValidationSelectResponse")
@WebResult(targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation",
partName="CreditcardinfoCollection", name="CreditcardinfoCollection")
public com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation.CreditcardinfoCollection getCreditValidationSelect(@WebParam(targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation",
partName="getCreditValidationSelect_inputParameters", name="getCreditValidationSelect_ccnbInputParameters")
com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation.GetCreditValidationSelectCcnb getCreditValidationSelect_inputParameters);
}
-----
Here there is the classes linked to the Spring Component and the configuration file :
SpringCallDB
<?xml version="1.0" encoding="windows-1252" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-2.5.xsd http://xmlns.oracle.com/weblogic/weblogic-sca META-INF/weblogic-sca.xsd">
<!--Spring Bean definitions go here-->
<sca:service name="CCSpringService" target="CCSpringImpl"
type="validationForCC.spring.service.api.ISpringCCService"/>
<bean id="CCSpringImpl" class="validationForCC.spring.service.impl.SpringCCServiceImpl">
<property name="dbRequest" ref="getCreditValidation"/>
</bean>
<sca:reference type="getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns.GetCreditValidation_ptt"
name="getCreditValidation"/>
</beans>
CreditCardNumber.java
package validationForCC.spring.model;
public class CreditCardNumber {
private String ccNumber;
public CreditCardNumber() {
super();
}
public void setCcNumber(String nb){
this.ccNumber = nb;
}
public String getCcNumber(){
return ccNumber;
}
}
Response.java
package validationForCC.spring.model;
public class Response {
String reply;
public Response() {
super();
}
public void setReply(String rep){
this.reply = rep;
}
public String getReply(){
return reply;
}
}
ISpringCCService.java
package validationForCC.spring.service.api;
import validationForCC.spring.model.CreditCardNumber;
import validationForCC.spring.model.Response;
public interface ISpringCCService {
/**
* @param ccn
* @return
*/
public Response getCCStatus(CreditCardNumber ccn);
}
SpringCCServiceImpl.java
package validationForCC.spring.service.impl;
import com.oracle.xmlns.pcbpel.adapter.db.top.getcreditvalidation.*;
import java.util.List;
import javax.jws.WebParam;
import validationForCC.spring.model.CreditCardNumber;
import validationForCC.spring.model.Response;
public class SpringCCServiceImpl {
public SpringCCServiceImpl() {
super();
}
private getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns.GetCreditValidation_ptt dbRequest;
public Response getCCStatus(CreditCardNumber ccn){
Response resp = new Response();
CreditcardinfoCollection resultSet;
GetCreditValidationSelectCcnb selectCCNb = new GetCreditValidationSelectCcnb();
selectCCNb.setCcnb(ccn.getCcNumber());
resultSet = dbRequest.getCreditValidationSelect(selectCCNb);
resp.setReply((resultSet.getCreditcardinfo().get(0).getStatus()));
return resp;
}
public getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns.GetCreditValidation_ptt getDbRequest(){
return dbRequest;
}
public void setDbRequest(getcreditvalidation.validationforccwithspring.creditcardvalidation.db.adapter.pcbpel.com.oracle.xmlns.GetCreditValidation_ptt dbReq){
this.dbRequest = dbReq;
}
}
-----
So, the line which is the cause of the error is the following :
resultSet = dbRequest.getCreditValidationSelect(selectCCNb);
in the SpringCCServiceImpl.java class
And there is the error I obtain :
+weblogic.sca.api.ScaException: java.lang.RuntimeException: BINDING.JCA-12563 Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'getCreditValidationSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [getCreditValidationSelect], Descriptor name: [getCreditValidation.Creditcardinfo]. Caused by Exception [EclipseLink-6003] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException Exception Description: The number of arguments provided to the query for execution does not match the number of arguments in the query definition. Query: ReadAllQuery(name="getCreditValidationSelect" referenceClass=Creditcardinfo ). See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'getCreditValidationSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [getCreditValidationSelect], Descriptor name: [getCreditValidation.Creditcardinfo]. Caused by Exception [EclipseLink-6003] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException Exception Description: The number of arguments provided to the query for execution does not match the number of arguments in the query definition. Query: ReadAllQuery(name="getCreditValidationSelect" referenceClass=Creditcardinfo ). See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
java.lang.RuntimeException: BINDING.JCA-12563 Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'getCreditValidationSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [getCreditValidationSelect], Descriptor name: [getCreditValidation.Creditcardinfo]. Caused by Exception [EclipseLink-6003] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException Exception Description: The number of arguments provided to the query for execution does not match the number of arguments in the query definition. Query: ReadAllQuery(name="getCreditValidationSelect" referenceClass=Creditcardinfo ). See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message ca
Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'getCreditValidationSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [getCreditValidationSelect], Descriptor name: [getCreditValidation.Creditcardinfo]. Caused by Exception [EclipseLink-6003] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException Exception Description: The number of arguments provided to the query for execution does not match the number of arguments in the query definition. Query: ReadAllQuery(name="getCreditValidationSelect" referenceClass=Creditcardinfo ). See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. +
Any idea is welcome! :)
If you have great urls to communicate with adapters and variables from spring component, don't hesitate to post it!
Thanks in advance,
Sophie
Edited by: 953383 on Sep 18, 2012 6:41 AM
Edited by: 953383 on Sep 18, 2012 6:43 AM
Edited by: 953383 on Sep 18, 2012 6:46 AM