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
Related
Is it possible to generate java web-service client using a WSDL file(from local file-system)?
I am working with siebel and Java. siebel developer send me a WSDL file, I need to generate java web-service client. How can I generate client using that WSDL file which is saved on my desktop like a normal file?
I know how to generate web-services clients in Java using eclipse, But eclipse is looking for a WSDL url. which siebel can not provide.
Is there any alternative?
You can do it in eclipse just copy the wsdl file into the project root and then when you click to generate instead of url click browse choose the project and select your wsdl.
Right click on project->new->other
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.
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.
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
I have made an Axis2 Web Service in Java. I am using Apache Tomcat 6.0.32 as a Web Server. My Web Service gets the data from the database(MySQL), and it returns the data into my mobile application. Now I want to deploy my Web Service. What are the steps for that?
Check this link if you want to deploy without using eclipse
http://www.ibm.com/developerworks/opensource/library/ws-webaxis1/
If you are using eclipse then
In preferences setup the Axis 2 runtime
Right click on the project where you have your service implementation & choose the New webservice option. Use the Bottom Up Java Bean Web Service option
You can also quickly create a client to test it.