I want to call the standard "Contact" Seibel Business Service from my java program. I will appreciate if you can point me to some resources on the same.
Thanks.
There are bunch of documentation and samples online.
You need to replace the Echo service by the Contact service.
I post just an example from Oracle website below:
Aside from the business object and business component API, the primary
point of integration with the Siebel application is by using business
services. There are several ways to invoke a business service. The
simplest way is using the Siebel Java Data Bean directly, as shown in
the following example.
Alternatively, Siebel Tools provides a Code
Generator which creates, for any business service, Java classes that
invoke the business service. The generated code may invoke the
business service either using the Siebel Java Data Bean or using the
Siebel Resource Adapter. The creation and use of generated code is
described in the next section. The Siebel Resource Adapter is part of
the Java EE Connector Architecture, which is described in About the
Siebel Resource Adapter. The following is an example of invoking a
business service directly using the Siebel Java Data Bean.
import com.siebel.data.SiebelException;
import com.siebel.data.SiebelPropertySet;
import com.siebel.data.SiebelService;
public class BasicDataBeanTest {
public static void main(String[] args) throws SiebelException {
SiebelDataBean dataBean = new SiebelDataBean();
dataBean.login("siebel://mymachine:2321/siebel/SCCObjMgr_enu", "USER", "PWD", "enu");
SiebelService businessService = dataBean.getService("Workflow Utilities");
SiebelPropertySet input = new SiebelPropertySet();
SiebelPropertySet output = new SiebelPropertySet();
input.setValue("Please echo this");
businessService.invokeMethod("Echo", input, output);
System.out.println("Output: " + output.toString());
}
}
Related
I'm working on a framework that has a Spring Boot Java layer and a C++ layer that contains the core logic. The C++ layer is modular such that many services with unique responsibilities and commands share common components, including a command processor. The command processor communicates with the Java layer (which is also the same for all services) via Thrift RPC.
Currently, users execute commands through a single executeCommand REST endpoint at the Java level by specifying a command name and set of parameters.
POST http://localhost:8388/framework/executeCommand
JSON Body {"commandName": "aCommand", "parameters": {"param1": "value1", "param2": "value2"}}
Is there a way to dynamically generate REST endpoints based on the set of commands provided by the C++ layer? Ex... each command would have an endpoint such as
POST http://localhost:8388/framework/aCommand
JSON Body {"parameters": {"param1": "value1", "param2": "value2"}}
OR
GET http://localhost:8388/framework/aCommand?param1=value1
Ex... at startup, the Java layer would query the C++ layer for the set of commands and other relevant information such as the appropriate REST method. With this information the Java layer would generate an endpoint for each command.
Thanks!
You could use a path variable in your REST controller to accept different command types, something like so:
#RestController
#RequestMapping("/command")
#RequiredArgsConstructor
class CommandController {
private final CommandService commandService;
#PutMapping("/{commandType}")
public CommandResult handleCommand(#PathVariable("commandType") String commandType,
#RequestParam Map<String, String> params) {
return commandService.execute(commandType, params);
}
}
(Here CommandService is a service that loads available commands at startup and then validates and executes a requested command).
You could then run a command with a request like PUT http://localhost:8080/command/someCommand?param1=value1¶m2=value2
UPDATE
Some solutions for the clarified requirements (dynamic REST controller creation):
https://github.com/tsarenkotxt/poc-spring-boot-dynamic-controller
Make #RestController at runtime
Spring boot runtime add controller?
I am totally new to the whole Google Cloud Endpoint/Google App Engine world. If you have gone through the Hello World example that Google provides(and you probably have), you might remember that there are 2 classes that are auto-generated for you: MyBean and MyEndpoint.
These are something like this:
/**
* The object model for the data we are sending through endpoints
*/
public class MyBean {
private String myData;
public String getData() {
return myData;
}
public void setData(String data) {
myData = data;
}
}
And,
/**
* An endpoint class we are exposing
*/
#Api(
name = "myApi",
version = "v1",
namespace = #ApiNamespace(
ownerDomain = "backend.myapplication.DJ.example.com",
ownerName = "backend.myapplication.DJ.example.com",
packagePath = ""
)
)
public class MyEndpoint {
/**
* A simple endpoint method that takes a name and says Hi back
*/
#ApiMethod(name = "sayHi")
public MyBean sayHi(#Named("name") String name) {
MyBean response = new MyBean();
response.setData("Hi, " + name);
return response;
}
}
Now, I examined the code in index.html(which gets opened on deploying the backend). I found the following call in the javascript:
gapi.client.myApi.sayHi({'name': name}).execute(
Now, I can see that myApi is the name through annotation and sayHi() is the corresponding method, What I don't understand is the concept of exposing an API and annotation is aiding in that. There isn't any information about exposing APIs.
Could anyone help me understand this?
I think your question can be divided in 3 parts:
1/ What is exposing an API?
Basically, you are offering an access to your business logic through an Interface (the API), with full control on what you want to show or not. This Stack Exchange answer is a great explanation: https://softwareengineering.stackexchange.com/questions/203844/what-does-it-mean-to-expose-something
2/ What are these annotations in the auto-generated endpoints class?
If I can summarize it like that, Google endpoint is a "framework" which generates "default" APIs based on your java beans. By default you get CRUD operations in the API, but you can modify and/or enrich the endpoint to offer more complex business logic. The Endpoints classes that are generated include specific annotations that are used by the framework (in particular while generating a corresponding servlet) and define the URI you will call to interact with the methods of the APIs. See https://cloud.google.com/appengine/docs/java/endpoints/
3/ What is this gapi.client call?
gapi stands for Google API Client Library. It is the library that is offered by Google to interact with Endpoints from a web browser. See https://developers.google.com/api-client-library/javascript/
You could use other methods to call the Endpoint APIs, like jquery Ajax methods (http://api.jquery.com/jquery.ajax/), since Endpoints follow the REST architectural style. Note that you can call your endpoints from other "clients" than a web browser, e.g. an Android or iOS App. In these cases, you would not use the Google API Client Library but some other libraries.
I hope this clarifies a bit. Do not hesitate to ask for more details.
I am new to CXF and hence kindly spare me if my question is too dumb.
I intend to develop a REST service using Grails which accepts a custom JAVA Object. Hence I intend to use grails-cxf plugin.
In my controller, I need a method (POST) which accepts a Java Object and return a Java Object
def UserDetails getUserDetails(User user)
{
// Logic
return new UserDetails();
}
I don't see any good example in the Plugin's documentation. I am not very particular about using this plugin. If you can suggest any way of achieving it with grails, its fine with me.
Please Help. Can we use grails-cxf pluggin to develop REST APIs ?
You have to define in the config.groovy where the cxf Plugin is looking for the Service.
Fore Example:
cxf {
servlet {
loadOnStartup = 10
}
servlets = [
CxfServlet: '/services/*'
]
endpoint {
soap12Binding = false
}
}
So the Plugin looks in the Service folder for some WebServices, but you need to define a Service as a WebService.
For your example the Service maybe looks like this :
class UserDetailsService {
static expose = EndpointType.JAX_RS
#WebResult(name = 'getUserDetails')
#WebMethod
UserDetails getUserDetails(#WebParam(name = 'user')User user)
{
// Logic
return new UserDetails();
}
}
I'm not sure if it works with the User Object, I never did that with an Java Object.
If it doesn't work you could use the UserId and get the User inside the method.
HTH
I didn't need a cxf pluggin to achieve Rest Service accepting Java Objects as arguements.
Command Object served my purpose
I am developing a web application using spring framework and google app engine. I am wondering if there is a design pattern or framework with the help of which I can develop features of my application as pluggable modules. For example I have identified 4 features of the application:
Oauth Login
User Profile Management
User Group creation
User File management
Now what I need is to develop all these features as independent modules, so that i can detach any of them dynamically and they are as loosely coupled as possible. They can have their own database implementation, their own set of technologies etc. Is there a design principle to implement modules in such a way.
You can take a look at MQ systems (such as RabbitMQ, ActiveMQ).
MQ system will work as intermediate layer, which provide you loosely coupling.
Communication between modules will be implemented as posting messages to queue and listening for posting.
Also, OSGI may help you. It gives you possibility to make your application as a set of pluggable modules, which might be loaded dynamically.
As per my experience, I suggest, Use MVC pattern. Use Servlet filttersfor 1.Oauth Login.
Create service/POJOs to implement and inject each other according to your requirement for
2.User Profile Management
3.User Group creation
4.User File management
If you know Spring AOP, use. So that you can achive more dynamic integration between implementations of points 2,3, and 4.
You should split the feature in two components: API and implementation. The first one contain interfaces, the second their implementations. You pass the interface to web app controller and inject implementation via Spring or any other Dependency Injection framework. For example
web-app, UserController which handles requests from client and delegate to your components
#Component
public class UserController {
private FileManager fileManager;
#Autowired
public UserController(FileManager fileManager) {
this.fileManager = fileManager;
}
#GET("/user/{userId}/file/{fileId}")
public File getUserFile(long userId, long fileId) {
fileManager.getUserFile(userId, fileId);
}
}
file-mgt-api where you define interfaces to decouple web-app from implementation
public interface FileManager {
File getUserFile(long userId, long fileId);
}
file-mgt-impl where all the details of how to get requested file
#Component
public class FileManagerImpl implements FileManager {
#Override
public File getUserFile(long userId, long fileId) {
// get file by id from DB
// verify that provided user is the file owner
// do other useful stuff
// return the file or throw exception if something wrong
}
}
Do the same for group, profile management and other features. After that you can easily replace implementation by replacing single jar file. Your web-app is completely decoupled and don't know anything about implementation details, it only depends on interfaces.
I have a collection of stateless scala/Java APIs, which might look like:
class UserService {
def get(id: UserIDType): User { ... }
def update( user:User): User { ... }
...
}
where User has a set of inspectable bean properties. I'd like to make these same APIs not only available over HTTP (which I know how to do), but also other, more performant non-HTTP protocols (ideally also running in the same process as the HTTP server). And more importantly, automate as much as possible including generation of client APIs that match the original Java API, and the dispatching of method calls following network requests.
I've found Spring's guide on remoting
However, this looks limited to HTTP (text not binary). What I'd really love is a library/other method that:
lets me scan for registered/annotated services and describes methods and parameters as data
lets me easily dispatch method calls (so that I'm in control of the sockets, communication protocols and whatnot and can chose a more performant one than HTTP).
i.e. the kinds of things that Spring's DispatcherServlet does internally, but without the HTTP limitations.
Ideas?
Background
I'd like to make a set of stateless service API calls available as network services with the following goals:
Some of the APIs should be available as REST calls from web pages/mobile clients
A superset of these APIs should be available internally within our company (e.g. from C++ libraries, python libraries) in a way that is as high-performance (read low-latency) as possible, particularly when the service and client are:
co-located in the same process, or
co-located on the same machine.
automate wrapper code for the client and server. If I add a method a service API, or and an attribute to a class, no-one should have to write additional code in client or server. (e.g. I hit a button and a new client API that matches the original Java/scala service is auto-generated).
(1) is easily achievable with Spring MVC. Without duplication of classes I can simply markup the service: (i.e. service is also a controller)
#Controller
#Service
#RequestMapping(...)
class UserService {
#RequestMapping(...)
def get(#PathVariable("id") id: UserIDType): User { ... }
#RequestMapping(...)
def update( #RequestBody user:User): User { ... }
...
}
With tools like Swagger (3) is easily achievable (I can trivially read the Swagger-generated JSON spec and can auto-generate C++ or Python code that mimics the original service class, it's methods, parameter names and the POJO parameter types).
However, HTTP is not particularly performant, so I'd like to use a different (binary) protocol here. Trivially, I can use the this same spec to generate a thrift .idl or even directly generate client code to talk Thrift/ProtocolBuffers (or any other binary protocol) while also providing to the client an API that looks just like the original Java/scala one.
Really -- the only tricky part is getting a description of the service method and then actually dispatching a method calls. So -- are there libraries to help me do that?
Notes:
I'm aware that mixing service and controller annotations disgusts some Spring MVC purists. However, my goal really is to have a logical API, and automate all of the service embodiments of it (i.e. the controller part is redundant boilerplate that should be auto-generated). I'd REALLY rather not spend my life writing boilerplate code.