How to add different projects to your OSB Configuration project

When you manually setup your OSB Config project or when you get it automatically created from an sbconfig.jar file you will always have your project properly nested to your configuration project, like in the image below:

OSB_Config_Project_Nested
The thing is when you already have a project into another folder or config project and you need to import it to yours. When you do that, the project will be shown like this:
OSB_Config_Project_Foreign_Project
You will also get an error telling you the project is not associated with a Oracle Service Bus Configuration Project, like you see below.
OSB_Config_Project_Not_Assosciated_Error
What you have to do is go to your <OSB Config Project home folder>/.settings and edit the com.bea.alsb.core.prefs file.
All you have to do is add the name of your project to the container.referenced.projects property, separated by pipe “|”, like below
#Fri Feb 08 14:48:55 BRST 2013
 ACTIVATION_DESCRIPTION_PROPERTY=Publish from Oracle Service Bus IDE.
 CUSTOMIZATION_FILE_PROPERTY=
 DISCARD_SESSION_PROPERTY=true
 KEYSTORE_PROPERTYfile=
 KEYSTORE_PROPERTYpassword=
 PUBLISH_SESSION_NAME_PROPERTY=OSB_Publish
 SERVER_PROPERTY=
#VRS: Add the project here:
 container.referenced.projects=Local Project|Foreign Project
 eclipse.preferences.version=1
Now restart the eclipse and you are all done!
OSB_Config_Project_ReNested
Thank you!

Calling a RESTful web service from an Android application

This a simple example of how you can call a RESTful web service from an Android application.
First of all, you need to request a permission to access network. This can be done by adding the following tag to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

Then we can go to the actual implementation. The easiest way is to use Apache Http Client, which is bundled with Android:

        HttpClient httpclient = new DefaultHttpClient();
        HttpResponse response;
        String responseString = null;
        try {
            response = httpclient.execute(new HttpGet(uri[0]));
            StatusLine statusLine = response.getStatusLine();
            if(statusLine.getStatusCode() == HttpStatus.SC_OK){
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                response.getEntity().writeTo(out);
                out.close();
                responseString = out.toString();
            } else{
                //Closes the connection.
                response.getEntity().getContent().close();
                throw new IOException(statusLine.getReasonPhrase());
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

If you want it to run on separate thread I’d recommend extending the AsyncTask:

class RequestTask extends AsyncTask<String, String, String>{

    @Override
    protected String doInBackground(String... uri) {
        HttpClient httpclient = new DefaultHttpClient();
        HttpResponse response;
        String responseString = null;
        try {
            response = httpclient.execute(new HttpGet(uri[0]));
            StatusLine statusLine = response.getStatusLine();
            if(statusLine.getStatusCode() == HttpStatus.SC_OK){
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                response.getEntity().writeTo(out);
                out.close();
                responseString = out.toString();
            } else{
                //Closes the connection.
                response.getEntity().getContent().close();
                throw new IOException(statusLine.getReasonPhrase());
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return responseString;
    }

    @Override
    protected void onPostExecute(String result) {
        super.onPostExecute(result);
        //Do anything with response..
    }
}

The AsyncTask class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers. An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread.
You then can make a request by adding the following line to your code:

RequestTask task = (RequestTask) new RequestTask().execute("http://www.myserver.com/rest/myservice");

If you are going to access a service from your local machine, keep in mind that the localhost IP address for Android is 10.0.2.2 instead of 127.0.0.1.
After the execute method returns, you just have to call the following method to get the response:

	        try {
				String message = task.get();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ExecutionException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

From there, you can manipulate the response message the way you need.

That’s it!
Thanks!