WEBLOGIC EJB 实现

 EJB 为远程提供JNDI 代码如下:

 

@Stateless(mappedName = "HelloWorldBean")
@Remote({HollowWorld.class})
public class HollowWordBean implements HollowWorld,Serializable{

 private static final long serialVersionUID = 1L;

 // @Override
 public void remotePrintln() {
  // TODO Auto-generated method stub
  System.out.println("remote is run!!");
 }

}

 

系统测试代码为:

 

       java.util.Properties prop = new java.util.Properties();  
      prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,  
              WLInitialContextFactory.class.getName());  
      prop.setProperty(Context.PROVIDER_URL, "t3://localhost:7001"); //
      prop.setProperty(Context.SECURITY_PRINCIPAL, "user");
      prop.setProperty(Context.SECURITY_CREDENTIALS, "12345678");
      InitialContext ic = new InitialContext(prop);     
     
      UserOptionTestDao  userOptionDao = (UserOptionTestDao)ic.lookup           ("userDao#com.yineng.jpa.UserOptionTestDao");//lookup的名称在weblogic 中可以查找到

 

 

EJB 提供webservice服务的代码:

 

  /**
 *@see 本地的webservice实现类
 *@author desert
 *@version 1.0
 */
@Stateless
@WebService(name = "HelloWorldService",  serviceName = "HelloWorldService",targetNamespace=Contants.targetNamespace)
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class HelloWorldService implements HelloWorldServiceInteface{
 
 @WebMethod
 @WebResult(name="String")
 public String  sayHello(@WebParam(name = "name")String name){
  return name+ "说:这是我的第一个web 服务";
 }

}

 

系统的测试代码:

       创建远程接口

      @WebService(targetNamespace=Contants.targetNamespace) //必须要否则无法调取远程               (targetNamespace="http://127.0.0.1")
           public interface HelloWorldServiceInteface{
    
                    @WebMethod   //必须要否则无法调取远程
                    @WebResult(name="String")   //必须要否则无法调取远程
                  public String  sayHello(@WebParam(name = "name")String name);
 
            }

 

  测试类(用的Apache 的 cxf 解析webservice):

  ApplicationContext ctx = new ClassPathXmlApplicationContext(  
                 "applicationContext.xml");  
        
         HelloWorldServiceInteface client = (HelloWorldServiceInteface) ctx.getBean("client");  

         String result = client.sayHello("HELLO");  

         System.out.println(result);  

 

   cxf 在spring 中的配置文件如下:

    <!--载入webservice properties-->
    <bean id="propertyConfigurer"
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:webservice-config" />
    </bean>                 
    
    
    <bean id="client" class="com.yineng.webservice.HelloWorldServiceInteface"
                             factory-bean="clientFactory" factory-method="create"/>

    <bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
                    <property name="serviceClass" value="com.yineng.webservice.HelloWorldServiceInteface"/>
                    <property name="address">
                        <value>${ws-test}</value>
                    </property> 
 
    </bean>

 

    webservice-config 文件内容如下:

                  ws-test=http://127.0.0.1:7001/HelloWorldService/HelloWorldService

 

  这个时SOA 最基本要了解的 如果有业务流程的话 可以用BPEL (自己探索)。下面有个详细的文档下载;如有误请谅解。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值