[jboss-user] [EJB 3.0] - Re: EJB3 WebServices

dasariprasad do-not-reply at jboss.com
Sun Nov 5 10:10:45 EST 2006


I had tested one webservice example in jboss4.0.5GA  & ejb3(version RC9, i suppose) the following are files

SimpleWS.java

package com.htc.htcws;
import javax.ejb.Remote;
@Remote
public interface SimpleWS extends java.rmi.Remote 
{  
   public  String greet(String person)
          throws  java.rmi.RemoteException;             
}

SimpleWSBean.java

package com.htc.htcws; 

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import org.jboss.annotation.ejb.RemoteBinding;
      
@Stateless
@WebService(name="EndpointInterface",
            targetNamespace="http://htcws.htc.com/jaws",
            serviceName="SimpleWSService")
@RemoteBinding(jndiBinding="/ejb3/EJB3EndpointInterface")   @Remote(com.htc.htcws.SimpleWS.class)
@SOAPBinding(style=SOAPBinding.Style.RPC)    

public class SimpleWSBean implements SimpleWS
{
  @WebMethod
  public  String greet(String person) 
  {
   return "Hi "+person+" all Good Wishes for Diwali";
  }
  
}

the build.xml

<?xml  version="1.0" ?>

 
  
 
  
  
   
    

  

  
 
 

   

  
 
     
     
      
     
      
                 
      
    

    
     
     
     
    

  
     
   
  

 
    
     
       
        
    


  
  
   
     
    
      
   
    
   

     

  
       
        
        
       
  

 

  first i ran 
   from my directory >ant

  then started server

   d:\jbossejb3\bin>run -c all

 then tested the client

 SimpleWSClient.java

package com.htc.htcws;

import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Service;
import javax.xml.namespace.QName;
import java.net.URL;

public class SimpleWSClient
{                                      


 public static void main(String[] args)
 {   
    final String _NAMESPACE = "http://htcws.htc.com/jaws";
    final String _SERVICE = "SimpleWSService";
  
   
  try
  {
   URL url =  
     new URL("http://localhost:8080/simpws/SimpleWSBean?wsdl");
 
    QName qName = new QName(_NAMESPACE,_SERVICE);
    if(args.length!=1)
 
    {
      System.out.print("Give the person-name as args[0]");
      System.exit(1);
    }  
    
    

    ServiceFactory sFactory = ServiceFactory.newInstance();
    
    Service service = sFactory.createService(url,qName);

    SimpleWS invoker =
            (SimpleWS)service.getPort(SimpleWS.class);

     String res = invoker.greet(args[0]);
     System.out.println("Response is :"+res);
   }
   catch(Exception ex)
   {
       System.err.println("Caught the exception as"+ex);
   }
  }

}

    > ant   java
  
  it is working fine (except a warning that log4j not configured)

  just made a beginning  may be helpful to you

                       all good luck
                       Prasad DTR
                       rajendra32 at yahoo.co.uk


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983299#3983299

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983299



More information about the jboss-user mailing list