Using Java to connect to SOAP UI Mock Web Service - java

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.
........................

Related

QuickBooks java SOAP Web Connector structure

i have inherited a java app that integrates with desktop QB. There's something in the structure of this whole setup i'm not understanding. This is my first go with the QB api as a developer.
the QB Web Connector 2.2.0.71 is installed and functional. I see the .qwc file and understand it, and it is loaded into the web connector. There is an Application class that publishes an endpoint to the same URL as in the .qwc file and then starts a class named QBWebService. this web service class implements com.intuit.developer.TroubleshootWebServiceFSSoap and has methods authenticate, sendRequestXML, etc. Method sendRequestXML has the code i am testing and attempting to modify. but, before i can do that i need to understand the XML going back and forth.
since i don't know what i don't know, if i'm asking the wrong questions, by all means, please say so.
is it correct, then, that the web connector (on schedule) launches the application class and calls the sendRequestXML method?
i was expecting to find a URL that i could send XML to with something like SOAPui in order to test the XML and examine the response, but that doesn't seem to be how this web service works. is it possible to set it up this way?
perhaps i don't understand what the QB web connector application is doing. what is the purpose of opening up the URL on localhost if it can't accept XML via POST?
thanks in advance for the help
--matt
is it correct, then, that the web connector (on schedule) launches the application class and calls the sendRequestXML method?
Yes, that's correct.
i was expecting to find a URL that i could send XML to with something like SOAPui in order to test the XML and examine the response
You can send requests to your SOAP service (e.g. you can call the sendRequestXML method for example).
You'll get back an XML response that (if you were the Web Connector) you would then relay to QuickBooks. QuickBooks would process the response, and then call the receiveResponseXML method to send the XML response back up to your web service.
perhaps i don't understand what the QB web connector application is doing.
It sounds like you're expecting QuickBooks to provide a SOAP endpoint, which you can then directly send XML requests to to query data directly from QuickBooks.
This is not really how the Web Connector works. The Web Connector sort of works "backwards".
Instead of connecting directly to QuickBooks, the Web Connector connects to you (your SOAP endpoint) and asks you "Hey, give me something to do!" (i.e. send me the request XML you want to run against QuickBooks). You then give it an XML request, which it runs against QuickBooks, gets the response, and then connects to you again and says "here's what QuickBooks responded to your request with" (i.e. here you go, receive this response XML from QuickBooks).
So the Web Connector essentially polls a SOAP endpoint you provide, asking you to give it XML requests to pass through to QuickBooks.
Longer explanation here:
http://www.consolibyte.com/docs/index.php/QuickBooks_Web_Connector_Overview#About_the_QuickBooks_Web_Connector

Creating a client for a existing web service out of a WSDL file with Java

I have a given WSDL file (a SOAP web service in the internet) and I want to use this service. For that I want to write a Java client, that sends the required datas (as XML) to the web service and the service itself sends an response.
Unfortunately, I am totaly new in web services. This is why I want you to ask for help.
I found a lot of ways to use SOAP in Java. One way is the AXIS2 framework from Apache, another way is the Eclipse Web Tools Project (WTP). I've tried both but couldn't get it run..
First of all.. What do I need to use such an SOAP web service?
I think:
- generate Java source out of the WSDL file
- write an client that uses this code
- with this client you can send datas to the web service (the client itself sends the data via XML) and the client can process the response
Am I right or do I have a fallacy?
Thank you for your help!!
I think: - generate Java source out of the WSDL file - write an client that uses this code - with this client you can send datas to the web service (the client itself sends the data via XML) and the client can process the response
That is correct. You can use Axis2 as you mentioned, write a JAX-WS client, you can even write the SOAP message by hand (not that I would recommend that though).
You should try to get a successful call from SoapUI first then write your client application. Use wsimport to get a simple client working (if that's all you need a framework like Axis2 could be overkill).

Call WebService method created with Netbeans and Glassfish from browser(localhost)

This may sound like a dumb question but i am new to web services.
I followed this tutorial and successfully created a Calculator web service up to the point where i created a local client application that consumed the web service method (A java class with main method which calls the web service method).
My question now is how can i access this method via my browser and set the parameters there, just get an XML/JSON result.
My guess is that i am missing something and i have to publish the web service somehow.
Any solutions, links are highly appreciated.
You have hosted your webservice on glassfish server. Now you want to consume it using internet browser like you did it using test webservice option in net beans.
That means you need to built your own client which runs on web browser.
You need to built a webpage having two input fields in it and a button as result and whenever you hit this button call your webservice and display it's result. You can follow any simple tutorial of web client or application and again you can deployed it on glassfish or apache server.
Also you can use soapui (a client to consume web services) to import your wsdl and access its methods, providing inputs and get result in form of soap.

Implement server and client

I need to implement a server that downloads a webpage and sends it to a client that saves it as a file.
On the server side I need to process socket.
So I was thinking about making a web service in java (with netbeans) but I don't know how to start the web service (I use osx lion).
How can I start the web service?
Is there another way to solve my problem?
Thanks
I'd strongly consider just using an HTTP-based RESTful client/server, using any of a million server-side frameworks. The server-side option may influence the client side implementation.
For example, you could use something like Jersey, which can also create the client-side library needed to consume your service.
On the server side I'd use something like HttpClient to retrieve the websites that will be returned to the client app.

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