As I have understood we use Web services(Rest/Soap) so that a piece of code with some functionality written in one language(say Java) can be used by other programmer no matter the language(say Python) he is developing the application over the internet.
One of the projects I came across uses EWS web services to create,delete appointments on our Outlook 365. The application is developed in Java and a JAVA EWSAPI.jar file is included in the library path(which contains class files like appointment.class,Meeting.class etc) to connect to EWS server and create meetings .
My confusion is suppose we were developing the application in Python, so for that do we have another API (say EWSPython.pythonextension). So then how developing a web service helped us.
I understand API defines the set the methods available and how can they be called with argument.
Please clear my doubts.
I think that you have misunderstood the aim of webservices. We need webservices to make their calls (clients) a platform independent interface which means that once you have created your webservice using any technology (java for your case here) now anyone can call this service by creating a client using any language like python, C#, C++, Ruby, ........... in that case a service which was built by Java will be consumed or called by an application or client created using python and vice versa.
JAVA EWSAPI.jar file is a API Client Library.
What is a client library?
A client library, sometimes called a helper library, is a set of code that application developers can add to their development projects. It provides chunks of code that do the basic things an application needs to do in order to interact with the API. For example, a client library may:
Provide boiler-plate code needed to create an HTTP request and to process the HTTP response from the API.
Include classes that correspond with the elements or data types that the API expects. For example, a Java client library can return native Java objects in the response from the API.
Handle user authentication and authorisation.
How is that useful?
Looking at the developer who’s using the API: With a REST API or any web service API, the developer could be using any of a number of programming languages to make the API calls.
Wouldn’t it be great if we could give them some code in their own language, to help them get started with the API? That’s what a client library does. It helps to reduce the amount of code the application developers have to write, and ensures they’re using the API in the best supported manner.
For more information:
https://ffeathers.wordpress.com/2015/10/25/what-is-an-api-client-library/
Related
I'm building a REST API with ASP.NET, which should ideally be able to use Java code. I've already managed to create a bridge between .NET and Java by using jni4net in a simple console application. This is absolutely necessary due the non-existing interoperability of .NET and Java.
Nevertheless I can't create a bridge in my ASP.NET project by using jni4net. Apparently this is a common error due the fact that .NET core 2.1 or later versions do not support the methods shown below. I am refering to this question: "Error in the webapp while connecting with JVM using jni4net from C#".
MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.
Note that I'm using .NET core 3.1 for my ASP.NET project and jni4net 0.8.8.0. Anyways I'm would change my .NET version if needed. My current implementation in Program.cs looks like this:
using net.sf.jni4net;
public class Program
{
public static void Main(string[] args)
{
var setup = new BridgeSetup();
setup.Verbose = true;
Bridge.CreateJVM(setup); // Error is thrown here
}
}
Does anybody know if there is a way to bypass this error OR how to use Java code in an ASP.NET project? I highly appreciate any help or suggestion, sheers!
An API is a medium that recieves requests from client, processes those requests inside and responds back to the client.
You can probably do what you want to do by creating an API on .NET Core and consume that API in your Java project.
In the simplest way, you can create an API endpoint in your .NET project's controller and send a request to that api on your Java application using the target URL of your API endpoint.
The response from your API is going to be in JSON format.
Please note that you can consume an API regardless of the language since the communication between your application and your API is going to be via HTTP requests and JSON responses.
Some useful video links to start with:
How to build a restful API in .NET Core 3.1 https://www.youtube.com/watch?v=fmvcAzHpsk8&t=11447s&ab_channel=LesJackson
How to consume an API in Java application https://www.youtube.com/watch?v=Fry7waUIJiY&ab_channel=PrakashShindalkar
I also would like to clarify that HTTP is just a a protocol. You can probably achieve what you want with other communication protocols as well but this one is fairly more popular and suitable for your needs.
As far as I know jni4net is not compatible with .NET Core. It's for .NET Framework.
This is absolutely necessary due the non-existing interoperability of .NET and Java.
I don't know the circumstances but it shouldn't be a necessity. Just build a service that exposes API to C# code. Voila you have a bridge. Or you can use CORBA however it's so complex it doesn't worth at all imo.
One problem that continuously comes up at my workplace is creating clients for Java rest services that we create. We have 4 different programming languages to support and it is costly to create clients for each programming language. Often this means our web services aren't available in a cross platform manner since we rarely have time to build all of the clients.
SOAP provides this type of discovery and machine created client mechanism based off of tools that consume WSDL but our architectural direction is to write REST based services in Java instead of SOAP services.
We would also prefer not to write WSDL documents by hand that expose these REST web services. In a .NET environment, WCF and ASMX web services automatically create the WSDL for consumption in other applications, but this is not a direction my team is allowed to pursue.
Can this be done in some fashion for a Java based REST service?
How can this be done without having to invest a lot of manual labor?
We're currently using spring controllers but might be able to argue for a different Java framework if it provides better velocity.
Jersey (JAX-RS implementation) has support for WADL. You can use Jersey to automatically generate a WADL and there is also some support for generating Java clients from the WADL.
That's for Java, and I don't know if it's more than basic support, but I doubt you can pull it off for 4 different programming languages.
You might want to read these first though (tl;dr: REST is more than a CRUD style Web API and is different than SOAP):
Do we need WADL?
Why the slow WADL uptake?
You may want to check third party tools like swagger (http://swagger.io/) and mashery. I know swagger has support for client generation.
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.
2 month ago i started to develop an android application which needs to call remote methods and receive complex objects (custom objects with custom feilds in it) from a server.
My friend and I splitted the work so he worked on the android client and i on the server.
Before we started, we built the base interfaces which provide the functions that the client needs from the server, so my friend can program easly the application (by using fake classes as implementation for the interfaces), and after i finish the implemntations of the interfaces in the server-side he will make the connection and call the functions from the server and not from the fake classes.
Now the problem is that we can't find a way to pass those interfaces from the server to the client.
We tried to use java RMI, but we faild because android doesn't support java RMI,
then we tried to use JAX-WS (with tomcat 7) and we also faild because JAXB can't handle intefaces. (-you can see more details here about jaxb issue-)
My friend and I feel really lost.. we don't have any idea how to pass those interfaces between the server and the android client.
Is it possible what we're trying to do? if not,
what other options avaible for us to call remote methods and receive complex objects from the server?
Thanks!
You can expose webservices on the Server, so the client can interact with the server whenever its needed that might be quickest solution.
Or you can write a kind of servlet programming to get the json request from the client, process it and send the json respoonse back to the client. If the application is data intensive, the JSON helps you a lot
Not sure if this is too late now (after 2 months of development), but there are frameworks that should make RPC easier for you (take care of linking both ends). Two I know of are Apache Thrift (definitely usable with Android - there are apps that use it) or Apache Etch (possibly).
Apache Thrift:
http://thrift.apache.org/
Apache Etch:
http://incubator.apache.org/etch/
Blog about Evernote choice of Thrift:
http://blog.evernote.com/tech/2011/05/26/evernote-and-thrift/
If your application is limited to communication between Java on the server and Android (no other clients e.g. IOS) then an easier RPC path compared with IDL based solutions is to use jsonrpc. This solution provides both server and Android client components. It is extremely easy to implement on both client and server. One limitation is that byte arrays have to be encoded because the JSON transport does not support binary.