Trying to fetch data from mongodb to ws02 integratoe and gives me output like that
success details"robust in-only operation"
In your "operation" add returnRequestStatus="true".
Example:
<operation name="myInsert_operation" returnRequestStatus="true">
<call-query href="myInsert_query">
<with-param name="active" query-param="active"/>
<with-param name="id" query-param="id"/>
</call-query>
</operation>
Related
I am new to wso2 6.4.0. I have to insert excel data to sql so i choose wso2 dss. Using dss records fetching correctly and inserting too but inserting only one record(top one only) remain records getting skipped. I used nested query option also to retrieve as well as insertion.
<query id="readExcelData" useConfig="excelConfig">
<excel>
<workbookname>sheet1</workbookname>
<hasheader>true</hasheader>
<startingrow>2</startingrow>
<maxrowcount>-1</maxrowcount>
<headerrow>1</headerrow>
</excel>
<result element="Products" rowName="Product">
<element column="ID" name="ID" xsdType="xs:string"/>
<element column="Model" name="Model" xsdType="xs:string"/>
<element column="Classification" name="Classification" xsdType="xs:string"/>
<call-query href="insertIntoSql" requiredRoles="">
<with-param name="ID" query-param="ID" />
<with-param name="Model" query-param="Model" />
<with-param name="Classification" query-param="Classification" />
</call-query>
</result>
</query>
<operation name="excelFileProcessing" returnRequestStatus="true">
<call-query href="readExcelData"/>
</operation>
<query id="insertIntoSql" useConfig="sqlConfig">
<sql>insert into dbo.myProductList(ID,Model,Classification) values(:ID,:Model,:Classification)</sql>
<param name="ID" sqlType="STRING" />
<param name="Model" sqlType="STRING" />
<param name="Classification" sqlType="STRING" />
</query>
Once you retrieve records from Excel sheet you are getting sets of records. Therefore you have to write a synapse config to insert each record. For that, you have iterate over the payload of excel sheet's data (for each record) and insert. You can use iterate mediator. For an example you can implement something similar to this.
You can follow,
In the proxy service/ API call the dataservice to get excel sheet's
data.
Iterate over the result set.
In each iteration, create the
payload to insert data to DB and call the dataservice to invoke the
insert data query.
Invoke the proxy service / API.
I followed following sample with one different i used MS SQL database.
http://wso2.com/library/tutorials/2013/11/scheduled-database-polling-with-wso2-data-services-server/
I am observing that polling is working as expected but timestamp (datetime column in sql is not getting updated)
Here is my DSS XML
<data enableBatchRequests="true" name="PollingService" serviceNamespace="http://ws.wso2.org/dataservice/samples/eventing_sample" transports="http https local">
<config enableOData="false" id="Default">
<property name="driverClassName">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="url">jdbc:sqlserver://geoshieldsp3\sqlexpress;databaseName=RahulTest</property>
<property name="username">sa</property>
<property name="password">CSSL#2014</property>
</config>
<query id="pollingQuery" output-event-trigger="pollingTrigger" useConfig="Default">
<sql>select x.[Call Number], x.Priority, x.Call_Type, x.DispatchDate,y.total from CADFeeds as x left join
(select *,count([Call Number]) over() as total from CADFeeds ) as y on x.[Call Number]=y.[Call Number]
where x.DispatchDate > (select TIMESTAMP from Timestamp where id=1)</sql>
<result element="Calls" rowName="call">
<element column="Call Number" name="CallNumber" xsdType="string"/>
<element column="Priority" name="Priority" xsdType="float"/>
<element column="Call_Type" name="Call_Type" xsdType="string"/>
<element column="DispatchDate" name="DispatchDate" xsdType="string"/>
<element column="total" name="count" xsdType="integer"/>
</result>
</query>
<query id="UpdateTimeStamp" useConfig="Default">
<sql>update dbo.Timestamp set timestamp = GETDATE() where ID=1</sql>
<param name="timestamp" ordinal="2" sqlType="STRING"/>
</query>
<event-trigger id="pollingTrigger">
<expression>//*[local-name()='count' and namespace-uri()='http://ws.wso2.org/dataservice/samples/eventing_sample']>0</expression>
<target-topic>polling_Topic</target-topic>
<subscriptions>
<subscription>http://localhost:8280/services/PollingProxy</subscription>
</subscriptions>
</event-trigger>
<operation name="PollingOperation">
<call-query href="pollingQuery"/>
</operation>
<operation name="UpdateTimeStamp">
<call-query href="UpdateTimeStamp">
<with-param name="timestamp" query-param="timestamp"/>
</call-query>
</operation>
</data>
Here is the DB schema for timestamp table
CREATE TABLE [dbo].[Timestamp](
[ID] [int] NULL,
[timestamp] [datetime] NULL
) ON [PRIMARY]
I do not see anything in the log or command prompt related to timestamp update.
Any help is greatly appreciated.
Thanks,
Rahul
There seems to be a mismatch between the operation and the query.
For the below SQL, query param is not needed as there are no arguments supplied.
Please try the following.
<operation name="UpdateTimeStamp">
<call-query href="UpdateTimeStamp">
</call-query>
</operation>
<query id="UpdateTimeStamp" useConfig="Default">
<sql>update dbo.Timestamp set timestamp = GETDATE() where ID=1</sql>
</query>
I'm trying to create a service with an inner join query but it returns this error:
org.postgresql.util.PSQLException: A result was returned when none was expected.
This is my service:
<data name="consultarPersona" transports="http https local">
<config enableOData="true" id="mi_datasource">
<property name="carbon_datasource_name">fuente_datos</property>
</config>
<query id="contactos_registrados" useConfig="mi_datasource">
<sql>select * from t_contacto inner join t_datos_contacto on t_contacto.id = t_datos_contacto.id</sql>
</query>
<operation name="obtenerDatosContactos">
<call-query href="contactos_registrados"/>
</operation>
</data>
You should specify which columns do you want to return and generate the response, the result is an service like this:
<data name="consultarPersona" transports="http https local">
<config enableOData="true" id="mi_datasource">
<property name="carbon_datasource_name">fuente_datos</property>
</config>
<query id="contactos_registrados" useConfig="mi_datasource">
<sql>select name, age from t_contacto inner join t_datos_contacto on t_contacto.id = t_datos_contacto.id</sql>
<result element="contactoCollection" rowName="contacto">
<element column="name" name="name" xsdType="xs:string"/>
<element column="age" name="age" xsdType="xs:string"/>
</result>
</query>
<operation name="obtenerDatosContactos">
<call-query href="contactos_registrados"/>
</operation>
</data>
I hope this coudl help you.
I am developing simple dss service in which i am retrieving customer details based on some input parameters.
In the output, i am displaying customer_id,first_name,last_name,mobile_number,email and status of customer.
Now if any of the above 6 output field are blank in the database entry(i.e.if the mobile number of customer is not entered in DB) and if i try retrive that customer detail via dss, i dont get the customer details in the output.
Only if there is a value in the above 6 output field in the database, then only that customer's detail is retrieved.
I tried putting the output field as optional, but that didnt help. Also tried giving default value to outpu field, but that also didn't help
Following is my data service.
<data name="CustomerStatusManagementDssdirectconsole">
<config id="ildb">
<property name="carbon_datasource_name">il_database</property>
</config>
<query id="select_customer_details_by_any_parameter" useConfig="ildb">
<sql>select * from ildb_schema.customer_detail where identifier like :cust_id and first_name like :firstname and last_name like :lastname and mobile_number like :mobilenumber and email like :email</sql>
<result element="Customers" rowName="customer">
<element column="identifier" name="cid" xsdType="xs:string"/>
<element column="first_name" name="first_name" xsdType="xs:string"/>
<element column="last_name" name="last_name" xsdType="xs:string"/>
<element column="mobile_number" name="mobile_number" xsdType="xs:string"/>
<element column="user_status" name="user_status" xsdType="xs:string"/>
<element column="email" name="email" xsdType="xs:string"/>
</result>
<param name="cust_id" sqlType="STRING"/>
<param name="firstname" sqlType="STRING"/>
<param name="lastname" sqlType="STRING"/>
<param name="mobilenumber" sqlType="STRING"/>
<param name="email" sqlType="STRING"/>
</query>
<operation name="select_customer_details_by_any_parameter_operation">
<call-query href="select_customer_details_by_any_parameter">
<with-param name="cust_id" query-param="identifier"/>
<with-param name="firstname" query-param="first_name"/>
<with-param name="lastname" query-param="last_name"/>
<with-param name="mobilenumber" query-param="mobile_number"/>
<with-param name="email" query-param="email"/>
</call-query>
</operation>
</data>
Eg. If there is a customer with customer_id=110,first_name=abc,last_name=xyz,email=abc#some.com,mobile=<<blank>>,status=active
And if i retrieve the above customer via dss in try the service option, i get following output with no details of customer
<Customers xmlns="http://ws.wso2.org/dataservice"/>
The query you wrote requires that all parameters be present. Perhaps it could have been named "select_customer_details_by_every_parameter" instead of "select_customer_details_by_any_parameter". :)
In WSO2 DDS, You can define multiple data service queries for each datasource, each with different parameters. It appears that you only have one query, and one operation that takes every parameter. I recommend writing multiple data service queries for your datasource, including one with only the primary key fields in the where clause. That should allow you to retrieve the rows that have other empty columns.
Cheers,
Colin
I have created a simple dss service which by inputing cust_id it gives me the customer data.
I have exposed this webservice as http get resource with the following url
GET /services/getCustDetailDSS/getDetail?cid=101
Corrsponding xml code for my service is as follows
<data name="getCustomerDetailDSS" serviceGroup="" serviceNamespace="">
<description/>
<config id="mydb">
<property name="carbon_datasource_name">mydb</property>
</config>
<query id="get_customer_detail" useConfig="mydb">
<sql>select identifier,user_status from customer_detail where identifier = :cid</sql>
<param name="cid" paramType="SCALAR" sqlType="STRING"/>
<result element="customer">
<element column="identifier" name="cid" xsdType="xs:string"/>
<element column="user_status" name="status" xsdType="xs:string"/>
</result>
</query>
<operation name="get_customer_detail_operation">
<call-query href="get_customer_detail">
<with-param name="cid" query-param="identifier"/>
</call-query>
</operation>
<resource method="GET" path="/getDetail">
<call-query href="get_customer_detail">
<with-param name="cid" query-param="cid"/>
</call-query>
</resource>
</data>
But now i want the dss service to read cust_id from url instead of passing it as a parameter.
i.e i want to hit dss service as
GET /services/getCustDetailDSS/cid/101/getDetail
How can i do this in DSS ?
Can anyone provide wat changes i need to do in my dss?
For GET /services/getCustDetailDSS/getDetail/cid/101
You have to edit your resource path as follows.
<resource method="GET" path="getDetail/cid/{cid}">
With WSO2 DSS 3.2.1, you can now define your query string parameter as below:
<param name="cid" sqlType="QUERY_STRING"/>
instead of:
<param name="cid" paramType="SCALAR" sqlType="STRING"/>
and your URL should look like:
.../getDetail?cid=101