This post shows an example of jax-ws maven plug-in usage. This maven plug-in can be found in two repositories
org.codehaus.mojo
org.jvnet.jax-ws-commons
First repository contains old versions of this plug-in. ( available upto versions 1.12 ). Second one has the Latest version (2.3) and it can be found in http://jax-ws-commons.java.net/jaxws-maven-plugin/. To use latest version, replace groupID and version fields with following .
<groupid>org.jvnet.jax-ws-commons</groupid>
<artifactid>jaxws-maven-plugin</artifactid>
<version>2.3</version>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Most of the web services use soap headers to pass various kinds of information and it is required to manipulate those headers within a BPEL process when we are creating a complex business logic. Sometimes we have to deal with soap headers which aren't declared in the WSDL abstract message. These kind of headers are called Dynamic headers and both Apache ODE and WSO2 BPS can handle these type of soap headers.
For more information about header handling in Apache ODE, follow this article.
This post will show you how to handle soap headers, covering following scenarios,
Reading a soap header in request message.
Create a new soap header in a variable and assign a value to it.
Copying soap header from one variable to another.
Sample BPEL Process
To demonstrate above scenarios let's consider this simple BPEL process. These are process's default request and response messages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's read "echo" header from the input message and set its value into the process output message (to result element). To do this, add another copy into the Assign activity like this. Note that we are using "header" attribute to refer a soap header. (Resultant process's response is shown in response.xml)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2. Create a new soap Header in a variable and assign a value to it
Let's add new soap header called "echo2" in the output variable and assign request message text (input) value as new header value. First copy will create the echo2 header and second copy will do the value assigning. (Resultant response is shown in response.xml)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3. Copying soap header from one variable to another.
Let's copy request message's echo header to output message. In the Assign activity define a copy as follow. (Resultant response is shown in response.xml)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Echo service is an asynchronous web service and this is the service which we are going to mock using SoapUI. Clients send requests to the echoService using ws-Addressing. Echo service uses ws-addressing headers to identify client's callback information and sends back echo-Response to client's callback services.
Step 1 :Obtain or Create wsdls files of the services which you are going to mock and client callback service.
Here I am using EchoService.wsdlfile as my service's wsdl and ClientCBService.wsdl as client's callback service wsdl. Step 2 :create a new SoapUI project using service and client WSDLs.
Open SoapUI.
Then goto File -> new SoapUI project or use shortcut key Ctrl + N
Give the your service wsdl path in initial wsdl/wadl filed and give an appropriate project name. ( Let's say EchoService ) and Click OK
Now Let's add client's wsdl into the same project.
right click on your SoapUI project and select "Add wsdl"
In "Add WSDL" window select your client wsdl and Click OK
( Note: Create Sample Requests for both server and client's callback operations if they were not created by default )
Step 3 : Generate Mock service for EchoService
Right click on EchoService and select Generate MockService
In Next windows click OK to create mock service with default values.
Now we have created the mock service. In Mock service window, click configure icon ( the most right icon) to set host name and port.
Give host name as localhost and give port which you prefer.
Step 4: Create a TestCase to invoke Client's callback service with echoService response.
Right click on the client wsdl project and select Generate TestSuite.
In next windows Click Ok to reate test suite with default values.
Now You have create the TestSuite. Open the test-step which was created by default. Set echoString and messageID parameters in the request message. ( you can set parameter using ${parameter_name} )
We will extract and set values to the above parameters in next step.
Step 5 : Write a groovy script to handle asynchronous behavior of the service.
Double click on echo Operation in Mock-Service
In opened Window select Dispatch type as Script.
Then enter following code as our dispatch logic. It extract values from incoming request and parse to the testcase using a map. Also it sets testcase's end point address to the value that came with ReplyTo header.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now we have finished mocking our asynchronous service. But we need to have a callback service to get the response back.
Let's create another soapUI project to mock the callback wsdl. Follow above steps to create a mock service for client callback. For your reference I have added only few screenshots of most important steps. Note that I am using port as 8087 and host as localhost.
Start client Callback service by clicking green arrow of the mock service.
Start our asynchronous echo (mock) service.
Now we are ready send a request to our mock service. Open request in EchoServiceSOAP and add mockservice endpoint to it.
Click WS-A tab and enable ws-addressing. Then set "Action", "To", "ReplyTo", and "MessageID" fields in the request message as follow.
Now we are ready to invoke our service. Click submit button in request window to send the request to mock service.
It returns an empty response. But if you check your callback service, you can see that actual echo response was sent to it.
You can view incoming request messages in both mock-services windows. Open both echoService request and echoReult message and Compare them for echoed string and ws-a messageID. ( see bellow screenshot.)
In this post, I am showing how you can invoked a secured proxy service, using SOAP UI tool.
Here I am using WSO2 ESB 4.6 and SOAP UI 4.5.1for this example.
Step 1: Create a proxy service
Let's create a ESB proxy service first. Here I have created a proxy service to invoke echo service that comes with WSO2 ESB.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First let's try to invoke our proxy service without security. Here I am using tryIt tool. Click "Try this service" link in the EchoProxy row in the Deployed service. Use following sample request to invoke the service.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 2: Creating SOAP UI Project and Testing service.
Open SOAP UI tool and Create an new soapUI Project. ( File -> New soapUI project )
In the new soapUI project wizard, give the our EchoProxy service's wsdl url. (ex: http://localhost:8280/services/EchoProxy?wsdl )
Give the project name as "EchoProxy". Fill other fields as necessary.
Then Click Ok.
Then try to invoke our proxy service using soapUI as well.
Step 3: Securing the proxy service
Let's secure our proxy service now.
Go to service list (see 1 in Figure 1)
In Service list view, click on unsecured link (see 2 in Figure 1) in the EchoProxy row to secure the proxy.
Figure 1
In next Window, select "yes" to enable security for EchoProxy ( Figure 2)
Figure 2
In this example, I am going to secure proxy service using security scenario 5 - "Sign and Encrypt - X509 Authentication"
So select security scenario 5 under Advanced Scenarios ( Figure 3 ) and click next.
Figure 3
For simplicity of this post, I am going to use wso2carbon.jks as Trusted Key Stores. So in next window ( Figure 4) Select wso2carbon.jks as Trusted Key Stores and click Finish.
Figure 4
Now we have secured proxy our service.
Figure 5
Note: If you try to invoke our proxy service now using tryit or soapUI tool, it will fails. In next step let's try to invoke it by adding Sign and Encrypt - X509 Authentication to the soapUI request.
Step 4: Adding Sign and Encrypt - X509 Authentication to soapUI request.
Step 4.1 - Setting up ws-security configuration to soapUI project.
Right Click on your soapUI project (EchoProxy) and select "Show Project view"
In the opened sub window, click "ws-security configuration" tab.
Now let's add a KeyStore first. For Simplicity I am adding wso2carbon.jks here again. You can find it from $ESB_HOME/repository/resources/security/ . But you can use your own valid keystore here.
Step 4.2 - Adding KeyStore
Go to the keystores tab ( see figure 6)
Add a keystore by clicking the button which is shown using arrow 1 in figure 6.
Select key store file. (ex: $ESB_HOME/repository/resources/security/wso2carbon.jks)
It asks the password of the keystore. Give it. ( for wso2carbon.jks password is wso2carbon )
Then fill the Default Alias and Alias password fields. I am using wso2carbon for both fields.
Figure 6
Step 4.3 - Setting up Out going Security Configuration.
Since our proxy service is secured using sign and encryption, we need to add encryption as well. So add encryption entry similar to Timestamp and signature fields.
Fill the option fields as given in figure 10.
Keystore is wso2carbon.jks;
both alias and password is wso2carbon;
Key Identifier type is X509;
tick the create encryption key check box;
Leave other fields as default;
Then
add a new part; which describes what we are going to encrypt. Since we are encrypting body of the soap11 request, let's add new part like this.
Now we are done with configuring out going message.
[Important] Please note that order of the ws entries matters when we are invoking the secured service. So always add those three one after the other. As an exercise try to change order of timestamp, signature and encryption and try to invoke the service.
Step 4.4 - Setting up Incoming Security Configuration.
Go to incoming ws-security configuration tab.
Similar to outgoing ws-security configuration first add incoming security configuration profile. Name it as EchoProxy-securedResponse
Fill the other fields as showing in figure 11.
Decrypt Keystore=wso2carbon.jks
Signature Keystore=wso2carbon.jks
password=wso2carbon
Figure 11
Step 5 - Invoking secured Proxy service.
Open soap11 request. ( If you have already opened it, you may have to close and re-open it, to apply project changes which you did in step 4)
Click on button aut ( arrow 2 in Figure 12 ). It contains authentication related details.
Select outgoing wss that we created in step 4 from arrow 3.
Select incoming wss that we created in step 5 from arrow 4.
Then Invoke the request 1 by clicking green play arrow.
Figure 12
you can view decrypted response from response window. it is Done :)
[Important] Troubleshooting.
If you are running your system on a fresh JVM, you may face "Illegal key size or default parameters" [1] or similar problems since we are using encryption algorithms in this sample. To fix this you have to patch the JVM by applying "the Java Cryptography Extension (JCE), Unlimited Strength Jurisdiction Policy".
Caused by: org.apache.xml.security.encryption.XMLEncryptionException: Illegal key size or default parameters Original Exception was java.security.InvalidKeyException: Illegal key size or default parameters at org.apache.xml.security.encryption.XMLCipher.encryptData(XMLCipher.java:1140) at org.apache.xml.security.encryption.XMLCipher.encryptData(XMLCipher.java:1081) at org.apache.xml.security.encryption.XMLCipher.encryptElementContent(XMLCipher.java:855) at org.apache.xml.security.encryption.XMLCipher.doFinal(XMLCipher.java:985) at org.apache.ws.security.message.WSSecEncrypt.doEncryption(WSSecEncrypt.java:602) ... 24 more Caused by: java.security.InvalidKeyException: Illegal key size or default parameters at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1011) at javax.crypto.Cipher.implInit(Cipher.java:786) at javax.crypto.Cipher.chooseProvider(Cipher.java:849) at javax.crypto.Cipher.init(Cipher.java:1213) at javax.crypto.Cipher.init(Cipher.java:1153) at org.apache.xml.security.encryption.XMLCipher.encryptData(XMLCipher.java:1137) ... 28 more
HumanTask engine comes with a humantask event generator. These task events are generated when a task goes trough a state transition. An event contains details about tasks and its state transition. So by writing a custom event listener to these events, a developer can easily enhance the HumanTask engine's functionalities.
What developer can do with a task event listener.
Can do custom java code/ web service invocations.
Can retrieve task information.
Developer free to implement their own logic depending on their requirement.
Sample Event Listener.
EventListener class should implement HumanTaskEventListener class and onEvent method. See following sample code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copy it into /repository/components/lib. Where is the root directory of BPS server.
Uncomment TaskEventListeners in HumanTask configuration file (/repository/conf/humantask.xml) and give your Event Listener
class name for ClassName.
eg:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This Post describes, how to you can define a deadline within a human task. For this I am going to extend WSO2 BPS Claim Approval Task sample.
Prerequisite
If you haven't tried the sample yet, try it first. So you get better idea about how human task works.
Download WSO2 BPS 3.0.0 +
an Text Editor.
Note: You can find more information about humantask deadlines and timeouts under section 4.9 in humatask specification. What I am going to do in this sample ...
In this sample, I have set deadline time duration for 5 minuets after task creation. The escalation is defined such a way that, if the claimed amount is less than 10000 and task not started within 5 minutes, then notify task's potential owners that current claim approval task is overdue.
Deploy BPEL package. Creates Roles and Users. But do not deploy humantask package ClaimsApprovalTask.zip since we are going to modify it in next steps.
2) Modify ClaimsApprovalTask.ht
Unzip ClaimsApprovalTask.zip and Add following deadline definition (i.e <htd:deadlines>) inside ApproveClaim task definition (i.e. <htd:task "ApproveClaim"> ) in ClaimsApprovalTask.ht
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I did slight changes to wsdl file for this sample. So replace ClaimsApprovalTaskService.wsdl with this file.
4) Deploy Sample
Create new zip file including all files.(modified and unmodified) and deploy it in BPS.
( you can find modified sample from here )
5) Send a Sample Request.
After deployment, send a sample request (like given in sample page). You can see task is created under clerk login. Do not start the human task.
6) Wait 5 mins.
After 5 mins, deadline will be executed. As a result this, a notification is generated and sent to the clerk. Clerk can view notification under Home -> Human Tasks -> Notifications.
I recently looking for data recovery tool to recover some files in my home folder. I was looking some recover tool for linux, and I found an interesting command line tool call Foremost. Why is it so interesting ?
light weight and easy to install.
Easy to use.
Built in file filters for fast recovery. ( e.g: jpg, zip, rar etc.)
How to install foremost.
Go to terminal and type.
$ sudo apt-get install foremost
Recovering deleted jpgs files in partition
First make an empty writable directory to save recover files in a partition other than that you are going to recover. ( let's say /recovery/data/ )
Then run foremost. I am going to recover my home partition ( let's say /dev/sda5).
Recently I wrote an assembler for DLX architecture using Antlr 3 as an assignment of the Advance architecture course module.
Target
Main target of this assemble is to generate an optimized assembly code by filling delayed branch slots. It can take High level language code segment as a input. First it should generate unoptimized assembly code and then optimized it to fill delayed branch slots.
Why Antlr ?
Antlr supports String template which is a java template engine that can be used to generate any type of formated texts ( source codes, emails, etc). So using string template we can perform language transformation very easily. For example Java to C#, C++ etc. For more details look at Here .
you can find antlr 3 samples at github. I modified the cminus sample available at github for this project.
About project
I used Cminus as High level language and DLX (RISC architecture) as target platform. It used Antlr version 3.
This project is available at Google-code svn repository.
Limitations of the Code
Fills only delayed branched that occurs after unconditional jump. ( j )
Supports multiple for, while and doWhile loops in high level language.
supports only addition.
supports only == and <
do not support variable = variable + variable type assignments
you can build project using maven3. ($mvn clean install) .
Maven build will execute assembler after the build and generate optimized code for sample.txt. asem_optimized.txt and asem_unoptimized.txt will be created after the build.
Improvements to the Code base
I warmly welcome your suggestions and ideas to improve this assembler.
1) Open maven plug-in source code using your favorite IDE ( Eclipse, InterlliJ IDEA etc) and set break points in codes that you are going to debug.
2) Start build project using following command.
$ mvnDebug clean install
3) maven starts to Listen on port 8000 till a remote debugger connects.
$ mvnDebug clean install Preparing to Execute Maven in Debug Mode Listening for transport dt_socket at address: 8000
4) Start remote debug on port 8000 using your IDE. It will trigger the build process with remote debug.
------------------------------------------------------- T E S T S ------------------------------------------------------- Listening for transport dt_socket at address: 5005
4) Start remote debug on port 5005 using your IDE. It will trigger the build process with remote debug.
Here I am using Linux Mint 14 ( Mint is very similar OS to Ubuntu) on Lenovo ThinkPad machine.
Step 1 - is your Finger print reader detected by system...?
First check whether your figer print reader is recognized or not by the system. for this open terminal and run command.
$ lsusb
It shows information about USB buses in the
system and the devices connected to them. Then look for your finger print reader device. (My finger print reader device, Upek is listed in device list.)
..
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 147e:2020 Upek
Bus 001 Device 004: ID 04f2:b2eb Chicony Electronics Co., Ltd
..
Step 2 -Installing fPrint
Use following commands to install fPrint.
$ sudo add-apt-repository ppa:fingerprint/fprint
$ sudo apt-get update
$ sudo apt-get install libpam-fprintd
if Installation is success, the needed lines in common-auth should now be present. for that type following command in terminal
$ grep fprint /etc/pam.d/common-auth
you should observe similar output like this,
auth [success=2 default=ignore] pam_fprintd.so
Final (Fun) Step - configure fPrint
Now run
$ fprintd-enroll
swipe your right index finger until process is completed.
Using device /net/reactivated/Fprint/Device/0
Enrolling right index finger.
Enroll result: enroll-stage-passed
Enroll result: enroll-stage-passed
Enroll result: enroll-stage-passed
Enroll result: enroll-stage-passed
Enroll result: enroll-stage-passed
Enroll result: enroll-stage-passed
Enroll result: enroll-completed
Now you should be able to authenticate (Login, Terminal, Lock screen, and everywhere ) by swiping your right index finger.
see how it works on terminal authentication.
( Note: If finger print fails, then system automatically prompt you to enter password. )
checkout entire Carbon platform ( including trunk, branches, etc.) ( $svn co https://svn.wso2.org/repos/wso2/carbon )
checkout each above svn code locations separately. ( $svn co https://svn.wso2.org/repos/wso2/carbon/kernel/branches/4.0.0/ . Similarly other two locations. )
But first method is too time consuming, because it checkout entire Carbon Platform. So second method seems to be a good choice, but is also have some (minor) negative points.
Since codes are not in same svn structure (as in the first method) in file system, maintaining can be a little bit hard. Also If you need to checkout another location ( for example let's say carbon/platform/trunk ), again you need to checkout it separately.
So it is better to have some mechanism to narrow down the svn scope when checkout the code. There are some reference articles in end of this post. Refer them to get more information about this technique. Let's see how we can do this.
Step 3 - Repeat step 2 for other two locations ( for orbit and platform ).
Advantages:
All three locations are under some svn tree.
Quick.
Limits the scope and skips unnecessary locations.
Taking svn up at svn root directory ( in this example carbon ) will update only above three locations which we made using this examples. other will not update.