I'm absolutely new to GWT, java and eclipse, but I'm an experienced MS programmer.
I installed eclipse and GWT and created a default project (called it test2) with pre-built sample gwt code. It comes with one java web service on the backend called 'GreetingService' which has a single web method called 'greetServer' that takes a single parameter called 'input'. I tried to invoke it in the web browser with many different combinations, but with no success (my project name is called 'test2):
http://127.0.0.1:8888/test2/greetServer?input=hello
http://127.0.0.1:8888/greetServer?input=hello
http://127.0.0.1:8888/test2/greetingService/greetServer?input=hello
http://127.0.0.1:8888/test2/greetingService?input=hello
etc
but I get http error 404 not found.
My question is, how can I invoke the web service from a browser and see the return data? I know this can be done easily with WCF or asmx web services but I'm not familiar with java web services.
Thanks a bunch!
The GWT Remote Service Servlet only uses HTTP Post. If you want to see the data (which will be encoded by gwt anyway) use could use firebug and take a look at the traffic.
The greeting service isn't intended to be a web service. It's a demo of GWT's remote procedure call (RPC) facility over AJAX. As with most RPC frameworks, the server side is only intended to be called from the generated client stub.
Related
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.
I have created J2me application (prototype) and now I have to add web services to it which are written in .Net.
How to do that? I'm looking for the procedure for developing j2me client in which I can pass parameters which are similar as in .Net web service.
As the sreehari explained, first you need to have JAX-RPC API to include in your project. Once you have done that, the next thing comes, How to call web service.
Web Service can be created in any language like Java ( servlets ), PHP or .net, I have worked with all these three. for Java & PHP you can directly call the web-service, while for .net you need to create stubs.
Steps to create stubs. Once you create these stubs, you can simply call it like you call other methods in code and pass the argument ( if necessary ).
Also look at this quetsion How to use web service in J2ME application ?
You will need to use JAX-RPC API to create client for Web services. It doesn't matter in which language the service is implemented. I am not sure on limitations from a J2ME perspective.
I wrote a java web service on Netbeans 6.9.1 and deployed on GlassFish 3.0.1
I have a wsdl url like this "http://localhost:8080/web2/service2Service?wsdl".
How can I use this url to access this web service from another java application.
Thanks
You need to generate some Java that represents the client's view of the Web Service and then invoke that Java. Here's an article which explains some of the detail.
Generating client from WSDL in Eclipse
The general idea is that you generate some Java classes from the WSDL. Those classes act as a proxy for the service you want to call. Your java invokes methods on the proxy objects, the generated code creates the appropriate SOAP messages, sends the HTTP request, interprets the response and your code just sees a Java result.
I just use the tooling built into Eclipse, but you will also find other suitable generators, for example in Apache's Axis
1º U must save the content in a "myWebServices.wsdl" file
2º Run your Wsdl converter, all compilers have one of this, normally the name is WDSL.EXE
This process will create a new file with NameSpace or Package with the definitions of webservices built in.
3º Then imports this package or built a library.
Develop web service Client in second application.
You can use Netbeans to create web service client by giving your wsdl url
The document at this url is the actual wsdl (a description of the actual webservice, written in WebService Definfition Language).
The description includes information about the services url, the protocol(s), the method names and and data objects. Your application will use that information to call the remote methods of that service.
The protocol may or may not be SOAP, and without knowing the webservice details, it's quite impossible to recommend a toolset or methodology to use the webservice, there is no general approach. In most cases we see SOAP, for those services I recomment soapUI as a general tool to use and test SOAP based webservices and apache axis to implement java based service consumers.
I'm developing a Web Service Project in which I have to implement a web service that should be interoperable on all platforms. So initially I used basicHttpBinding as it uses SOAP 1.1 but I want the features of WS-* like reliable messaging, security, exceptions. So I used wsHttpBinding which is a SOAP 1.2 standard.
Now after deploying on my test server I used Netbeans IDE to generate a webservice client. So in return it called the wsimport tool in java to generate proxy classes. When I invoke any method it simply goes into non-working state like there is no activity for 5 mins. So I'm not able to figure out that whether Java client can consume a SOAP 1.2 web service created in WCF?
I need to know if I need to use any other binding than wsHttpBinding for all the features and have interoperability as well.
I don't get any error when i invoke the web method.I tried debugging it but to no help.i set break-point on the line which was invoking the method,when debugger reaches that line then nothing happens, IDE shows running status but there is no activity.If anyone can suggest a tool to monitor Http request to server.
Have you tried tracing the communication between the Java client and the WCF service?
I would do two things first, turn on logging in WCF; use a trace tool (there are many tike tcptrace) to act as a proxy between the client and server, then point the client at the trace tool and the trace tool at the server. That way you get to see the traffic and the XML (if any) sent back and fore. That should give you a much better idea as to what is going on.
Why not configure another endpoint using SOAP 1.1?
Here's a scenario:
I have a webservice, let's call this StockQuoteService deployed on tomcat (axis).
There is this method getStockQuote() exposed via this webservice.
Now, I would like to build a GUI tool which would build a webservice called StockQuoteServiceEx on the fly. The new webservice would expose the same methods as StockQuoteService. However, when getStockQuote() is invoked on StockQuoteServiceEx, this method act like a webservices client, thereby invoking getStockQuote() on StockQuoteService, obtaining the result from it. The purpose of doing this is in manipulating(data masked/shuffled/encrypted) the original result.
Once the webservice is generated, existing clients would update end points from StockQuoteService to StockQuoteServiceEx. So, the question here is, what would be the steps to dynamically generating a web service on the fly?
Since your willing to expose the same webservice interface/operations: Wouldn't it be easier to let your GUI tool act as a HTTP proxy and place that tool between the client and the actual webservice? Like:
Client(s) ==> GUI Tool (http proxy) ==> StockQuoteService.
That way the client(s) are build against the WSDL of the actual StockQuoteService, but make use of the endpoint address of the GUI tool. You can implement the HTTP proxy in your GUI tool as a simple Servlet which dispatches the request (after manipulation) to the actual webservice using Apache HTTPClient.