CQRS, Commands, Javascript - javascript

I have an architecture where a task-based UI passes commands to a service layer. Now, my intention is to implement the UI in javascript, using KendoUI and the service layer, domain layer etc. in .NET. I'm also looking at future mobile implementations of the client that may use say Java rather than Javascript.
If I define the commands in .NET, I'd like to know how to use them from my Javascript client so the client can communicate the commands appropriately to service layer. Do I have to use something like Apache Thrift for this i.e. to define the commands at both the client and service layer?

Since you use .NET have a look at this blog post I wrote, it uses t4 templates to render javascript objects of the C# Command/Query classes. The benefit from this is contract safty and code completion
http://andersmalmgren.com/2014/02/05/typed-javascript-contracts-using-t4-templates/

Typically, a service layer implemented with .NET cab be exposed as an HTTP API with which JavaScript communicates. The HTTP API implementation can be regarded as an adapter in a hexagonal architecture which relays all requests to application services, which in turn invoke commands on your domain model.
You may use Thift as an interface definition language to declare the messages that flow between client and server. Given, that the client is JavaScript based, you'd want to the JSON protocol which Thrift has support for.

Related

Server side for dojo-based+Qt5 application

I'm studing dojo to create web applications.
The HTTP server will be a Windows machine with IIS.
On the same machine will run my own Qt5 application to provide all backend logic for the web pages. I'm going to use dojo for them.
I wonder what is the best way to exchange data (JSON) between the client (dojo) and my application (Qt5).
In the docs I've learned how to use the AJAX methods to make HTTP requests (https://dojotoolkit.org/documentation/tutorials/1.10/ajax/index.html). But they rely on the HTTP server, instead I need to communicate with my Qt5 application.
What do you recommend?
Of course I'm trying to avoid (web)sockets!
The Dojo main modules for loading data in your application are based on AJAX, examples require, dojo.xhrGet, the content is actually in JSON format. Dojo has also support for restful service with module as dojo/store/JsonRest.
Dojo also offer you some support for socket using dojox
It really depends of the scope of your Qt5 application if you need bidirectional communication web sockets could be a reasonable solution.

How do I access printer SNMP data through JavaScript

How do I send and receive SNMP queries using JavaScript? I am trying to create a webpage for my employer that can query the company's printers and display toner and paper levels on the webpage. I don't have access to the webserver itself, so I have to implement something client-side using HTML/JavaScript/etc. I did some searching and it looks like JavaScript doesn't have any native SNMP methods or functions, and the JavaScript libraries that I've found (net-snmp, node-snmp-native, node-snmpjs, and several others) all require Node.js, which my company doesn't use.
This is an impossible request. SNMP is a network protocol. Javascript (client-side) has no socket support and can't communicate in any other protocol other than HTTP/HTTPS. The Node stuff is a whole different ball-game, because it's server side.
You can think of two solutions.
Use java snmp client libraries and java swing as front end.
Use Node.js server and snmp.js library.
Solution #2 is a long term solution and you will have more options here.This will give you web UI and it will be nice and useful for future.
Read What client-side web scripting languages are there other than JavaScript and VBScript?
You can find out other client side scripting options. For Perl/Python , you have snmp client library .
Other better option is , use VB Script and IE as client . There are VB Script snmp client libraries. This solution works only for IE.
Thanks

How to send message to JMS queue using javascript?

I have made a web-server using node.js, now on my client side (which I have made using java-script), when a user clicks send button, instead of a post request (XMLHttpRequest), I want to send the data to JMS queue. How can I implement that in javascript.
JMS is a Java-only API. There is no way to make JavaScript implement Java-API unless you actually run the JS on top of java (Rhino or whatever). But that does not seems to be the case here.
Theoretically - it's possible to implement a C++ wrapper using JNI to talk to java classes that can use JMS. That wrapper then has to be adapted to Node/V8 extension.. Well, it's a lot of error prone work. Don't go this way.
The solution is not to use JMS. Most JMS implementations (ActiveMQ, IBM WebSphere MQ, etc.) usually have multiple ways to communicate with it. Usually there is a C/C++ client that can be used by a Node.js extension.
There are also standardized wire-protocols that JMS brokers commonly supports that can be used with existing Node.js extensions. AMQP 1.0, MQTT, STOMP. Also, many message brokers have some possibility (addon or similar) to accept messages through HTTP.
So please explore what possible communication methods your JMS implementation has.
As a fallback solution, simply write a small java program that listen to HTTP and produces JMS messages that you can call from your Node.js app.

WIQL and other languages

Is WIQL specific to the TFS SDK or can it be used in other languages?
For example if I have built a client using TFS SDK that gets info about projects on the tfs, is it possible to somehow reuse the WIQL if I want to build a javascript client that does the same thing? Or is WIQL only used internally by the tfs sdk to create the proper soap request?
Your WIQL is processed on the TFS App Tier so, yes, you could conceivably write a Javascript client that sent WIQL queries to the server (in the context of a properly formed SOAP call). I wouldn't recommend it, however. The SOAP API for work item tracking isn't conducive to that approach.

Portable Javascript Client for a REST API

I'm about to create a JavaScript-based client for a RESTful webservice. The client should facilitate access to the webservice and wrap some raw HTTP calls into more "candy" functions and objects.
I'm intending to use this client library for node.js-based applications as well as for PhoneGap. So, I don't have to care about the Same-origin-policy. However, dispatching HTTP requests is totally differnt in PhoneGap and node.js.
Now I'm wondering how I can implement a client library in JavaScript, that is portable between different "platforms" (node.js, PhoneGap, perhaps later even browers)?
Thanks in advance
You might try this emulation of XmlHttpRequest under nodejs but you still may need to special-case your client library to operate under PhoneGap (and other browser-based JavaScript platorms) and nodejs.
One way to do this would be to check the contents of 'window' which is undefined by default under nodejs, or 'global' which is (should be) undefined in a browser.
EDIT
It appears I spoke(wrote) too soon. Check out abstract-http-request which while not explicitly supporting PhoneGap, might give you enough to work with.
Phonegap is basically just a browser. So if you want to get around the same origin policy you might want to take a look into different phonegap plugins (GapSocket) to handle your own communication.
REST is an architectural style for designing web services. A web service doesn't have to use HTTP to be RESTful, though a large proportion of them do. To be RESTful, an HTTP-based web service has to rigorously leverage HTTP's resource names (URIs), operations (GET, PUT, DELETE, etc), error codes (404, 200, ...), and so on. This means that any (HTTP-based) REST client framework can interoperate with any (HTTP-based) REST server framework: if it doesn't, something's probably wrong. So your problem decomposes into finding a good generic REST client framework and one or more generic REST server frameworks.
For node.js based web services, take a look at the Geddy server-side framework (here's the documentation).
For a PhoneGap REST client, you could try the Force.com JavaScript REST Toolkit (and see this extension).
Disclaimer: I have only read about these frameworks, not used them.

Categories

Resources