Hi Friends i am new to web services and now i want to create a web service and consume other webservices to my project. i went through lot of search and find out that for consuming web service Dynamic Invocation Interface (DII) is best method. i find out how to create webservice using this link http://netbeans.org/kb/docs/websvc/jax-ws.html. But for consuming other webservices apart from that i have created using DII i dont know can any one please tell some material with examples to test it, and also regarding how to secure webservice .....
You can develop following web services with java
SOAP/WDSL
Restful
Both of these two services have their own strengths and weaknesses. Just search for "soap vs restful" and you'll find lots of articles to read on this subject and hopefully you will then have the ability to decide which should be implemented where.
Here are some useful links which have recently helped me with developing web services.
www.w3schools.com/webservices/default.asp
netbeans.org/kb/docs/websvc/jax-ws.html
This is to develop a restful service. You can use jersey library from java.net for the implementation or include it using the netbeans modules.
http://netbeans.org/kb/docs/websvc/jax-ws.html
Related
I am a Java SE programmer and exploring implementing JAX-WS web services for the purpose of integrating with our web server. To this date, I have not had experience with web-services thus would like to get everyone’s expert opinion.
The background is that my company has a POS system developed and hosted in-house using Java SE. We are planning for e-commerce capabilities, which will be implemented in HTML/PHP, via external web development company and hosted externally.
Thus we are exploring implementing JAX-WS web services on our endpoint for the purpose of integrating with our e-commerce server running PHP endpoint.
I’ve done some research and my understanding is that:
it is possible to implement JAX-WS without Java EE containers
JAX-WS Web Services Without Java EE Containers
it is possible to mix end-point technologies, and specifically in my case JAX-WS as our endpoint and PHP SoapClient on our e-commerece end-point
PHP SOAP Client to consume JAX-WS with Basic Http Authentication
Using PHP SoapClient with Java JAX-WS RI (Webservice)
I am now wondering what’s is the proper approach when discussing implementation with the external web development company that is building our e-commerce platform. Most web sites and forums’ examples assumes Java on both endpoints and that both endpoints are implemented by the same developer/team.
Based on my limited understudying, I gather the process would be:
Me/my company creating the web service (coding the web services methods in Java)
Me/my company creating the server program
The wsdl generated from the URI (http://:/md5WebService?wsdl )of my server program is then used as the interface contract between our internal POS system and the external e-commerce platform
The web development company that is implementing the e-commerce platform then uses the wsdl to implement the PHP SoapClient endpoint on their side.
And in the case where our internal POS system need to consume a web services created by the external web development company, they will pass me the wsdl and I use that to make the call to them.
Is this the correct way to do proceed?
Many thanks.
Cheers,
Arthur
In Java you have actually two ways to start your design of your web service. You can either create the WSDL (Web Service Description Language) contract first (contract first approach) and then let Java or some framework tools create Java skeleton classes for you which you can use to implement the logic of each operation or you can start by code first approach and implement each web method and its logic and then let Java or some external framework tools generate the WSDL contract for you.
Either way you start, the result should be very similar and platform independent. The standard message format used for WSDL based web services is SOAP (Simple Object Access Protocol) which is based on XML (eXtensible Markup Language) which is by definition platform and programming language neutral.
So, after implementing your service and starting a server for the WS endpoint adding ?wsdl to the end of the endpoint URL should return the WSDL contract to the invoker, which can be used to create client side stubs for the required programming language which furthermore simplify the sending and receiving of messages from and to the web service. Note however that creating stub files might not be needed as all the information may be parsed from the WSDL contract directly. As of lack of knowledge concerning PHP I can't give details on how to call a WS from PHP directly or if stub file creation is required/recommended.
In order to call an other WS from your service you need to create a WS client within one of your web methods and invoke one or more of the operations offered by the remote WS and process the response within your web method.
As I am not sure if you are using any (Java) frameworks like f.e. Apache CXF I am not giving any code examples here. For integrating external web services within your service you might also have a look at Apache Camel which offers integration support for numerous Java based frameworks including CXF. Here your web service is treated as a Consumer while other external services you need to invoke are handled as Producers. The interaction between your internal and the external services is modeled here within a route where you can apply various Enterprise Integration Patterns (EIP) like splitting multiple elements contained within a response into distinct objects which you furthermore can process in parallel.
In general your enumeration of steps involved does look right if you follow the code first approach but as mentioned earlier you can also start by defining your contract first. Depending on your knowledge of the WSDL/XSD syntax (the less you know the exact syntax the more you should use code first approach), crating the contract first might enable PHP side integration sooner while you still develop the internal logic of your implementation.
it is possible to mix end-point technologies, and specifically in my case JAX-WS as our endpoint and PHP SoapClient on our e-commerece end-point PHP SOAP Client to consume JAX-WS with Basic Http Authentication Using PHP SoapClient with Java JAX-WS RI (Webservice)
This is the exact purpose of introducing webservice concept. You don't have to worry about on which platform or language your client and server is implemented. Client and server will simply exchange xml messages (platform independent) as agreed upon within wsdl.
Go ahead with your understanding.
I have created .NET web services. I want to run it on a remote server and have the Java Applications (clients) contact the server for data. How should I implement the Server such that the Clients can make use of the org.apache.xmlrpc.client.XmlRpcClient package?
I just want the clients to generate a request for data and does not want to have any other dependencies.
Here is a good material on using eclipse for this purpose: http://wso2.org/library/tutorials/creating-web-service-client-3-steps-using-eclipse
Thanks.
Although both are rightfully called "web services" the SOAP based web services usually created in .net are incompatible with web services following the older XML-RPC standard.
In my opinion you can follow 2 routes to solve your problem:
either you go the SOAP route under Java, one of the most common API's for that purpose would be jax-ws - some excellent pointers to tutorials here, in Pascal Thivent's answer
or you transform your .net webservices to XMl-RPC by using xml-rpc.net
Both routes have advantages and disadvantages, it's hard to make that choice for you without knowing more about your project. A priori choosing the SOAP route might look "safer" as there the entire communication will be based on standard components.
If you have the Web Services on the .NET side, you must have a Web Service Description Language (WSDL) (if you are not talking about REST), you can easily create the client classes to consume this Web Service using an IDE, check this link here: http://netbeans.org/kb/docs/websvc/client.html
If you are using Eclipse I suggest you this tutorial to build a simple WS client.
You can adapt this example application to your real needs.
NOTE the example uses an old version of Eclipse, but the wizard is very similar also in newer versions.
i'm new with web service programming and i want to create,using netbeans 6, a restful web service using Jersey over a Grizzly server and then a client javascript in order to use this web service through a browser. So i started learning more on restful web service and i read a lot of guide over the web, then i started learning more on grizzly and jersey by reading jersey user's guide http://jersey.java.net/nonav/documentation/latest/index.html. I succesfully follow the tutorial to create the helloword example resource. So i created all the resources needed for the job and tested successfully with the browser...but i'm still confused: in particular i want know how i can create a static homepage which can be used by the users to select what is the desired resource. Can you give me some tutorial or example?? Thanks to all!
(Moreover i want to learn more on grizzly server and creating jersey restful web service, can someone give me a useful guide or book??)
So, the key to understanding RESTful web services is to understand the HTTP protocol more thoroughly. That's what makes it easier than (and often preferable to) RPC style services epitomized by SOAP. When you pull down a static web page, for example, you can think of it as a limited "web service" which serves only GET requests. In order to make a static web page which "selects resources," you would only need to provide URLs to the resources in question, as long as they're accessed via GET, because that's the same HTTP method used for retrieving web pages (and therefore is the default method for web browsers). If you want to access other types of resources, such as sending POST requests, you can use a form; other than that (with PUT, DELETE, HEAD, OPTIONS, etc.) you'll want to use Javascript or a more programmatic API for accessing the HTTP resources.
There are many good books in this space, and I've found these particularly useful:
RESTful Web Services
RESTful Web Services Cookbook
RESTful Java with Jax-RS
SOA With REST
The first two approach REST in theory and practice; they are more about the concepts than specific technology. The third addresses the Java standard for RESTful services as defined in JSR 311, of which Jersey is the reference implementation.
The last is more of an "enterprisey" book, but it's been useful to me from the approach of designing a system of web services, as opposed to one-off service resources.
Regarding Grizzly you can take a look at Grizzly User's Guide, specifically Http Server framework chapter. If you have more questions don't hesitate to ask on Grizzly mailing lists.
I am required to build couple of Java WebServices on JBoss 5.x. One of the services will be consumed by a WPF Application. I am quite new to the world of WebServices and researching more on that. Needed to know if someone has been through the same and can share the pointers on how to achieve it.
I am reading one of the articles on JBoss Communities: http://docs.jboss.org/jbossas/jboss4guide/r2/html/ch12.html
I am not sure if web services explained here are interoperable with my WPF Client. I am planning to use WCF to consume these web services.
Can anyone share some pointers about it?
Thanks!
WCF can consume SOAP web services as well as RESTful ones. I recommend looking into JAX-RS for REST, and/or JAX-WS for SOAP. Both JAX-RS and JAX-WS are APIs that let you create web services by annotating Java code, rather than having to work with XML configuration files.
These days, SOAP is often considered over-engineered, and REST is considered leaner. There are a ton of questions comparing the two on SO.
I am new to web serivce. I have written a few clients using AXIS2 but nothing more. Now I have to create some service that will be consumed by others. We have a web application written using wicket.
Does my webservice need to be a part of the web application. Can it be a deployed seperately, but still use the same code that is used by the web application.
any tips of how to start including security, authentication etc. Any reference to reading material, tutorial is greatly appreciated.
Taking the questions one at a time:
Does the webservice need to be part of the web application? No. It can be a completely separate project with it's own deployment.
Can it be deployed separately? Yes, see #1.
Can it use the same code as the web app? Yes. This is a matter of how you reference the web app. You might consider branching the code, or just building it in to the web app to begin with.
A couple of resources:
RESTful webservices with Wicket
Web service API for Wicket
Bear in mind, I've never used wicket before so I have no idea if the above links are worthwhile.
Regarding security. You usually provide a web api "key" of some sort to your clients. That key is then passed in to every api call which you then validate for both authentication and authorization. This is how most systems work.
Also, just like with web apps, the calls to the API should go over an SSL connection in order to try and prevent anyone from eavesdropping on the conversation.
As far as logging, this is no different than logging you would set up for a normal web app. There are plenty of logging tools out there like log4j.
Short answer: Generically, yes, you can deploy your web service as part of your web application. You should think of your web service as another "view" on your business logic. If you have followed good patterns (e.g. putting your business logic in a library, not controllers) this shouldn't be too hard.
You may want to "enforce" this by putting shared business logic in one library, and then split the web service and web application into another project.
There are really too many options for web services to list them all, but here's a place to look as a tutorial:
http://static.springsource.org/spring-ws/sites/1.5/reference/html/tutorial.html
Follow the below link that explains how to expose your ASP.Net web application functionality as a web service. The below article takes TrendsInInvestment web application to explain the procedure.Features like authentication,caching and pagination has been included while implementing web service.
1)Link for article.
http://securityresearch.in/index.php/tutorials/how-to-expose-your-asp-net-web-application-functionality-as-awebservice
2)Link for the modified web application,web service and its sample code .
http://securityresearch.in/index.php/projects/f_security/trends-in-investment-web-service-1-0-is-now-available