How to write http url based web service in netbeans? - java

How can I write a web service where I can query in the URL with some parameters and display the result in the JSON format.
For example, There is a table AppInfo in my database which has two columns named AppID and Status
Now, what I want is to write a web service like that
http://10.11.201.84?q=Select+*+from+AppInfo+where+AppID='21212'&format=json
So, from a user, I will take the application id and get the status using this web service. I might have to use get method for using the HTTP URL request.
Which web service I have to use in this case and how?

I implemented the necessary http url based web service by this, I have used restful web service implementation
1) Create a Java Web Project and create a servlet
2) Connect with my Oracle database (using ojdbc 6.0)
3) Taking the query as a parameter in the url (as requirement) and then process the query (I used preparedStatement)
4) Getting the result of the query and Save it to json
5) Display the successive Json data in the browser and then parse the data json data to send back the response to user.
Thanks to all who guided me !!

I think you're looking for REST web service instead of SOAP web service.
You should take a look to this documentation : Building a RESTful Web Service

It's pretty simple (assuming you're having curent NB version)
Create a new project Java Web -> Web Application
In the project: New -> Web Service -> RESTful service
you have multiple options.. you have an empty one, from database, etc..

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

What is best way to configure soap based web services in HTML5 based apps

I am developing banking mobile apps using html5 for client as communicate back-end system they provided soap based xml services.
To make a soap request, i doesn't want to write code in ".js" file because of code complexity and not found request and response logs in production phases.
now i want to make separate project to maintain the web-service request and response business logic using java?
from .js, I want to make a http request to call the web service as a response i want to get json an object?.
Please correct me if i was wrong, Please help me how to separate web service logic into a single project?
Note: I doesn't want to configure my soap request through js file.
Regards,
nag
Write a servlet or httphandler(if IIS) that interacts with SOAP services and parses the information and creates a json response for the JS client.
You JS client interacts with servlet/httphandler and handles when it json response when it receives it.

HTTP response getting html response

response getting from server is html response. How can i know whether the reponse is correct? how can i check that in server?
These api urls corresponds to a REST web service and thats why when you call those urls, you are getting data. So you need to create your own REST service api for your site to fetch data first.
For creating dot net based REST Service, Use this link. For creating Java based REST service, follow this link.

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

How to create a web proxy service using a Java Program

I have a scenario where I am supposed to contact a RESTFul API which sends me a response in JSON. After I get the response I am suppose to store the data in the DB.
We use BPEL for our development. But, for clean development/deployment I am using Java for contacting the RESTFul API so that I don't have to handle any Java codes in my BPEL. So I wanted to create a web service proxy.
I have created a class which contacts this endpoint and gets me the response (JSON) and converts the response message(JSON) into XML.
Now, I want to create a Web Proxy service which I can host for this Java program that I have created. Is there any way that I can do this?
Thanks!
I got a solution to this. I created an intermediate webservice using java (using json.org library) for consuming the REST API and then giving my BPEL the SOAP response after parsing the JSON response.

Categories