Thursday, December 04, 2008

Manggil Service WebMethods pakai Servlet di build pake Maven2

Environment
Sebelum mulai ada beberapa environment yang perlu dipersiapkan, diantaranya tools/teknologi yang saya gunakan untuk percobaan ini adalah:
1. Eclipse Gannymede(ato versi lainnya)
2. Maven2
3. Servlet
4. JSP
5. WebMethods+Integration Server 6.5


yang lainnya lebih lengkapnya liat disini:
http://forum.swamedia.co.id/viewtopic.php?p=628#628

Kelas
Ini kelas servlet-nya
package test;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.wm.data.*;
import com.wm.app.b2b.server.Service;

public class UpperCase extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;

// Allows you to have finer control over the logging levels
private static Log log = LogFactory.getLog( UpperCase.class );


public void doPost( HttpServletRequest request,
HttpServletResponse response)throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
ServletContext ctx = getServletContext();

// Will show on IS level 8
ctx.log("logging a string in the IS server log via the Servlet API");
log.info("Servlet logging at the IS level 4");
log.debug("Servlet logging at the IS level 8");


//passing parameter to variabel
String param1 = request.getParameter("param1");
String param2 = request.getParameter("param2");

// INPUT -----------------------
IData input = IDataFactory.create();
IDataCursor inputCursor = input.getCursor();
IDataUtil.put( inputCursor, "inString", param2+param1 );
IDataUtil.put( inputCursor, "language", "language" );
IDataUtil.put( inputCursor, "country", "country" );
IDataUtil.put( inputCursor, "variant", "variant" );

// OUTPUT -----------------------
IData output = IDataFactory.create();
IData output2 = IDataFactory.create();

// invoke the WM service riset:getUpperName
/*try{
output = Service.doInvoke( "riset", "getUpperName", input );
}catch( Exception e){}
IDataCursor outputCursor2 = output2.getCursor();
String name = IDataUtil.getString( outputCursor2, "name" );
*/
// invoke the WM service pub.string:toUpper
try{
output = Service.doInvoke( "pub.string", "toUpper", input );
}catch( Exception e){}
IDataCursor outputCursor = output.getCursor();
String value = IDataUtil.getString( outputCursor, "value" );

//destroy the cursor
inputCursor.destroy();
//outputCursor2.destroy();
outputCursor.destroy();


}
}




PROSES
Setelah environment-nya dipersiapkan, selanjutnya adalah proses berikutnya
1. Build source di eclipse menggunakan Maven2. Atau jika tidak ada bisa menggunakan builder apapun. Intinya kita ingin mendapatkan paket WAR-nya (WAR=Web Archive). Klo menggunakan eclipse cukup mudah (tentunya klo plugin Maven2 sudah di install di eclipse). Jalankan Run As->Maven Packages.

2. Setelah itu masukan file war-nya (dalam hal ini CobaServlet.War) ke dalam folder /web/webapps.

3. Kemudian jalankan service pada packages WmTomcat, wm.tomcat:hotdeploy.

4. Jadi deh Packages CobaServlet-nya, selanjutnya tinggal dijalankan deh.

5. Ok, Selamat Mencoba!! Jika ada masukan silahkan hubungi saya ok! Terima kasih.

3 komentar:

Anonymous said...

[url=http://www.hi5.com/friend/group/4441177--natrol+tonalin+cla--front-html]natrol tonalin cla[/url]
[url=http://www.hi5.com/friend/group/4440535--soft+hackle--front-html]soft hackle[/url]
[url=http://www.hi5.com/friend/group/4441347--nail+salon+software--front-html]nail salon software[/url]
[url=http://www.hi5.com/friend/group/4440490--murad+acne+complex+kit--front-html]murad acne complex kit[/url]
[url=http://www.hi5.com/friend/group/4441743--codeine+cough+syrup--front-html]codeine cough syrup[/url]
[url=http://www.hi5.com/friend/group/4442403--kirkland+vitamin+c--front-html]kirkland vitamin c[/url]
[url=http://www.hi5.com/friend/group/4440594--metoprolol+tartrate--front-html]metoprolol tartrate[/url]
[url=http://www.hi5.com/friend/group/4442319--ageless+skin+care--front-html]ageless skin care[/url]
[url=http://www.hi5.com/friend/group/4440486--ginseng+powder--front-html]ginseng powder[/url]
[url=http://www.hi5.com/friend/group/4442036--edms+software--front-html]edms software[/url]
[url=http://www.hi5.com/friend/group/4441025--edms+software--front-html]edms software[/url]
[url=http://www.hi5.com/friend/group/4440527--natrol+tonalin+cla--front-html]natrol tonalin cla[/url]
[url=http://www.hi5.com/friend/group/4441785--pc+miler+software--front-html]pc miler software[/url]
[url=http://www.hi5.com/friend/group/4442120--maker--front-html]maker[/url]
[url=http://www.hi5.com/friend/group/4442285--ab+initio+software--front-html]ab initio software[/url]
[url=http://www.hi5.com/friend/group/4440501--soft+sole+infant+shoes--front-html]soft sole infant shoes[/url]
[url=http://www.hi5.com/friend/group/4440788--spironolactone+hair+loss--front-html]spironolactone hair loss[/url]
[url=http://www.hi5.com/friend/group/4442210--edms+software--front-html]edms software[/url]
[url=http://www.hi5.com/friend/group/4440845--mortgage+loan+origination+software--front-html]mortgage loan origination software[/url]
[url=http://www.hi5.com/friend/group/4441678--oxycontin+addiction+treatment--front-html]oxycontin addiction treatment[/url]

No one would choose a friendless existence on condition of having all the other things in the world.
wadon9981k

Anonymous said...

I have a family plan so I've heard that can make the overally monthly cost less but I'm not positive. On my family plan, we have an unlimited texting plan already. Does that texting plan carry over if I get the Iphone? I also want internet use. Any estimate at a monthly cost?



________________
[url=http://unlockiphone22.com]unlock iphone[/url]

Anonymous said...

My friend wants to give me her old iphone since she is getting the new one, but I am unsure if i can reset it and make it work with my number and bill since they don't let you change sim cards with ease. Any help would be nice!



________________
[url=http://unlockiphone22.com]unlock iphone[/url]

This Day in History