标签存档: SOA

Apache Servicemix 简单示例

一个简单的场景,做下笔记:

典型的In-Out接口: cxf-bc(consumer) –> eip “Static Routing Slip” –> saxon –> cxf-bc(provider)

CXF配置

<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:cxfbc=“http://servicemix.apache.org/cxfbc/1.0”
xmlns:xsi=“http://http://www.w3.org/2001/XMLSchema-instance”
xmlns:novaesb=“http://www.hongcheng.com/novaesb/selectnumber”
xmlns:clarity=“http://webservices/clarity/api/numbermanagement”
xsi:schemaLocation=“http://servicemix.apache.org/cxfbc/1.0 http://servicemix.apache.org/schema/servicemix-cxf-bc-3.2.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd”>   

 

<bean id=“propertyConfigurer”
        class=“org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
    <property name=“location”>
        <value>classpath:slt-npe-config.properties</value>
    </property>
</bean>

<cxfbc:consumer wsdl=“classpath:SelectNumber.wsdl”
    service=“novaesb:SelectNumberServer”
    endpoint=“SelectNumberPort”
    locationURI=“${novaesb.selectnumber.url}”
    targetService=“novaesb:routingSlip”
    targetEndpoint=“endpoint”
    useJBIWrapper=“false”/>

<cxfbc:provider wsdl=“classpath:NumberManagementAPIService.wsdl”
    service=“clarity:NumberManagementAPIService”
    endpoint=“NumberManagementAPIPort”
    useJBIWrapper=“false”/>

</beans>

EIP配置

<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns:eip=“http://servicemix.apache.org/eip/1.0”
xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://http://www.w3.org/2001/XMLSchema-instance”
xmlns:novaesb=“http://www.hongcheng.com/novaesb/selectnumber”
xmlns:clarity=“http://webservices/clarity/api/numbermanagement”
xsi:schemaLocation=“http://servicemix.apache.org/eip/1.0 http://servicemix.apache.org/schema/servicemix-eip-3.2.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd”>

<eip:static-routing-slip service=“novaesb:routingSlip” endpoint=“endpoint”>
    <eip:targets>
        <eip:exchange-target service=“novaesb:xslt” endpoint=“endpoint”/>
        <eip:exchange-target service=“clarity:NumberManagementAPIService” endpoint=“NumberManagementAPIPort” operation=“clarity:getNumbersViaAreaHierarchy”/>
    </eip:targets>
</eip:static-routing-slip>

</beans>

XSLT

<?xml version=”1.0″ encoding=”UTF-8″?>
<xsl:stylesheet version=‘1.0’
xmlns:xsl=‘http://www.w3.org/1999/XSL/Transform’
xmlns:novaesb=“http://www.hongcheng.com/novaesb/selectnumber”
xmlns:clarity=“http://webservices/clarity/api/numbermanagement”> 

 

<xsl:namespace-alias stylesheet-prefix=“novaesb” result-prefix=“clarity”/>

<xsl:output method=“xml” indent=“yes” encoding=“UTF-8”/>

<xsl:template match=“//novaesb:getNumbersViaAreaHierarchy”>
    <clarity:getNumbersViaAreaHierarchy>
        <ServiceType><xsl:value-of select=“novaesb:ProductName”/></ServiceType>
        <NumberType><xsl:value-of select=“novaesb:CustomerLevel”/></NumberType>
        <Area><xsl:value-of select=“novaesb:Area”/></Area>
        <CityCode><xsl:value-of select=“novaesb:CityCode”/></CityCode>
        <NumberStatus><xsl:value-of select=“novaesb:NumberStatus”/></NumberStatus>
        <HowMany><xsl:value-of select=“novaesb:HowMany”/></HowMany>
        <NumberPattern><xsl:value-of select=“novaesb:NumberPattern”/></NumberPattern>
        <ConsecutiveFlag><xsl:value-of select=“novaesb:ConsecutiveFlag”/></ConsecutiveFlag>
    </clarity:getNumbersViaAreaHierarchy>
</xsl:template>

</xsl:stylesheet>

可以看到,这里我去掉了JBI的包装,而采用了SOAP的包装,这里是无所谓的.个人建议采用SOAP包装.