Accessing Web Service using Play Framework 1.2.5 - java

I am using Play framework 1.2.5 in my application in Eclipse IDE. I need to access a web service built using IBM JAX-RPC. I have got the wsdl file of the web service which I need to access in my applicatiom.
For normal Java EE applications, I used to paste the WSDL in my workspace, generate the files by right clicking the WSDL file => Generate Client option i.e. generating files with the help of Eclipse IDE.
I am not sure how to access the WSDL using Play framework.
I want to know:
1) Where to paste the WSDL file in my workspace?
2) In Play framework how do generate the client (Not sure even if we need this or not in play framework) and access the service methods?
3) Any additional settings needed for accessing the service methods?
Please let me know about this.
Regards,

The easy way:
Use Play!'s built-in play.libs.WS (Link #2 and #3). You have to create the raw HTTP requests yourself, and parse the XML result from the server yourself. Of course, this can become a complex task, if the web service interface is complex.
Preferably, you will create a JAX-RPC client based on your WSDL, and use it from your Play! application.

Related

How to generate mock web service using WSDL in Java?

I have WSDL file and for local testing I need to generate mock web service.
Please do not recommend SoapUI.
Can anybody please help how to generate mock web service in Java using WSDL?
One option is to create a Web Services project using an IDE.
This will allow you to create a mock service and also implement your business logic.
As an example, using Eclipse:
Before starting, ensure that:
Eclipse has a server installed (Apache Tomcat)
Your WSDL file have a .wsdl extension (if not, rename as .wsdl)
Now, start Eclipse:
Create a new java "Dynamic Web Project"
Create a folder WebContent\wsdl and copy your WSDL file
Right-click on project > select new "Web Service"
Select:
Web Service type: "Top down Java bean Web Service"
Service definition: browser your WSDL file
Select "Start Service"
Select "Java Proxy / Start Client"
Select both option at the bottom of the form (publish/monitor)
Click next to complete process
At the end, your server should be started and WS deployed - check that your WSDL is available.
Now, you can:
call your WS using Eclipse Web Services Explorer see explorer
implement your WS mockup business logic see method implementation
or use a working java client to call your WS programmatically
Hope this help.
Try using Wiremock. However you will be needing to create and structure json/xml files according to your need. This will give you an better idea. Using WireMock with SOAP Web Services in Java

Call an axis2 web service from a java application

I have create one simple web service and I deploy it to the axis2 web application based on this tutorial
After creating my service, I am able to deploy it to the server and I can see the WSDL file by this url: localhost:8084/axis2/services/HelloAxisWorld?wsdl
Now, I want to call this service by an independent java application. I found some pieces of code that makes the invocation, but I am facing problems because I suppose that I don't include the proper libraries in my project.
Does anybody knows an example to call the web service by using axis2?
A simple Google for 'axis2 client tutorial' gives me this. It covers setting up your classpath properly, generating java from the WSDL via wsdl2java, and developing the client from this.

Unable to publish wsdl file

Can any one tell me how to public the wsdl file ie., that web service is created in java using eclipse.I am self learner to java/eclipse and web service too,so can any one please make me clear with steps.
Thanks for your time!...
Apache Axis has some cool tools that I frequently use - to generate a wsdl, use java2wsdl. It has a command line version, but also a Maven plugin (which I highly recommend) that will re-generate the wsdl for you automatically each time you package your web service.
What's more, the axis stuff also provides auto-generation of client stubs by which you can use your web service in consumer apps or services. Alternatively, JAX-WS tools can be used for this as well. In either case I would recommend automating the process with Maven.
If you package your wsdl with your app in this way (rather than letting a server do this for you automatically), you can be certain that your contract will look the same on any platform.

Eclipse WSDL generator (from java class)?

I want to generate WSDL compliant with Java classes. At this phase I don't want to put it online, just have the wsdl (in order to discuss it with someone else) and validate the generated file.
I'm using Eclipse, so I would prefer any solution that's already integrated with it.
From eclipse in the java perspective:
Right click on the Java class you want to use as your service implementation
Select Web Services -> Create Web Service
Web service type should be "Botton up Java bean Web Service"
This will generate a WSDL file for you.
Also you can publish the service at localhost with any server (Tomcat, for instance) and then with your browser in the address bar write
http://localhost:<server_port>/path/to/your/service?wsdl
If the service is correctly configured, you should see the generated wsdl. Then you can copy/paste in any text editor and save it as myService.wsdl.
Hope that helps

Developing a web page which invokes web services through CXF

I have already generated the files using wsdl2Java and created the proxy client in JAVA.I am using Apache CXF framework and using Maven as Build Management tool. I can run the JAVA application and consume the service using JAVA. There is no problem with JAVA implementation.
The need is I need to invoke and request the same web service from PHP or JSP file and display the result in PHP or JSP file. I would like to use the present JAVA code. I don't know how to invoke the JAVA code from PHP or JSP page.
Please help me with the solutions.
You have created a web service, so your design should be centered around that. For Java programs (including JSP's) you can use the generated client classes to access the web service. For PHP I would recommend using one of the many SOAP client libraries to process and consume your WSDL. You might want to take a look at wsdl2php, NuSoap, or SoapClient.

Categories