Can I force Jersey framework to scan only one package while creating WADL? - web-services

I have a project where I have kept web service in two separate package. One package contain customer face web services and another contains in house usage web services. I want jersey to only scan the customer facing package and generate WADL.

In general I was not able to find any way to split wadl generation logic by configuration. But here is hack you can perform. There is class called GenerateWadlTask.java This basically does the wadl generation logic for jersey. You can just extend this class in your custom application wadl generation task and use it as per your logic. For code example just download the jersey server source jar and look at the class. The logic is pretty straight forward.
hope this help.
EDIT:- There is a maven plugin called enunicate http://enunciate.codehaus.org/
That will make your life easy.

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

developing custom WSO2 Carbon authenticator clients

I am implementing new authentication methods for WSO2 Carbon. I know there is a pretty good explanation and sample piece of code in this post.
The problem is, what if I want to generate stub and service client components from the sample BE authenticator? What are the steps to follow? Any tools (java2wsdl / wsdl2java, maven plugins,...) or reference tutorial that can help to achieve this in the most straightforward way?
I know there are several existing authenticators (IWA, webseal,...), but they already come with some stub/ui built in the existing repositories. I would be rather interested in being able to develop/generate all the components more or less from scratch rather than having to modify existing code, which is often prone to errors.
Thanks
This is some high level thing.. but hope this is useful.
1st you can develop the BE component as OSGI bundle. Then you can deploy it in /repository/components/dropins directory. Here you need to have a service.xml file to expose as web service (Please refer WebSeal BE component)
Then configure following property in the carbon.xml file.. if BE service has been defined as admin service
true
Open browser and locate your WSDL of new service
https://{ip}:{port}/services/{service name}.wsdl
Then use wsdl2java tool to create the stub class for you. There is a UI tool in WSO2AS product to do it.
Use stub as a dependency for your FE

A proper place for a web-service backing logic

I'm going to create Axis2 web-service on WSO2 AS. AFAIK .aar must contain a service class and its configuration in service.xml. To process requests received by the web-service I'm going to implement some business logic including interaction with DB through Hibernate. In respect to a system architecture it would be wrong to place all this logic into the web-service class. What would be a proper place for the business logic implementation in my case?
You can model this inside the Axis2 project. You should only add the service publishing methods in the service class and no need to implement the core logic there. You can easily model it as project with different hierarchies and aspects.
Look at this example blog post and how the project is modeled which can be found at the end of the tutorial.

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.

Splitting Up the Rest Api WADL?

Is there a way to Split up application.wadl in Java environment?
Technology that are in place are
Jersey + Spring + spring MVC .
I want to split only application.wadl so that I can expose only those web services that I will be supporting for backward compatibility for my users. Also the authentication will be based on some different criteria.
Does jersey provide any support for such requirements ?
In general I was not able to find any way to split wadl generation logic by configuration. But here is hack you can perform.
There is class called GenerateWadlTask.java This basically does the wadl generation logic for jersey.
You can just extend this class in your custom application wadl generation task and use it
as per your logic.
For code example just download the jersey server source jar and look at the class. The logic is pretty straight forward.
hope this help.
EDIT:- There is a maven plugin called enunicate http://enunciate.codehaus.org/ That will make your life easy.