Select between two webservices - web-services

it is possible to decide one or another webservice by a condition into a Phase?
I have 2 ws: ws1 and ws2.
I want to decide to call ws1 or ws2 depending of a boolean.

Yes as long as the client/web service contracts/schema's are the same. Just replace the URI with corresponding the ws1/ws2 endpoint.

Related

Same Endpoint for three different operations using GET RequestMethod in REST

I want to have the same Endpoint for three different operations in one Request Method type as GET in REST Controller in Spring MVC application.
For example three operations GET Request Method:1 . ListofItems, 2. LoadDropdown,3. searchoneParticularItem.
Endpoint 1:/items this end point I could use it to list the items
Endpoint 2:/items/{itemId} this endpoint I could use it to search particular object.
How can I get the third operation load the drop downs of items?
Please give me some example to have atleast three operations in GET with same Endpoint.
It takes String[] in value, it can handle multiple urls, use
#RequestParam(value=["mapping1","mapping2","mappping3"]);
#RequestMapping value attribute takes String[], so you can map multiple URLs to the same controller method as shown below:
#RequestMapping(value={"/listItems", "/dropdownItems",
"/items/{itemId}"}, method=RequestMethod.GET)
public String loadItems(#PathVariable String item, Model model) {
//add items to model
//return JSP or HTML
}
You can refer here

Can the PostgreSQL C API (libpq) allow you to use the result rather than store it?

When performing a query that returns data, the MySQL C API allows you to specify whether you want to "use" or "store" the result set. To "use" the result set means the results are only sent from the server to the client when requested (e.g., one row is sent to the client each time that row is accessed). To "store" the result set means the entire result set is sent from the server to the client "in advance". The former requires less memory on the client, the latter more memory.
Does the PostgreSQL C API provide similar functionality?
The answer to this question can be found here:
http://www.postgresql.org/docs/current/static/libpq-single-row-mode.html
... call PQsetSingleRowMode immediately after a successful call of PQsendQuery (or a sibling function).
Note that this is only available in PostgreSQL 9.2 or greater.

Usage of Id='' in EAI Siebel Adapter Query

Requirement: I am suppose to use an existing Integration Object for my requirement. As this IO consists of ICs that I do not need in my requirement, I would like to avoid them in my IO query output.
I observe that passing Id = '' returns no result in Siebel 8.0. Can I use it as a feature and pass SearchSpec => [Integration Component.Id]='' to EAI Siebel Adapter query to suppress ICs that I don't want in output?
How good is this query Id=''? Will Siebel ignore this query completely? or will it attempt and return no output?
As per my understanding Siebel ignores the query where row_id is passed as ''
(Not true for siebel 6.0) Please share your opinion.
Not sure of using Id = '', when you club the condition with other conditions, Siebel might try to find actual matching records. Also , not sure if future upgrading will keep the same system.
If yours is the only code using the IO, you could straightaway inactivate the ICs you dont want.
If you are unsure of IC inactivation, best way should be to a DatMapper. Set up an EAI Datamapper, source and target IOs of same name. In this datamapper, map only the ICs you need. After querying from EAI Siebel Adapter, send your output to this DataMapper.
Siebel will keep only the ICs mapped and remove all the rest.
Since this is a non-repository change, you can modify the DataMapper in future too.
Hope this helps !
Answering it myself with my opinion..
As per my understanding, querying with Id='' still queries the database for row_id = ''. Including this in IO query reduces the query scope to the parent's context..
Though this won't improve any performance, IO query output looks cleaner.
Update: I'm using a Indexed column based field Id (ROW_ID) with search spec as "[Id] IS NULL". It's a next to impossible case in database having ROW_ID = NULL, unless it's intentionally and manually updated. Again no one would do it unless really wants to messup that data .. because without ROW_ID record is literally invalid..
Adding a null query to the IC will inherently result in an empty property set for the IC in question. But if you don't need the IC, and the ICs in the IO are not hierarchically connected (no hierarchy key )(eg- independant BCs with same base table in the same BO), you just have to remove the IC mapping in the datamap editor and the IC wont show in the IO propset

Oracle Service Bus DB Adapter

I am trying to use Oracle Service Bus DB Adapter to create a REST based service. There are four paramters that get passed in the query out of which at any time only 2 are passed. For example:
http://www.example.com/findPerson/personId=&birthDt=&ss=&lastname=
birthDt is always passed, but only 1 of the other 3 are passed. The other parameters are empty.
For me to do a database lookup, all I need is birthDt and 1 of the other 3 passed.
Is there a way in OSB to do a conditional select based on what is passed in? Do I do a Select or "Query By Example" or "Invoke a stored procedure" that returns what I need?
In the response to the REST service call, I need to return several elements in an XML format.
You could create a stored procedure in the backend which has all the input parameters as input (and 3 of them have 'default null')
create or replace procedure my_procedure
(p_parm1 in varchar2 default null, etc ..
and in the stored procedure you check what parameters are filled to construct your select statement.
In the xquery on the osb you will need to check which parameters from your rest call are filled in, to map these on the optional parameters of your stored procedure call.
Or you can use the 'select statement' option in the db adapter and use some construction like this :
select *
from my_table
where kolom1 = :p_name or :p_name is null
Now you can expand the whole query based on the values of your input parameters
Also for this case you need an xquery in the osb which will 'map' your rest parameters to the select statement parameters.
Easiest way is i think to just pass on the whole query-parameter string into your xquery and use substring/substring-after etc to get the different parameters out of it together with their values and map these values to the input xml payload of your db adapter call.

rails: convert a string with regex and write to database

I have an application that accepts an address and writes it to the db. I then want to take that address and convert it to something I can send through Google Maps, so I need to replace all the spaces with "+" symbols. I understand how to do that with a regex:
address.gsub(/\s/, "+")
And can create a variable that does it, voila. But I want the converted address to live in the DB as well, so it doesn't have to be processed every time. I'm not sure how I process that when I'm creating the entry to begin with and save it to the db as a separate entity ("gmapaddress" or something).
Thanks!
given a table name of rails_db_table and columns userid and gmapaddress and instance vars #gmapaddress and #userid it's as simple as
UPDATE rails_db_table
SET gmapaddress=#gmapaddress
WHERE userid=#userid
of course a more rails way of doing this is with active_record that allows a construct such as:
#user.update_attribute :gmapaddress, #gmapaddress
#user.save