My web service get a SOAP request from user. After doing all the stuff in service could I send back the user response and then run some code ?
Actually I want to log the output of my service. If I run the code that logs the output and if that logging service fails, I could not send back any response due to that error.
IS there a way that I send user response of my service and then run logging service after that ?
I tried close method of SOAP handler but it runs before my service has returned response.
Essentially you need to find a callback (http://cleancodedevelopment-qualityseal.blogspot.co.uk/2012/10/understanding-callbacks-with-java.html) you can hook into after the http response has been accepted back from the server.
See here for a similar question: SOAP web service callback architecture? that was answered.
You should use callback function to sure that responsing is finished
Use try-catch to control the errors in your code. For your case you can control if your logging service fails or not and send the response to user.
Exceptions try
If you want to use something more complex you can use an async approach using queues or events.
in JEE you can use "#Asynchronous" annotation for the method that need to log. It will run asynchronously, so it will not block the return of the webservice.
If you need the result of that method, you will need manage to store the reference of the Future, for example in a singleton, then get the esult in a second Webservice call.
Related
To give you a background, upon receiving a request we want to extract the payload along with other information like request URI, query parameters, etc. and put it as a message in a Message Queue. Another service will then pick messages and invoke Katharsis so that the proper Controller will process the request. This is to create an asynchronous processing mechanism.
Now to invoke Katharsis manually we need to implement KatharsisInvokerContext which requires to create HttpServletRequest and HSResponse. However, since this is happening in the server we want the response goes back the the original requester.
Does anyone know how to do this or whether we are doing it wrong way? I'm open to suggestions.
We are using Spring Boot, Katharsis-core 2.0.1 and Katharsis-spring 2.0.3.
I'm running a multi-threaded load test using SoapUI open source edition. I'm testing an asynchronous web-service. I send requests to the service via SoapUI, these requests are queued for later execution, and the web service sends notification responses later.
I'm using a MockService to capture these notification responses. I now need a way of mapping each response back to the request that SoapUI originally sent out so that the latency from request to response can be tracked. To do this, I was going to define a ConcurrentHashMap. The test step that sends a request would update the hashmap with the request id and current time. When my MockService receives a notification response it would access the hashmap to get the start time of that request id.
The problem I'm facing is that I would need to declare the hashmap in a scope where all the threads access the same hashmap and the MockService also has access to it.
If I declare my hashmap in a groovy test step, then each thread when executing the test step would create its own copy of it, which is not what I want.
My question is whether there is a way in SoapUI to declare my hashmap at a "global" scope so that all the test threads (and my MockService) can access the same hashmap instance?
I tried declaring it in the setup script of the TestSuite and adding it to the TestSuite context but that doesn't seem to be working.
Can someone help with this?
I am trying to consume IBM BPEL web service, which is published on a live server and consumer using core java, working fine but the code have a warning message:
Dec 10, 2013 10:18:31 AM
com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
WARNING: SAAJ0014: Invalid reply message. Content length of reply was
zero.
NOTE: As designed this web service does not reply anything (response is empty). How can I disable calling party SAAJ client not to expecting a reply from the web service response?
I suppose that BPEL has nothing to do with the web service part. From your message I understand that when you call the web service from your client, the response is empty. Therefore, the probable cause could be in the following points:
The specific web service function gets nothing from the business logic layer to return.
You have to debug using breakpoints to find if this is true.
The web service function gets something from the business logic layer but it returns nothing due to an error in the specific function. You have to debug using breakpoints to find if this is true. Maybe the flow control of the function has a bug. Or maybe a data serialization exception throws and gets lost.
The web service endpoint is not configured properly. Double check the web service endpoint configuration. IP, port, credentials, authorization. Perhaps the web service is configured to return nothing when an anonymous user is calling it.
The client calls another endpoint. Double check that the client executes the correct request. Try using another client (eg SOAP UI) to see if it gets the same response. If the response is not the same, then the problem is on the client side.
You have the setup and the code, so you have to find out what is going wrong.
Hope I helped!
I am wondering how to call a RESTful web service asynchronously? Any suggestions?
Since REST is based on HTTP, which is a synchronous request/response protocol, your only alternative is to wrap it in an asynch call on the client side.
Two possible solutions, depending if you want push or pull.
1) The caller can add a callback URL in the request HTTP header. This URL will be called by the service when the process is finished.
2) The service can add a process URL in the answer HTTP header. the caller can thus get information about the advance of his request and get the result when it is done.
You could always use client side code to async the sync call for the RestFul Web Service Call.
I am wondering how I can use google protocol buffers to accept a request and send a response back to a client? I am thinking about writing a servlet which will take a request.
Is the following trail of thought the correct way to implement this:
1. Have a .proto file which is the message definition for the incoming request.
2. Write a servlet which accepts this request, does various tasks like querying database
and then sends a response. Will this response require a separate .proto message definition with all the fields that make up the response?
3. Will the client just invoke the doGet() method of my servlet and pass the request, it should then return a response as a protobuff object?
Any suggestion or idea will be very much appreciated.
Typically you'd want a request message and a response message, yes. You'd also probably want a method name to describe the action - that's certainly how the built-in PB services work.
The client wouldn't invoke doGet() - it would make a request (probably a POST rather than a GET) and your servlet would receive it.
Now, ideally you could have a general "ProtocolBufferServlet" which could service the requests by handing them off to services implementing the appropriate interfaces.
I suggest you look at the documentation for Protocol Buffer services and the Java services generated code for more information. You could implement an RpcChannel which worked over servlets, or get the client to make the HTTP post directly. You'd probably use dependency injection of some kind at the server side to tell the servlet what was implementing the service.
HI,
I have this up and running. I ended up posting a http request as a post to my servlet. I was able to take the request protocol buffer, read the request, do some processing and then send back a response. It was actually really simple once I got it working. We used the 1 .proto file to define the request and response message structure.