-
1. Re: export stateless session bean as webservice
jonlee Aug 18, 2003 8:37 PM (in response to reeves)UserInfo may be too complex for the standard deserializer to handle. It doesn't look like a standard Bean in that there are not the standard setters and getters. Also, you have a complex get and set element with a String[]. Check the Axis site and the associated WIKI for more information on custom serializers and deserializers. There are also more in-depth discussions in the Axis mailing lists.
That is all I can suggest at this stage. -
2. Reply myself to my question and YES it's POSSIBLE
reeves Aug 19, 2003 9:28 AM (in response to reeves)In your Ant file :
Add : <fileset dir="${java.dir}" includes="**/webservice/*.java" /> to your ejbdoclet task
werservice is the directory which contains all your webservice bean
Add this subtask to ejbdoclet task
<jbossnet prefix="yourPrefix"
destdir="${build.dir}/META-INF/" />
you should have something like :
next write your session bean and your UserInfo bean
in a directory name "webservice"
---------------------------------------------------------
package com.xxx.domain.test;
import javax.ejb.CreateException;
import javax.ejb.DuplicateKeyException;
import javax.ejb.EJBException;
import javax.ejb.FinderException;
import javax.ejb.SessionBean;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
*
* @ejb.bean
* name="ManageUser"
* type="Stateless"
* view-type="both"
*
* @ejb.transaction
* type="Required"
*
* @jboss-net.web-service urn="HelloWorldService"
*
*/
public abstract class ManageUserEJB
implements SessionBean
{
/**
* @ejb.interface-method view-type="local"
* @jboss-net.web-method
* @jboss-net.wsdd-operation returnQName="ResponseString"
* @return the string "Hello " + name + "!"
*/
public String hello(String name)
{
return "Hello " + name;
}
/**
* @ejb.interface-method view-type="local"
* @jboss-net.web-method
* @jboss-net.wsdd-operation returnQName="ResponseUserInfo"
*/
public UserInfo login(String name,String password)
{
UserInfo u = new UserInfo();
if ( name.equals("user1") &&
password.equals("password1"))
{
u.setAuthentified(true);
String[] tabPlugin = {"plugin1","plugin2","plugin3"};
u.setUserPlugins(tabPlugin);
System.out.println("Valid [" + u.isAuthentified() + "]");
}
else
{
u.setAuthentified(false);
String[] tabPlugin = new String[0];
u.setUserPlugins(tabPlugin);
System.out.println("Valid [" + u.isAuthentified() + "]");
}
return u;
}
//==========================================
// EJB callbacks
//==========================================
/**
* @ejb.create-method
*/
public void ejbCreate( )
throws CreateException {}
public void ejbPostCreate( )
throws CreateException {}
}
---------------------------------------------------------
package com.xxx.webservice;
/**
*
* @jboss-net:xml-schema urn="yourPrefix:UserInfo"
*/
public class UserInfo implements java.io.Serializable
{
private boolean authentified;
private String[] userPlugins;
public UserInfo() {
}
public boolean isAuthentified() {
return authentified;
}
public void setAuthentified(boolean authentified) {
this.authentified = authentified;
}
public String[] getUserPlugins() {
return userPlugins;
}
public void setUserPlugins(String[] userPlugins) {
this.userPlugins = userPlugins;
}
}
And that's all ! web-service.xml contains all you want !
Going to write a real tutorial that explain all this process
and post it here.
Just one more thinks, notice that you have to use
String[] instead of java.lang.String[] don't know why .... :-(