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.
Related
I am using the CXF Web Client to call Soap Web Service.
WSDL2JAVA is used to generate Java Code from wsdl. There are information from the soap header but the generated code do not have method to access the header.
How can I get header information by the CXF Web Client?
try -exsh (true/false) as an option to wsdl2java
wsdl2java generate java code based on wsdl provided because the wsdl is the data contract between the producer and consumer.
If the consumer would like to get header information. The best is that the wsdl contains methods to get header data.
If the wsdl did not describe it, special handling may be required. You may directly get the header information by the response or by interceptors.
My way is that the interceptor capture the header information and then throws fault exception. The method catch the exception and then get the header information. It seems a dirty way but work for me.
I am working on a SOAP webservice. I am done with sending a SOAP request to get an XML response.
I don't have an idea of parsing the response SOAP message in a servlet or JSP.
Can anyone suggest a solution?
I would strongly recommend that you use something like JAXB to parse the response XML into plain Java objects that are much easier to work with.
In a nutshell, you just need to feed your webservice's WSDL file into JAXB, and it will generate a set of classes appropriate for the service's responses and a parser for handling the response XML.
Here's a brief tutorial if you're using NetBeans: http://netbeans.org/kb/docs/websvc/jaxb.html
Or if you're using Maven:
http://blog.dawouds.com/2008/09/maven-2-wsdl-to-java-using-jaxb.html
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
i want to invoke a web service based on the url and method name,when given the input parament in xml format ,i need to invoke the web service ,but i can't generate the client stub using tools like wsdl2java because the url and method name are given dynamically so these class aren't compiled.
for example,http://localhost:9090:/hello?wsdl there have a method
string sayhello(String []names); the input param likes <arg0>john</arg0> <arg0>lucy</arg0>
it seems that i need to generate soap request in code so is there any library can help me do this?
thank you for giving any recommendation!
That's possible and yes, you will need to generate the SOAP request yourself and also parse the reply yourself.
Some links to help with this including source code etc.:
SoapUI (complete source code of a generic SOAP client including a nice UI)
http://anshu-manymoods.blogspot.com/2009/10/how-to-simple-generic-soap-test-client.html
http://www.java-tips.org/other-api-tips/httpclient/how-to-send-an-xml-document-to-a-remote-web-server-using-http-5.html
http://biomoby.open-bio.org/CVS_CONTENT/moby-live/Java/docs/soapServlet.html
http://www.soapuser.com/ngx_22jul01.html
IF JavaScript is an option you can check this out...
There's SAAJ but it's pretty verbose.
If you can use Spring, Spring-WS has a number of client options.
You can always just build up the XML by hand, too (and parse the returned XML).
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.