I have an API in nodejs producing messages using the bull library, but instead of consuming using nodejs I would like to do a test consuming these messages in c#
does anyone know how to do it?
Related
I'm in the process of writing a C# equivalent of a Java web service client. Like the Java logic, the C# logic interacts with a web service.
In the Java world, I would test this by using something like jersey to host servlets that mocked the API and recorded interactions with the API client. Is testing in C# a similar process? If so, what how do I do this?
I have some C# code that uses the ExchangeService (via Microsoft.Exchange.WebServices.dll) object to do some typical email tasks (e.g. fetch email, send email). I'd like to be able to do the same thing, but using Go instead of C#. What is the most direct way to do this? I understand there are tools such as CGo but given that this is MSFT-provided DLL that is part of the .NET framework, I suspect the process is not as simple as it would be if I were creating my own DLL.
You have to roll your own SOAP requests to EWS. The managed/.NET EWS API is just a nicely packaged set of SOAP requests.
You can only use the managed .dll with a .NET language, i.e., C#, PowerShell, etc. If you are not going to use a .NET language then you have to construct your own SOAP requests for EWS to consume.
FYI, if this is an Exchange 2016 environment you might want to look into the Exchange REST API which is language agnostic.
I am working on https://github.com/mhewedy/ews can be a good start.
I'm developing a SMS sending and receiving application using EasySMPP library. So,I was able to send sms using this library but I can't receive messages using EasySMPP library. Because I can't find a methods for SMPP message receiving in EasySMPP, I'm trying more than 1 week to do it. But,I couldn't succeed yet. Please anyone know how to overcome this problem, let me know.
Finally, doing months of research I found a .net SMPP library for which can be used to send and received messages via SMPP protocol. The library link is https://www.tops.com.pl/en/smscc/
That is very easy to use library and sending messages at high speeds.
InetLab provides a high level library for receive/send SMPP messages. There are useful examples also illustrating how it works. Whole library needed to buy if you want to edit SDK code.
I have a C# application and a Node.js application. I would like to press a button in my C# application to send three arguments to a Node.js application/function as input. Is this possible?
Edit: Both applications run on the same machine. The C# application would provide three arguments to the Node.js application. The Node.js application would query a web service (POST), receive some XML data, and manipulate that data. I know that I could do that task in C# too, but in this case it has to be Node.js.
Edit #2 and solution: Right now I have chosen: 4. Your node process runs a socket server and your C# app does requests over tcp.
I will also provide a solution that seems to work:
Node.js part
C# part
Now you are ready to send any data from your C# application to the Node.js server.
Yes communication is possible like several people have pointed out in your question's comments.
These are (some of) the options:
Your node process runs an http server and your C# app does JSON Rest requests over http
Your node process runs a SOAP webservice using the node-soap/strong-soap module
C# app starts your node app and you do IPC by writing to the node process inputstream and read it's outputstream.
Your node process runs a socket server and your C# app does requests over tcp.
You use a 3rd process/server like Redis or a Message Queue
Anything that allows you to share data like files..
I would recommend you go for the first option as that doesn't require you to define a language protocol to send over the "wire". The other reason would be that there is a lot of documentation available on doing Rest with C# and node.js.
As the client library in C# I would suggest you have a look at Restsharp as the client library if you can't use the latest version of .NET (4.5). If you can use the latest version, use HttpClient to call your Node.js restservice.
For Node just use Express.
Option 2 might be quick as there is good support in VS for webservices, however, I have only used node-soap as a client so can't comment on how well the node-soap webservices are with C# clients.
Manually handling inter-process communication is time-consuming and the old alternative to that, Edge.js, has not been updated since mid 2017.
My organization maintains a library, Jering.Javascript.NodeJS, that allows you to call into Node.js from C#.
Example usage
string javascriptModule = #"
module.exports = (callback, x, y) => { // Module must export a function that takes a callback as its first parameter
var result = x + y; // Your javascript logic
callback(null /* If an error occurred, provide an error object or message */, result); // Call the callback when you're done.
}";
// Invoke javascript in Node.js
int result = await StaticNodeJSService.InvokeFromStringAsync<int>(javascriptModule, args: new object[] { 3, 5 });
// result == 8
Assert.Equal(8, result);
You can invoke any valid Node.js module, including one that performs tasks like those listed in the question: querying a web service (POST), receiving XML data, and manipulating that data.
Highlights
Cross-platform support
Targets .NET Standard 2.0 and .NET Framework 4.6.1.
Tested on Windows, macOS and Linux.
Performance features
Does not start a new Node.js process for each invocation. Instead, sends invocations to long-lived processes via inter-process communication.
Optionally, runs invocations concurrently in a cluster of Node.js processes. Handles load balancing for the cluster.
Caches compiled javascript where possible.
Long-running application support
Restarts Node.js processes if they terminate unexpectedly.
Optionally, restarts Node.js processes on file change.
Kills Node.js processes when their parent .Net process dies.
Flexible API
Exposes both a static API and a dependency injection based API.
Supports invoking javascript in string form, Stream form, or from a file on disk.
What im trying to do is a little different, im wondering, if its possible to create sorts of an interface, so that if a particular function is called in php (stand alone), than the arguments will be forwarded to a method in C#, and vice versa.
Depends of course on what kind of data you want to exchange, if the applications are on the same server or on two different ones etc.
I did briding between PHP and C# in some of my web based projects. What I did: create an ASP.NET MVC project which exposes a RESTful API. The methods exposed by this API are then called from PHP via HTTP (using CURL). I used JSON as a data exchange format to pass data from PHP to C# and back again. This worked good as the two applications were on different servers.
I could also imagine some kind of socket server. E. g. a background process written in C# is listening on some port, and then you connect to it via PHP´s socket functions. I did something like this to connect PHP and Java. The Java app ran as a demon process on port XXXX and was a wrapper around Apache FOP. I used PHPs socket functions to pass XML and XSLT to the Java demon which then used Apache FOP to transform the data into a pdf and returned that via the socket connection back to PHP which in turn sent the PDF file to the client requesting the page.
There are probably some other approaches, but these were my experiences so far in connecting two different technologies together.
EDIT: as an aside: PHP on a windows webserver using IIS was really not that nice to work with. Sometimes strange errors occured or certain permission related errors that were not easy to resolve. YMMV though.