What is the WCF correspondent for Java? - java

Is there a unique service centralizer like WCF for Java where I can create and host services for different media?
Change:
It seems it has a different concept in the java world, is it called application server?

JAX-WS / Metro
allows you to annotate your web service class and methods and generates a WSDL from those annotations, just like WCF.
allows you to generate a service wsdl-first, just like WCF
allows you to generate a web service client, just like WCF
allows you to host your web service in any Java EE container. This is comparable to WCF's IIS hosting.
allows you to host your web services using the Endpoint api. This is comparable to WCFs self-hosting.
allows you to choose between SOAP or Fast InfoSet over HTTP or TCP protocols, like the WCF transport options. (Though I don't think it allows named pipes...)
So in many ways it corresponds to WCF. It is more focussed on Web Services than WCF is, though. Like the names say.

I have found some blog, it is pretty old, but it explained very well about java jax-ws and .net-wcf.
Hope this helps..!

The options I've found are
Netty
http://netty.io/
Apache MINA
http://mina.apache.org/

Yes, and it's pretty simple to use it's called java webservices, and it uses wsdl files like WCF and everything. refer to this: http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/

It seems you want to host your application locally ...For that there are several application server's like Jboss,Glassfish,Tomcat,IBM Web sphere ...

Related

Advice on implementing JAX-WS web services to be consumed by non-Java (PHP) endpoint

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.

Consume .NET web services in Java

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.

Can we use php web services in java?

I have a web application in JAVA (Spring MVC framework) and I want to connect to a website and use its web services which wrote in php, is it possible ? if yes how can I do that?
It doesn't matter what language one used to create a webservice. You can talk to any webservice by agreeing on how it exchanges messages.
Yes, Spring integrates well with Apache Axis: http://axis.apache.org/axis2/java/core/docs/spring.html
To consume web services with Spring you can use JaxWsPortProxyFactoryBean to create a client proxy: http://musingsofaprogrammingaddict.blogspot.com/2009/03/writing-and-testing-jax-ws-clients.html
From Spring in Action, here's how you'd configure an example web service proxy bean:
<bean id="spitterService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean"
p:wsdlDocumentUrl="http://localhost:8080/services/SpitterService?wsdl"
p:serviceName="spitterService" p:portName="spitterServiceHttpPort"
p:serviceInterface="com.habuma.spitter.service.SpitterService"
p:namespaceUri="http://spitter.com"/>
The beautiful thing about web services, and web services are beautiful things, their hosts are made with wsdl's, their client is made in Spring! (Totally stole that from the mouse (just a warning, as per the comments, this rhyme is not to be used as an authoritative anything. It is an attempt at humor by someone who was excessively tired at 3 AM because of Win 7 issues))
Web services are language agnostic -- the only thing which matters is that they are up and running (and serving valid outputs), not that they are using technology X, Y, or Z. Theoretically, you could even have a webservice running on something written in Piet or Brainf*ck.
A tutorial on how to create a client can be found here.
Use CWSDLGeneratorDocument.php for generate WSDL file in DOCUMENT/LITERAl style and use standart library JAX-WS in java 1.7.

Calling a soap web service using java

In my java program, I need to call a SOAP web service that is deployed on a remote server.
Looks like there are several different approaches when explored in web.
But I would like to know as what is currently being used more in the developer world.
Also is there is a way to call a SOAP web service using Spring or axis or xfire.
Thanks in advance for your input.
For spring you can look at http://static.springsource.org/spring-ws/site/reference/html/client.html for client information.
When I write SOAP webservices I tend to use jax-ws now, especially since it comes installed with JDK6 now.
For a tutorial on that you can look at http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/2.0/tutorial/doc/JAXWS.html.
I like it since it uses annotations, so is simpler than using axis.
If you are using Spring then using their webservice options would be your best bet though.

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