WebService连接

WebService连接主要是在WebService中用于连接客户端与服务端,以此来保证客户端可以根据配置的相关信息进行请求报文的准确发送和服务端的报文接收。

连接配置

  • WebService连接WSClientConnection所在位置:lib==>be-esb-plugin-third-2.0.jar==>com==>brilliance==>eibs==>core==>service==>instance==>impl==>WSClientConnection
  • WSClientConnection插件需要继承插件共有的父类AbsConnection

1666334101728

  • commons.xml的connections中注册该连接,连接属性可以在客户端根据具体请况进行针对性的配置
<connections>
    <connection class="WSClientConnection" id="wsClient"/>
</connections>
  • WebService连接WSClientConnection配置
属性 说明 示例
uri WebService URL地址可以根据实际服务端的URL进行修改 http://218.249.92.82:10043/ServiceESB
class 接口类 com.brilliance.esb.service.IService
method WebService接口调用方法,暂不修改,可以通过argument标签配置方法参数 doSomething
  • 客户端属性配置
<connection ref="wsClient">
    <!--WebService URL地址可以根据实际服务端的URL进行修改-->
    <property name="uri" 
              value="http://218.249.92.82:10043/ServiceESB" />
    <!--接口类-->
    <property name="class"  
              value="com.brilliance.esb.service.IService" />
    <!--WebService接口调用方法,暂不修改-->
    <property name="method" value="doSomething">
        <argument value="${this}" />
    </property>
</connection>

配置示例

JavaBean配置

  • 在cfg/beans目录中配置WebService接口和实现类,以及javabean对象。以下为cfg/beans/ServiceESB.xml文件配置:
<?xml version="1.0" encoding="UTF-8"?>
<root serviceid="ServiceESB">
   <!--接口类-->
    <class name="IService" package="com.brilliance.esb.service"
        type="interface">
        <method name="doSomething" return="String">
            <argument name="arg" type="String" />
        </method>
    </class>
   <!--接口实现类-->
    <class name="ESBServerImp" package="com.brilliance.esb.service"
        type="class" impl="com.brilliance.esb.service.IService">
        <method name="doSomething" return="String">
            <argument name="arg" type="String" />
            <call interfaceName="esbservice" transactionName="bmq" /><!-- 
                call为接口平台接口调用实现所需 -->
                <!--接口处理逻辑入口-->
        </method>
    </class>
</root>

服务端配置

  • cfg/etc/services.xml文件配置
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://www.brilliance.com.cn/service" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.brilliance.com.cn/service schema/service.xsd">

<services state="on" hotDeploy="on">                  
    <service id="ESB" state="on" type="webservice">                               
        <!-- 自动生成实现类 -->                         
        <property name="beanname" value="ServiceESB.xml"/>                                   
        <!-- 服务发布地址 -->                           
        <property name="uri" value="http://218.249.92.82:10043/ServiceESB"/>                                                       
        <!-- 处理服务的实现类 -->                           
        <property name="class" value="com.brilliance.esb.service.ESBServerImp"/>                                         
    </service>
</services>
</root>

客户端调用

  • cfg/main/esbclient.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://www.brilliance.com.cn/interface" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.brilliance.com.cn/interface ../etc/schema/interface.xsd">

    <interface id="esbclient" type="client" basePackage="com.brilliance.eibs.core.service.instance.impl" version="2.0">
        <transaction id="request" version="2.0">
            <step id="1">
                <!--组装XML报文,作为WebService的请求报文-->
                <filter type="out" ref="xmlFilter" encoding="GBK">
                    <field etag="root.name" value="zhangsan"></field>
                    <field etag="root.month" value="08"></field>
                </filter>
                <!--WebService客户端调用-->
                <connection ref="wsClient">
                    <!--WebService URL地址可以根据实际服务端的URL进行修改-->
                    <property name="uri" 
                        value="http://218.249.92.82:10043/ServiceESB" />
                    <!--接口类-->
                    <property name="class"  
                        value="com.brilliance.esb.service.IService" />
                    <!--WebService接口调用方法,暂不修改-->
                    <property name="method" value="doSomething">
                        <argument value="${this}" />
                    </property>
                </connection>
                <!--输出返回信息-->
                <filter ref="publicFilter" type="in">
                    <field value="${this}" />
                </filter>
            </step>
        </transaction>
    </interface>
</root>

results matching ""

    No results matching ""