How to query a SOAP Service in Java - java

I would like to connect and query Trip Advisor's SOAP service. I currently have a WSDL for the service, and have connected to it using SOAPUI. I have been doing a lot of research about SOAP, but still am not sure I fully understand what I need to code in order to query the service as I would like.
The service takes an input of a simple place-id(I Have a list of many place-ids that I would like to query) Then it returns with the SOAP reply, which I would like to save as a new file(named place-id.SOAPrequest).
I have been doing reading on AXIS2, how to generate API code using SOAPUI, and launching a SOAP service in Netbeans.
I am currently trying to launch a AXIS2 service on my server, and then I assume load into it the java code that SOAPUI generating for the wsdl. But I don't know how to do this or if this is even the correct approch to the problem. Any suggestions or advice would be great.

See this step by step guide to Generate Java Axis 2 WebService CLIENT/SERVER

Related

Writing a simple java client which uses soap messages for bunch of provided WSDL and XSD files?

I want to write a java client to use some medical api. On there website they have uploaded a bunch of WSDL files and corresponding XSD files, along with documentation explaining the SOAP messages format to consume each service.
In past I have used REST API of Amazon and Azure to write java client but this seems to be different.
I have read about JAX-WS and also tried to create a dynamic web project in Eclipse using Tomcat but nothing working (https://wiki.eclipse.org/Creating_a_Java_Web_Service_Client).
Could some one explain me basic steps on how to write a simple java
client to **consume these WSDL and XSD files using SOAP messages** and
point me to really good tutorial where I can understand the underlying
concepts?
Till now:
I read about basic wsdl and xsd structure.
Tried to use Postman and SoapUI to make service call to these services.
But struggling to make first step towards making a simple java client project to interact with these services.
I would recommend you go check SAAJ API

Connect to SOAP using Java NetBeans

I can successfully connect to a SOAP service using SOAP UI.
However, I cannot find a good guide on connecting to the SOAP service using Java NetBeans where I need to pass username+password to SOAP, can someone suggest a good tutorial/guide for this purpose?
My example below that works with SOAP UI, but doesn't work correctly when I try to use Java like JAX WS...
See the SOAP UI screenshot here from dropbox: https://www.dropbox.com/s/3iwrees1ph36j0k/soap.png?dl=0
or Drive: https://drive.google.com/file/d/0B6qlCIai7vD3X05LMVA2YUo1ejQ/view?usp=sharing

WSDL2JAVA for simple http get on php page?

I have to request a PHP page with 3 Parameters (e.g. www.test.com/index.php?name=mrTest&no=1&id=10001). I'm using WSDL2JAVA for other Services and am now wondering if it is possible to generate a similar Service for this case. This PHP page Returns an XML. I'm just consumer/client of the Service.
I could also make a simple request and then use JAXB to parse the XML but i would like to implement all my Services the same way.
So, does anybody has already implement a php page consumer using WSDL2JAVA?
Best regards
So from my understanding this is a simple PHP page not a SOAP service. Remember XML is just the protocol used in a SOAP service however a SOAP service consists out of a WSDL that is published describing operations and how to call those operations.
A simple PHP page even if it returns XML data is NOT a SOAP service and thus does NOT have a WSDL. You wont be able to use WSDL2JAVA for that.
This PHP page seems more like a REST type service that returns XML instead of JSON. To be honest it really sounds like a REST service.
Try using the latest SOAPUI to connect to the page and see if you can use the REST project type with this page. If it is a REST service it might have a WADL file. YOu can use the WADL2JAVA cxf utility to generate classes to you. HOwever this is a BIG might as most REST services dont use WADL's yet. See this link on CXF

Using Java to connect to SOAP UI Mock Web Service

I have a mock web service running in soapUI 4.5.1 which looks up peoples names and addresses. I have a large dataset of names and addresses in a .txt file which I need to search for and verify with the web service.
The idea is to produce a count of the names which are valid and invalid.
I've created a Netbeans project to code a file reader to read in the text file and I need to connect to the web service to perform a bulk search.
Does anyone know a good tutorial to follow? Or suggestions of the best way to approach the problem? I've looked all over the internet, but I'm not too sure what I'm looking for..
Thanks!
Your requirement as far as I understand:
"Read a name and address from a text file and send them to a web service to verify"
1) If you DO NOT want to use a Java EE container then read this:
http://today.java.net/pub/a/today/2007/07/03/jax-ws-web-services-without-ee-containers.html .... as mentioned here jax-ws-web-services-without-ee-containers
The only difference in your case will be that you will use SoapUI to interact with the endpoint.
2) If you want to use a Java EE container, which is available free with NetBeans if you have the free enterprise download of it.
The way I will do it; I will have a web service running on a server. I'll connect to the web service from SoapUI. I will send a username/address and the web service will return something for example a string "valid" or "invalid". So the mock code is on the server not in soapUI.
Since you are using NetBeans, you should create a web service using NetBeans;
http://netbeans.org/kb/docs/websvc/intro-ws.html
Develop a SOAP based web service and connect to it with SoapUI. The web service is where your MOCK code will go, making it a MOCK Service which you can replace with real code afterwards.
You can put your file on the server or make it part of the application as a property file. In that case, create a web service on server that will verify the name/address list and send you back a count of valid and invalid.
If the data is too huge and you want to keep it on a local file on your machine, then you need to use jax-ws clients appraoch. You will read the data file in a class and then use the clients to send one at a time to the web service and keep a valid/invalid count.
........................

Remote Web Services

I am new to web services. I have a requirement in my project. I have to consume the web services of our vendor in my project. All he has shared with me is a WSDL file and a document about the description of the the different operations.
Question:-
1: What do I need to do consume these web services in my java project? I have been advised to use axis2, eclipse with tomcat6.
2: Do I need to ask for some other files/information from WS vendor OR wsdl file is enough to consume these web services?
3: Do I need to write a java WS client (using axis2 plugin) or another webservice which will talk to vendor web service?
Please suggest the best possible way.
I am sorry if the question sounds like a naive..
Axis is a solid choice for such application.
You need to generate an axis client based on the provided WSDL. Then you import the generated client and use it's methods. You can see the details of this process here (read whole page or starting from the linked section): http://ws.apache.org/axis2/1_0/userguide3.html#Writing_Web_Service_Clients_using_Code_Generation_with_Data_Binding_Support
You could also need some entry-point (WebService URL).
You need to generate a client, not a webservice. See point 1.
Don't use Axis if you need ambient authentication in a Windows environment. I went down that path and ended up going with Apache CXF - which seems better to me anyhow.
You can use SOAP UI to test the web service. It'll read the WSDL, let you create requests by filling in values, and display the response that you get back. It might help you get a better understanding of what the service does before you start writing your classes.
You don't need to create a new web service in order to consume a web service, you need to write a web service client.
Similar question to this one:
Steps in creating a web service using Axis2 - The client code
All the standard web frameworks have a command (normally called wsdl2java) that will read the WSDL and then generate a java based client object.
I can recommend Axis2, but another popular choice is CXF

Categories