developing custom WSO2 Carbon authenticator clients - web-services

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

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

Adding Functions and packages to Device managemnt Core and common

I created a package and org.wso2.carbon.device.mgt.core.log.mgt created some functions in it.
Added my new Build of Carbon Device core as a project dependency to
WSO2 MDM - Mobile Device Management Admin Services
precisely the Operations Class
Build the project and Deployed it.
On loading it failed with Error being
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
Any Help will be greatly apreciated. My Goal
Create functions in Carbon device Core and Common following your Design. Call the functions in my webservice
Please follow the instruction given in the below webinar and the tutorial in order to create your feature as an OSJI bundle(Carbon component) and add it to the EMM server. This is the correct and advisable approach for include new functionalities to WSO2 products.
http://wso2.com/premium/webinars/creating-your-own-wso2-carbon-components http://wso2.com/library/tutorials/2014/03/how-to-write-a-wso2-carbon-component/
First of all you need to create the carbon component(in here your newly created package).
Then Create the feature accordingly.
Then need to add created feature to the pom.xml file of the
product-emm p2-profile-gen.
then makes it packs in the project target by adding a entry to the bin.xml of the product-emm
following attached tutorials gave you a better guidance and clear idea about how to create your own carbon component.
tutorial
http://wso2.com/library/tutorials/2014/03/how-to-write-a-wso2-carbon-component/

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.

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

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.

Using Axis to generate a web service implementation that calls another web service

I need to provide an implementation of a web service for which I have the WSDL, to run under Weblogic 9.2.
I aim to use the Axis (1, not 2) tools for this , having tried and failed to make it work with thw weblogic web service generation tools (due to an inability to set the authentication - see my other question here),
This web service needs to make calls to another web service (for which I also have the WSDL).
I can use the Axis tools to generate the client stubs etc.
But how do I do the two in combination? Is there a tutorial or other step by step guide? I have googled and found some mailing list postings, but they're about specific issues.
If someone's done it, could they share the relevant parts of their build.xml for this?
If I used the weblogic web service generation tools, there's a tool that in one go generates the skeleton implementation of the web service and the client stubs for the web service it calls - is there something similar in Axis?
Any gotchas if I just try to mash up the skeleton and client generation output from WSDL2Java?
Update:
Got this to work.
Used the Eclipse tools to build the client, then the service, allowing the second to overwrite the duplicate files from the first. We then had some issues with the client_deploy.wsdd file (see my other question How do I refer to a client_deploy.wsdd file that's in WEB-INF?) and with jar versions (needed to update the jars that Axis uses to newer version), then it just worked.
Speaking for axis2, you can create the client stub like this (I reckon axis1 is not much different):
/wsdl2java.sh -uri webservice.wsdl -p com.your.client.package -d adb -s -o output_folder_client
Once you have the client package you should be able to use it in your own webservice implementation by just importing it, creating a client instance and submitting requests.