Create SOAP webservice starting from WSDL using Groovy? - web-services

We have a wsdl for which we need to create a server implementation. In previous projects we used wsdl2java from Apache CXF, but now we want to keep it all in Groovy. Is there a way in which we can create a server implementation and keep it all in Groovy? Or are there any other ways we can achieve this?
The ultimate goal would be that we can hook this implementation into a Grails application that will serve as the server for clients.

Yes. You can either use the plugin or use cxf directly.
If you follow that tutorial, you can always use wsdl2java and just rename the generated files to be .groovy files and update the syntax to be more groovified. They will still work like normal. Also, as you may or may not know, you don't have to copy the jars directly to your lib directory as it says in the tutorial, you can just use normal Grails dependency management.

I think a better fit for you would be Groovy WS Lite. Spring-ws is also an option, it is a powerful library and reasonably well documented, since grails is spring at the end of day, this may integrate very well with grails. Shameless plug: This is web service integration testing tool I created which uses groovy and spring-ws. You can see the code to get a "working example".

Related

How to mock SOAP web service without SoapUI

I have a web service that I want to mock in following way: I will have a list of given IDs, and a set of response items for them, and if user will send a request with ID from the list, proper response should be sent back.
How to do it without tools like SoapUI (I don't want to install any additional software on the server that will be tested if possible).
Thanks in advance for any help.
SoapUI open source provides exactly what you want to achieve, without any need to install SoapUI on the server.
I consider this approach very efficient:
Create your mock service inside SoapUI.
Test the mock on your computer with SoapUI.
Create a WAR with the mock service (or more services) - just click on the project and choose "Deploy As WAR"
Deploy the WAR to the target server.
The resulting WAR is standalone and you do not need to deploy any other software.
I recommend this tutorial: https://www.soapui.org/soap-mocking/getting-started.html
Regards,
Karel
The easiest way I could find is https://www.mockable.io/ . Hope it helps.
You might have to build an actual mock for this.
This could range from just a different implementation for an existing interface (say IOrderQuerier, with the old OrderQuerier and the new MockOrderQuerier), to a different project altogether (say MockOrderApi).
In both scenarios, the Mock would just return a set of predefined values depending on the input, but you'll need to provide some sort of switch mechanism (for example a flag in the config file, which is read by the DI container).
You'll have to provide more details about the server if you need more targeted answers on this.
If you can manage to mock this using mockito, I've just added a simple project which does most of the heavy lifting: mockito-soap-cxf

Creating and using SOAP based web service in Laravel framework

In Laravel 4 framework, how to create a SOAP based web service. I would like to build a SOA based web application in laravel. Please clarify with an example how to use web service with some step by step examples or links as i am completely new to laravel
Thanks in advance..
You can use "php-wsdl-creator" (also supports SOAP). They have a great tutorial and many demo php files to get you started. It can also easily be implemented in laravel or any other framework for that matter. :)
You can find more information on Google Code: https://code.google.com/p/php-wsdl-creator/
Also note that SOAP requires an extension to be loaded in PHP.
For more recent needs, you should use a Project such as wsdl2phpgenerator or PackageGenerator from WsdlToPhp. This sort of projects, requirable with composer, use an OOP approach and allows to build a SOAP request easily with PHP objects then handle the response just as the request with PHP objects.

Have WSDL, need to generate services (step by step instructions)

Any documentation on creating a service and deploy to JBoss from WSDL? I have found several on the net, struggling to choose the correct/optimal approach. Using spring is also okay.
I have created WSDL from eclipse based on my requirements. Now, How do i generate request/response from WSDL? and then stubs. I also can use Intellij if it simplifies things.
I did generate a service, but i had to strip out so many jar files (jboss related) from my ear file before deploying to make it work. Any help generating ear file will be helpful too.
JDK 1.6; JBoss 5.1; Eclipse Indigo or Intellij Idea (11.1.4)
I know this question has been asked several times, but as i mentioned tons of information on the web, getting confused with several approaches.
If you are using Maven, you can use the jaxws-maven-plugin to generate artifacts. You can find a simple maven project for generating artifacts from a WSDL, here (wsimport)
Step-by-step:
Generate Java artifacts from your WSDL. (Use wsimport tool or Maven plugin)
Implement the generated Service Endpoint Interface.
Deploy.
If you want to start with Spring-WS, the obvious starting point is the documentation. You probably want to use a marshalling framework like JAXB to generate classes based on your WSDL. Based on those classes you can create #Endpoint annotated classes. In such an endpoint, you can create methods which are annotated with #PayloadRoot and #RequestPayLoad - based on that combination it will be mapped to a specific operation in the WSDL. Check out this page in the documentation for more information on annotating methods.

Contract-First Web Services using CXF , Spring and JAX-WS

I am currently looking at redeveloping a web service that is currently written in .Net. I would like to port it across to Java using a CXF, Spring, Hibernate and Maven stack.
The WSDL for the service is already available and is well formed so I would like to reuse rather than redeveloping the interface. This will also mean that the clients will not require significant changes in order to use the new service.
I would like to use a JAX-WS type approach to developing the web service, similar to the Java-first approach at http://cxf.apache.org/docs/writing-a-service-with-spring.html. The only difference being that I would like to follow a contract-first approach and ensure that the exact WSDL is used.
Has anyone attempted this before? Are there any good guides online that I can refer to?
I am actually not seeing in your question what is stopping you from developing it with WSDL first approach.
Check my answer here, for the tutorials you need.
I guess its pretty straight forward (The WS stack part)
1.Create the Implementation stubs using WSDL (contract)
2.Create Client using WSDL
* implement methods using your own logic and syntax
both 1&2 is supported by CXF.
good guides here
and here

How do I test webservices?

I am a novice in web services. I am totally new to testing web services.
A new project demands that I test the web services, and the customer is in favor of any open source tool.
What is the approach to testing web services?
Also Please suggest a tool(with minimal scripting) to test web services?
Check out SoapUI - one of the best web service test tools - plus it's free!!
They also have a "Pro" version which costs - you can do more stuff, like load testing etc., but the free version is quite good enough for most of your testing, I'd say!
Given a WSDL (online or stored as file), it'll create stubs for each method, which you can then use to create requests (as XML), fill in the blanks (the parameter values), and then you can send off your request to the web service and see what comes back as a response.
SoapUI also allows you to write scripted tests than can be run over and over again.
Excellent tool - can't praise it enough!
Marc
Additionally you could use Firefox Poster in order to test your web service by passing XML-packets manually.
Check it here:
FF Poster
SoapUI is a great tool to test SOAP webservices. It allows you to test a SOAP client or a SOAP server.
Another very useful tool is Fiddler. Fiddler isn't necessarily aimed at testing webservices (it's a HTTP debugger), but since SOAP webservices run over HTTP, you can use it to testing. Another very important advantage of using Fiddler is the fact that you can test REST webservices also.
You might want to consider robot framework. It is a generic, keyword-driven testing framework. There are libraries for testing REST and SOAP based web services. It can also be used to test web pages (via a selenium library), databases, and a whole lot more.
robotframework has a ton of built-in keywords, and there are additional libraries that do much more. You are also able to develop your own keywords in python, java, .NET languages, or any other language.