SCA与spring集成(在spring中开发SOA)

客户端调用与Tuscany SCA相同

服务端的配置如下:

sca.composite

<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
    targetNamespace="http://myWebServer"name="myWebService">    
      <!-- 绑定服务-->
       <service name="myWebService" promote="myComponent">
                <!--服务的接口-->
                <interface.java interface="com.server.MyServiceInterface"/>
             <binding.ws uri="http://127.0.0.1:8082/myWebService"/>
    </service>
    <component name="myComponent">
              <!--该服务的spring配置文件地址-->
         <implementation.spring location="spring/spring-configuration.xml"/>
    </component>     
</composite> 

此外还需要添加spring配置文件,在src目录下新建spring目录

spring-configuration.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:sca="http://www.springframework.org/schema/sca"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                        http://www.springframework.org/schema/beans/spring-beans.xsd   
                        http://www.springframework.org/schema/sca 
                        http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">

<!-- 配置服务 -->
    <sca:service name="myWebService"  
        type="com.server.MyWebServiceInterface" target="myFunction"/>
<!--配置bean-->
<bean id="myFunction" class="com.server.myFunction">
    ......   
</bean>    

<sca:service>标签说明:

该标签将spring bean开放为一个SCA服务,这个服务也需要在SCA段的.composite配置文件中声明,否则SCA会抛出配置错误。如果在spring配置文件中没有<sca:service>标签声明,则所有bean都会作为服务开放(不建议这么做)。

该标签有三个属性:name属性指出服务的名称,该名称应和SCA段的.composite配置文件中声明的服务名称相同;type属性指出服务构件对应的java接口;target指出在spring应用配置文件中声明的bean对象名称。

此外,在spring配置中声明与SCA之间的关联还有来自spring sca 命名空间的两个标签。<sca:property>:将一根SCA构件的属性定义为一个spring bean。<sca:reference>:将定义一个来自SCA服务端构件实现的spring sca,供spring配置文件中的其他bean使用。但这两个标签似乎没有太多使用的必要。

在服务端启动webservice 与Tuscany中相同。 
原文地址:https://www.cnblogs.com/vitosun/p/3777331.html