Is it possible to make Spring MVC not to send an answer back to the client? - spring-mvc

I am working on a Stub of a microservice with which the Network Function under test communicates via a REST API. The stub is developed with Spring MVC (Spring Boot 2.5.0)
Under certain cirtumstances we need to provoke an absence of reply from the stub to the NF. And here is where the question comes: how to sneak into the Servlet to block the reply back to the client? If that is even possible.
I have been for a while googling but I haven't found anything being really of any use. Before digging more into the framework I am making the question in case someone has had to solve this problem before.
If it is, any hint that we can use to work on the solution would be appreciated.
Thanks!

Related

Invoke web service method without waiting for it to finish

I have ASP.NET 2010 (VB.NET) web-service having a method "Method1".
I need to invoke that method from Windows application (VB.NET 2010) without waiting for the method to end execution, also do not need to get the return value of the method. Just need to invoke it and that's all.
What is the best way to do that?
If you edit your question giving more information about your needs, maybe some code that you're pretending to use, it should be easy to help you.
So, without that information I can assume that maybe investing about asynchronous methods should be helpful for you. It's not just about put async keyword...
You can find more information from here:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/5179579a-492b-4aad-babe-fdef854b68b3/c-50-calling-a-method-without-requiring-to-wait-for-it-to-finish-nor-its-results?forum=csharpgeneral
Hope to be useful... Greetings.

Check if a webservice exists

Could someone please be kind enough to show me the best way to determine if a webservice (ASP.NET) exists at a given URL?
I assume an approach will be something along the lines of issuing a request using System.Net.Webclient but how could I determine if it is a valid webservice and what sort of request should I issue?
EDIT: To add a bit more context I am determining if a webservice exists because I am attempting to build a generic tool that uses arbitrary webservices.
The only way IMHO to be sure the service is up is to be able to call an innocuous method on the service and verify the response. Retrieving the WSDL is not sufficient.
There is a similar SO question on this here:-
How do I test connectivity to an unknown web service in C#?
I would ask for WSDL document. If you get it back it means that the service exists and you can check to WSDL for implemented methods.
Consider reading about WS-Discovery
http://docs.oasis-open.org/ws-dd/discovery/1.1/wsdd-discovery-1.1-spec.html

Seam JBoss Servlet injection

I am a beginner creating a SEAM (2.2) application with JBoss AS6
I am integrating the Paypal express checkout code which acts as an http servlet, this seems to work ok with the payments processing correctly by paypal, the problem is I cannot seem to inject my stateful backing beans into the servlet to verify the payment and update the database on my side. I have tried a variety of methods including the following...
#In PaymentBean paymentBean
PaymentBean paymentBean = (PaymentBean) Contexts.getConversationContext().get("PaymentBean")
paymentBean = ((PaymentBean)Component.getInstance("paymentBean"));
In each case I am left with a null pointer exception, I dont think its a problem with the bean as it wont even inject the messages files
As I have seen a lot of similar issues I am not even sure if this is possible with my setup? Is there some further configuration I am missing?
Can somebody suggest a solution, or a way to access my backing beans from the servlet?
Thanks
It turns out the answer to my question lives here...
http://seamframework.org/Documentation/ReplacingServletsWithSeamResources

How can something like BOSH be implemented using Java Servlets

BOSH (Bidirectional-streams Over Synchronous HTTP) is a sneaky way of implementing 2-way client-server communication in situations where true server-push is not allowed, most obviously to let a server push data to a browser client without having to use client polling.
It works by the client sending a request to the server, and the server doesn't respond immediately... rather it remembers the request but only responds when it has some data to send. When this happens the client immediately sends another request so there is virtually always a 'stored request' sitting on the server ready to push data to the client.
At least, that's how I think it works!
Update:
My question is how you can do this using a Java EE stack i.e standard servlets. Is this possible using say Servlet 2.x (I'm a bit rusty so I don't know if you can decline to send a response or something) or only using extensions through a wrapper like Atmosphere?
Not an equivalent but Servlet 3.0 introduces an Asynchronous API. With or without Servlet 3.0, there is also Atmosphere.
See also
Servlet 3.0 Asynchronous API or Atmosphere? Easy decision!
Asynchronous HTTP and Comet architectures
Jean François Arcand blog (the author of Atmosphere)
I think this is what you might be looking for: http://blog.jwchat.org/jhb/
Maybe you are looking for something like comet, a kind of reverse AJAX in which the client initiates the connection, allowing the server to push data when it wants.
EDIT: I realize you are looking for solutions in Java and when we think of AJAX we immediately think of JavaScript, but the term has been tainted lately and it represents a concept more than a JavaScript solution. Comet is very much a concept like AJAX and can also be implemented in the programming language of your choice.

Are WCF request handling Thread Agile?

I have seen lots of documentation on how Agile Asp.Net Request handling is? I want to know is the case same with WCF Request handling. Can we rely on the fact that the Thread that starts Wcf request handling will finish it?
I am maintaining a Wcf Application where at lots of places ThreadStatic variables are used. Although the code is working but is it reliable? Is it worth changing it or should I keep it as it is?
When creating a WCF service you can set the threading and service instantiating behaviour, by decorating the service implementation class with a ServiceBehavior attribute:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single)]
class SingleCachingHttpFetcher : IHttpFetcher
The above code snippet is from http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.concurrencymode.aspx
EDIT
I dit a bit more research and found this article: http://blogs.microsoft.co.il/blogs/applisec/archive/2009/11/23/wcf-thread-affinity-and-synchronization.aspx. It basically says that no, you cannot be sure that the same thread starting the request will be the one finishing it.
EDIT 2
This question has been discussed before at StackOverflow. It links to How to make a WCF service STA (single-threaded) where there is a description on how to create an OperationBehavior which will force a single threaded apartment. The example deals with calling GUI components, but it should work for other single threaded requirements as well.

Resources