Trace all RPC calls in C++ gRPC server - c++

I have a gRPC server written in C++ and I would like to trace or log all RPC calls to the server, including arguments and responses, if possible.
The Go gRPC implementation has the very helpful concept of an Interceptor that can be attached to a client or a server. The interceptor gets access to not only the metadata, but also to the arguments/responses. For the C++ API I cannot find anything similar.

What about https://grpc.github.io/grpc/cpp/classgrpc_1_1experimental_1_1_interceptor.html ?
The only usage reference I could find is this SO question: C++ grpc::experimental:interceptor how to return status and message from custom interceptor
EDIT: in matter of fact, I think this is a better resource - https://github.com/grpc/grpc/blob/7bf82de9eda0aa8fecfe5edb33834f1b272be30b/test/cpp/end2end/server_interceptors_end2end_test.cc
I think you can query the request & response messages from the methods argument of the interceptor overridden method Intercept(grpc::experimental::InterceptorBatchMethods* methods), see available methods and properties here: https://grpc.github.io/grpc/cpp/classgrpc_1_1experimental_1_1_interceptor_batch_methods.html

Related

SOAP Webservice call from Java gives "Object reference not set to an instance of an object"

I have a requirement where I call a SOAP based web service from Java using Axis2 from eclipse. The web service code is in C#, with a BasicHttpBinding.
But when I call the method from the client stub I get this error.
org.apache.axis2.AxisFault: Object reference not set to an instance of an object.
Could anyone help me figure out this one? Is this on the service side or on the client side? Previously I got 'Internal Server error' and then they had to add something so that I can see this error in the logs.
The message is from the C# web service side ("Object reference not set to an instance of an object" is basically a Java equivalent of NullPointerException) but it might be because of something you send from your Java client or maybe you don't send.
The error usually means that you didn't send a required parameter and that the web service didn't do a proper job of validating it's input and missing parameter got to a point when caused the NullReferenceException.
But there is only one way to be sure, and that is to troubleshoot the call.
I suggest you use something like SoapUI to create a message and send that to the service. Once you get a succesfull call in SoapUI, make a call with the same parameters from your Java client and see what happens. When you do that, using a proxy for logging is very useful to see if the sent message is actually the expected one.

PHP library similar to REST-driver in Java

I found this little library to be perfect solution for my problem. It allows you to stub REST service responses easily.
Now i need to replicate the same set of test cases in PHP version of our library. Do you know any similar library/framework in PHP?
You could use Guzzle. Guzzle is a PHP HTTP client & framework for building RESTful web service clients. The thing is that you can create Response objects. In this library, you have a Response class. You could just create the Guzzle Response that you want (choosing the desired status code, content, etc), and mock your HTTP Client so it returns the Response object that you just created.
If you read the documentation, it seems that there is a plugin to mock responses, although I've never used it.

Using mongoose to provide rest api for my C++ application?

I want to use mongoose for exposing rest apis from inside my aplication. However, I do not see any model of how this can be implemented.
Does anyone knows if it's possible of feasible to do using mongoose?
Can any exemple be provided demonstrating a simple case of it?
I've used mongoose to implement an HTTP interface to a Windows service in C++. It was fairly straightforward to wrap mongoose in a set of C++ classes. It's easy to retrieve request information and generate output streams. I used Boost.IOStreams to implement connection streams so that request handlers could use a std::ostream interface to write results back to the connection.
Use the set_uri_callback() function to define a handler for every possible request.
In each handler get the request type (GET, PUT, POST, etc.) and parameters.
Write the appropriate result back to the connection.

Asynchronous Webservice

I wanted to clear something about Asynchronous Webservices.
I read that weblogic give you the ability to create Asynchronous Webservices.
but I also read that it's only supported as log as the client and the server of the webservice both working under Weblogic container.
Is that true?
is it possible to create Asynchronous Webservices without having the need to have the same system(weblogic, jboss) both at client adn server side?
In case it's possible I would like to get details how is it working..
thanks,
ray.
Neither WS-Addressing nor Weblogic have anything to do with enabling async services. See the Asynchronous Client documentation for JAX-WS. There are two basic approaches supported: Static stubs and the Dispatch API. Static stubs require the use of customizations and will result in additional methods being added to the service endpoint interface. These methods expose both polling and callback functionality for async invocation.
I understood that I can invoke async webservice as long as both the server and the client supports: WS-Addressing specification.
ray.

Consuming SOAP web services without the add reference approach

I am looking to make a service agent in C# from scratch. If the contracts/XSD are shareable via WSDL or dll. How do I go about writing a light weight service agent that can be configured to make calls to the SOAP webservice. When you do an add reference I feel too much code is generated behind my back.
You can post data to a webservice using the following url structure:
http://mydomain.com/mywebservicedirectory/mywebservice.asmx/mywebservicemethod
Simply use an HTTP POST to pass data(typically xml/json) to the service and process the response.
I use a bassic soap template and XSLT to render it out for what I want. It isn't that fun if you need to call multiple methods. I'm simply calling the same method over and over so it's no big deal. Simple HTTP POST will do it, that's all WCF/ASMX does.
You can get the WSDL and use XSD.exe to generate the object classes for you.