login button

Web Service To Create a New Service in WSO2 Mash Up Server from remote?

Forums :

Hello,
Is there a Web Service To Create a New Service in WSO2 Mash Up Server from remote?

Thanks,
Benny

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

There are a few options

Hi Benny,

Are you looking to consume another service from your Mashup? If thats the case there are a couple of ways you can do it with the WSO2 Mashup Server.

1. Use a JavaScript stub (you can use the stub generator tool in the Mashup Server to do this). You can find a sample of it http://mooshup.com/mashup.jsp?path=/mashups/keith/StubUsageSample

2. The second option is to use the WSRequest host object. A sample of this can be fount at http://mooshup.com/mashup.jsp?path=/mashups/samples/exchangeRate

The above options are already available in the 1.0 release. We will be releasing the 1.5 version out next week. This will be loaded with more options (You can give the URL of WSDL of the external service and access it specifying the operation to invoke).

Please let us know if you run into any issues trying these out.

Thanks,
Keith.
http://www.keith-chapman.org

Not to consume ...To add a new service to my Mashup server

Hello again,

Thank you for your answer.
I don't need to consume web services from the mash up service I need to add Services to the Mash Up Server without the GUI.
I'm developing a web application that gets a javascript file and when I get the Javascript file I need to add it to my mash up server somehow. (without using the GUI)
What are the options for that?
Can you please get more inside the techniqual issues?

Thank you in advance,
Benny

Simple drop in the js file to the users folder

If you need to add services you can simply drop in .js files to the users directory. For e.g my mashups (assuming my username is keith) can be found in $mashup_home/scripts/keith. So if a drop in foo.js in to this folder the Mashup Server will pick it and create a service from it. Is this is what your looking for?

Thanks,
Keith.
http://www.keith-chapman.org

Yes, this is what I meant

Thank you for your answer. I knew about this, but is there another way other than just drop the files? like a web service or something else?
Thanks,
Benny

You can try calling the admin services directly

When services are created using the UI it calls a backend web service, but these admin services are secured, hence you cannot call them unless u login. A workarond will be for you to login to the server and then call the admin service that creates new mashups.

Thanks,
Keith.
http://www.keith-chapman.org

Good idea - Do you have an example of piece of code?

Thank you Keith - this workaround sounds great to me.
Do you have an example of piece of code that is doing that?
I need the techniqual solution.
Thanks,
Benny

Java or JavaScript?

Are you trying to call this service using JavaScript or Java?

Thanks,
Keith.
http://www.keith-chapman.org

I'm not sure - can you please give me the solution for both?

Thank you Keith!!
I'm not sure yet - can you please give me the solution for both?
It will be really really helpful!!!
Thank you in advance,
Benny

Might be easier to write a new service

Actually the backend services require the payload to be encrypted so you wont be able to access these services using JavaScript. It might actually be easier for you to write a Java Service that takes care of this. You could have a look at the actual source of MashupAdminService [1](saveUISource method) that takes care of saving a mashup. You could then call this service with ease.

[1] https://svn.wso2.org/repos/wso2/trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service

Thanks,
Keith.
http://www.keith-chapman.org

Thank you I'll try this and let you know

Thank you Keith!
I'll try this and let you know.
I appriciate your help very much!
Thanks,
Benny

How can I write a code only in my application/web server?

Hi Keith,

This code is part of the mash up server. Do you mean that I'll change the code of the Mash up server, or write more services inside the mashup server?

How can I write a code only in my application/web server?
I really need help here...
There are so many includes there..
Thanks,
Benny

Options

I agree trolling through the code can be difficult (unless you're keith ;-). I'll try to list all the options I can think of to get you where you want to be.

There are three ways to get the Mashup Server to pick up a new service:

1) Through the online editor, which calls the backend services. You might be able to write a mashup that scrapes this page though that's a total hack and I'd only contemplate it as a temporary proof-of-concept.

2) Through the file system. Perhaps you could enable ftp or some other file system access to the Mashup Server scripts folder and publish mashups into this folder directly from your application. Maybe a Java service hosted on the Mashup Server that gives remote read/write to that folder...

3) Through the backend services directly. This is probably the best way, but these backend services aren't documented well for end-user access and might require some work to figure out. The WSDLs for these services are at http://localhost:7762/services/MashupLoginServiceUT?wsdl and http://localhost:7762/services/MashupAdminService?wsdl.

It is also possible for us to provide some custom development services to provide you a client for the backend services that you could easily integrate into your application, if that's appropriate for your project.

Small client application(code) that uses the web services

Thank you Jonathan!! :)

I find the 3rd option as the best one for me too! Can you please provide me an exmaple of a small client application(code) that uses the web services to add a new service? It will be so helpful to me!!

Thank you in advance,
Benny

Have a look at the code in ..

You can have a look at the code inside editor.jsp, which has code for maintaining a login, encoding the source code for transmission and submitting the encoded code to the back-end service through java script. All the back-end calls are handled via the services.js file.

The code is well commented most of the time so it shouldn't be that hard to figure out what's going on.

Tyrell

editor.jsp is part of the mash up server

Hi Tyrell,

editor.jsp is part of the mash up server and I need to do it from my application. How can I solve it?

Thanks,
Benny

Hi Benny, You can go through

Hi Benny,

You can go through the code of editor.jsp and mimic the behavior in your applications jsp page. Assuming you have the latest SVN check-out, I'll put down some line numbers of interest.

Note: When you copy and include files from the Mashup Server in your application, you are required to keep the license headers found in those files as stated in the Apache 2.0 license. Please have a look at http://www.apache.org/licenses/LICENSE-2.0.html for a complete text of this license.

First of all you will need the following JavaScript files included in your jsp page.
1. WSRequest.js
2. main.js
3. services.js

Once done have a look at the following lines;

mashup.jsp
----------
Lines 159 to 252 : Contains javascript functions to call the actual service, which saves the source code.

Once you are familiar with the code, have a look at the service calls and callbacks inside services.js (from where all service calls are made ).

To remotely login to the server use the service 'MashupLoginServiceUT' and the operation 'login'. You can user the WSRequest.js directly for this purpose, the options to be set in this call are username, password and Cookie.

The value for Cookie is your JSESSIONID, which is what you get from calling session.getId() in jsp.

Hope this helps to get you started,

Tyrell

Problems ...Please help

I Tyrell - I have some serious problems and I need your help:

1. I couldn't find the WSRequest.js in wso2-mashup-server-1.0.2-src.zip

2. I took pieces of code from editor.jsp and services.js, but I'm stuck in:
new wso2.wsf.WSRequest(callURL, "saveServiceSource", body_xml, callback, params, wso2.mashup.services.defaultErrHandler);

I don't know where is "wso2.wsf.WSRequest".

3. I can't define functions like wso2.mashup.services.saveServiceSource = function (path, modifiedSource, callback, params) {

I define them like that:
function saveServiceSource(newSource, isRedirect) {
....
}

4. Why do I need the Mashup.jsp? Can I use code from editor.jsp and service.js only?

Thank you very much,
Benny

More problems:)

Hi Tyrell ,

5. also I can't find main.js in wso2-mashup-server-1.0.2-src.zip.

It will be really helpful if you can make a simple example(web application) how to add a service from remote - It's getting a bit complicated here:)
I'll be very happy for any help!:)

Thanks,
Benny

Here is where you can find there files

Hi Benny,

main.js can be found in MASHUP_HOME/lib/tomcat/webapps/wsasadmin/js/main.js you can access it at http://localhost:7762/wsasadmin/js/main.js through the browser.

WSRequest.js can be found at MASHUP_HOME/lib/tomcat/webapps/ROOT/js/wso2/WSRequest.js hence you can access it at http://localhost:7762/js/wso2/WSRequest.js through the browser.

Thanks,
Keith.
http://www.keith-chapman.org

Thank you Keith

Hi Keith,
Do you know the answer for:
Why do I need the Mashup.jsp? Can I use code from editor.jsp and service.js only?

Is it possible to make a small(web application) sample as a simple case study?

Thanks,
Benny

Can u grab tomorrows release

Hi Benny,

We will be releasing the 1.5 version of the Mashup Server tomorrow. Tomorrows release will have the ability to call secure services from Mashups itself with ease. Can you hold on till tomorrow please. If we grab the release tomorrow you can write a simple Mashup that can deploy these services for you. I think that might be the easiest way for you to pull this off and I'll be glad to help.

Thanks,
Keith.
http://www.keith-chapman.org

Thank you Keith

Sure I can wait:) , but I'll need the same help - a small web application that need to add a service to the Mashup server from remote.
Will you be able to help?
Thanks,
Benny

Hi Benny, It's not

Hi Benny,

It's not mashup.jsp but editor.jsp, where you need to go through the code lines mentioned.

Looks like Keith provided the details on where to find the other files as well.

Tyrell

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.