How to call SAP web service in Java? - java

I have a RFC-enabled function in sap (WebService).. I want to call this function and get the result using java. What should I do? (I already have the WSDL endpoint)

Call it like consuming any other normal web service.
Use JAX-WS,which is the Java standard for it.
See here and here for an example.You can also use HTTP clients to call the web service as well.Apache HTTP Client is a great library if you want to go in that direction.There is an example available here for that as well

Related

How to call to Java RMI methods from web client?

I have a Java RMI application developed with Swing GUI interface. I want to change that to React app. Is it possible to call RMI methods from JavaScript?
No. It is not possible. Javascript is not Java at all.
You may consider to rewrite server side of RMI application to either Webservice or REST API application, then you'll be able to call its methods from Javascript. It can be also just a small wrapper application around existing RMI.
Like:
Javascript call (SOAP or REST) -> Wrapper call (RMI) -> Existing RMI app.
Maybe, you can use hessian protocol (reimplement RMI with hessian, just delegate from hessian servlet to local RMI). Use hessian.js

How to call java method using Angular JS?

I am using Angular JS with Spring MVC for my project. I want to call Java method directly from html using Angular JS to populate Drop Down.
Thanks.
You just can't because Angular JS is working on the client side while Java is most likely running on the server. What you need is a REST interface that accepts invocations from the Angular JS app. As the REST interface is (most likely) written in Java on the server side, you can then make the desired Java call to get the drop down values and send them back as response as part of the REST call. Use Angular JS then to interpret and use the response from the server.
Sorry for not being more precise but that should give you a pretty good starting point.

ReST webservice client - generate from WSDL or not?

I've some confusions about ReST clients and need a bit of help.
For ReST, does the service provider give WSDL document or not? If not, how does the client will know what kind of JSON data to expect? When I invoke the rest client, I will recieve the JSON/XML response in a string format which I'll need to convert it into a Java object(or Javascript, if using on client side) to do any meaningful tasks with the response. So it seems like I, as a client developer, need to know the WSDL or the Schema definition so that I can build a java object similar to the JSON response I'm expecting. But if you go by this answer, generating a client class based on the service definition flies directly in the face of ReST fullness. If that is the case, how do I go about creating my client code?
WADL/Web Application Description Language is not a standard but is gaining popularity for REST APIs contract definition.
The Web Application Description Language (WADL) is a machine-readable
XML description of HTTP-based web applications (typically REST web
services).1 WADL models the resources provided by a service and the
relationships between them.1 WADL is intended to simplify the reuse
of web services that are based on the existing HTTP architecture of
the Web.1[2] It is platform and language independent and aims to
promote reuse of applications beyond the basic use in a web
browser.
For documentation:
https://github.com/wordnik/swagger-core/tree/master/modules/swagger-jaxrs
For client code:
https://github.com/wordnik/swagger-ui
You integrate the library and annotate your resources and online documentation is generated on the fly.
You also need a client for which you can integrate the ui.
The dynamically generated REST client looks something like this:
http://petstore.swagger.wordnik.com/

How to connect WSDL file in my application using SOAP service?

I am doing a project using Java and BPEL. I successfully created webservices in Java and integrated them using BPEL. All i generated a single output WSDL file. Now, I have to use this output WSDL file in my application using SOAP communication. How can i do that? Is there any help out side for such scenarios? Walkthroughs are really appreciated..
Depending on the architecture of your application (Standard Java, Spring-based, ...) there might or not be a documented procedure to consume a SOAP-based webservice.
On the other hand, you're always free to pick a webservice development framework to handle that. For instance, you could pick either CXF or AXIS2 (I believe these are the two most popular frameworks for Java WebServices). Each of these frameworks provides a tool called "wsdl2java" that helps you generate client-side/server-side/both Java classes. Then, you can easily add those classes and the requireds libraries to your application.
Having used CXF in the past, It even does provide several way to consume a webservice
Generating the client-side classes
Using CXF dynamic client factory : basically, you'll retrieve an endpoint proxy from a factory object.
Hope that'll help
I start with SoapUI (or downloadable from sourceforge), that will let you consume the WSDL and fire off requests against your server. Typically I'm hitting someone else's webservice, and trying to figure out what the data looks like before I start wiring my code together, but in your case its just a verification that the services would be/are working.
Then, as #KHY said, you can automatically convert the wsdl into java with a wsdl2java and start coding (look under the Related list on the right panel of this SO screen)
If it is a Java application, then the easiest way to consume a service is using JAX-WS. It's really easy to create a Web service client from WSDL.
See this link
Once you deploy the BPEL project on server, then refer the WSDL with http://server:port/application/YourBPELProjectService?WSDL in the consuming application. You will need to write different client code based on the BPEL type - Synchronous, Asynchronous etc.

WCF & Java Interop using WSHttpBinding,

I’m trying to get a simple WCF application work with Java Client. Service exposes few simple operations using WSHttpBinding, which it does perfectly.
Now, due to some reason (probably due to incomplete WS-* specifications at Java side) it seems impossible to generate a Java Client for this WCF service hosted on remote system.
However, everything works fine when used with basicHttpBinding.
If you successfully use or have implemented WCF (wsHttpBinding) where it was interoperable with Java/Non WCF client?
What are you using in Java to generate the client? Not all frameworks are created equal. :) According to this post here, you will need to use WSIT.
We have seen issues related to WCF/Java. Basic binding in WCF creates WSDL ver 1.1 while other bindings use 1.2 if my memory servers me correctly.
We have also seen issues that can occur if you reuse the message contract.
Testing the WCF service from XML Spy is a good way to catch such errors.

Categories

Resources