Save generated Soap XML in database when sending request to remote WS - java

I'm using CXF to generate classes from WSDL in order for me to consume webservice. I need to save the requests if they fail and I'd like to save the SOAP xml that is sent, together with the exceptino error in my database.
How do I go about doing this? - I've done some searching and looking at the objects at hand while debugging, but nothing seems to give me the SOAP xml.
I didnt post any of my code as my problem isnt a specific coding problem, but more of a "how do I do X.." issue.

Related

Inspect SOAP message with SOAP Handler without making configuration

I need to catch all SOAP request messages. The purpose of inspecting SOAP request messages is reading specific value (such as IP adress).
I read this tutorial
http://www.mkyong.com/webservices/jax-ws/jax-ws-soap-handler-in-server-side/
But as far as I can understand, when I need to add handler on my project,
an annotation must be added like
#HandlerChain(file="handler-chain.xml")
And also handler-chain.xml must be implemented.
--
So, I'm going to implement a library to get all soap request IP adress and log them all. But if I use soap handler, I have to make some configuration on project that I added my library.
My purpose is creating Plug and Play library. If I add my library into a project, it must be start reading Ip adress from request message without making as above.
So, is it possible? How can I do it?
No it is not possible. Think about this logically. If your service does not make any call, does not create any objects (i.e. does not reference it the library in any way) then no code from that library will be run and therefore it will not be able to do anything. Using the message handler is the most minimalistic and least intrusive way I have found (and it is the way I do it) do handle such problem.

Is there a way to get the raw SOAP request from a SOAP based Web Service in a Java application

I am working on an application, that will pass client input to a vendor using web services. As phase I of the project, the vendor provided us with the XSD's and WSDL information. I used apache CXF to build the client jar. Now the issue I am facing is that, as part of the requirement, I need to send them the SOAP Request in an encrypted(I have taken care of the encryption part) XML file, that they will manually process, and send me back the response in another XML file that I need to parse and retrieve the response object.
Is there anyway to use the client jar in a dummy mode or something, where it looks like we are calling the client, but all we are doing is getting the raw SOAP request to a file
I kind of a hit a dead end and I am not totally sure how to proceed here, any help or suggestions would be appreciated
You might try SoapUI, it's a free web service testing tool. I know you can view the raw data of your soap request and response with it. soapUI

How can I send a GWT-RPC request with HttpClient?

I am using the Apache HTTPClient API to send HTTPRequests, and so far it's worked with standard requests. Now I want to send a GWT-RPC request and show the response, but I always receive the following error from the GWT-RPC server:
//EX[2,1,"com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException/3936916533","This application is out of date, please click the refresh button on your browser. ( Malformed or old RPC message received - expecting version 5 )"],0,5]
Actually, I have to send the following data with the request:
5|0|5|http://172.16.103.244:38081/kunagi/scrum.ScrumGwtApplication/|6E611C647A0C98D5A31A2506E16D81D6|scrum.client.ScrumService|startConversation|I|1|2|3|4|1|5|-1|
but I don't know how.
When I retrieve the request code from FireBug, I find the above data as a source in the post area.
Take a look at the gwt-syncproxy project. It does exactly what you are looking for, faking RCP calls from Java code. If you don't want to rely your project on gwt-syncproxy, you could look at it's implementation and find out how the create valid requests.

Extracting SOAP request from wsdl using wsdl4j

My inputs consist of a WSDL file and an operation name. I need to create a SOAP request and response XML instance after parsing the WSDL. What are my options to implement this? Which parser should I use? I tried wsdl4j. I was able to retrieve the Schema Object. But how do I convert this schema object to a SOAP Request in XML? I was not able to figure that out.
Did you try to use soapUI software ? I always used it in order to validate my manualy written SOAP requests (to a WSLD webservice), but it could give you the target direction
Try membrane SOA SOAP Model library.
Example code:
http://www.membrane-soa.org/create-soap-request.htm
Note: This is not a promotion. Membrane SOA is apache 2.0 licence project and I have no relation with it, except a user. Adding URL is only for helping.

How to match SOAP responses to the schema

Hi I am trying to evaluate a web service. I am using the Axis API to create the requests. I send requests with some attacks, and then want to validate the obtained response to the response schema. I don't have much idea as to how can I achieve this. Can some one help me to achieve this, or give me some pointers that would give me some idea to obtain this.
If you used the wsdl2java tool that comes with Axis2, the response message will be unmarshalled to the generated classes, and you will get an error if the reponse message does not correspond with the classes generated from the WSDL. So in this way you have a kind of implicit validation.
Jens-Martin is correct. If you're using the client generated by Axis wsdl2java, all the validation you need is happening behind the scenes. There are two kinds of validation going on:
SOAP has a schema definition, and the response must be a valid SOAP response or the client will throw an exception.
The WSDL you used to generate the client described what goes in the SOAP envelope of the response. If the response you get doesn't match, the client will throw an exception.
If you really feel compelled to write your own XML parser/validator and SOAP handler, you're on your own.
Try SOAPUI. It is quite a powerful open source testing tool for web services. You can construct test suites, do performance testing, and specify customized validation criteria.

Categories

Resources