在SOAP的开发过程中,我们会经常需要编写jms的xml配置文件,所以需要清楚的了解jms中各个标签和其属性的含义与wsdl的对应关系:
1、服务方jms:
<?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:cxf="http://cxf.apache.org/core" xmlns:soap="http://cxf.apache.org/bindings/soap" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jms="http://cxf.apache.org/transports/jms" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schema/bindings/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-local.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-jms.xml" /> <jaxws:endpoint id="IntervalRateServiceEpt" implementor="com.srcb.esb.intervalrateservice.v1.IntervalRateServicePortTypeImpl" address="jms://IntervalRateService"> <jaxws:properties> <!-- 修改默认的SOAP编码 --> <entry key="org.apache.cxf.message.Message.ENCODING" value="UTF-8" /> </jaxws:properties> <jaxws:features> <!-- 增加日志特征 --> <bean class="com.main.util.MySysCom.cxflog.CxfLoggingFeature" /> <!-- 注入JMS配置对象 --> <bean class="org.apache.cxf.transport.jms.JMSConfigFeature" p:jmsConfig-ref="intervalRateServiceConfig" /> </jaxws:features> <!-- 配置路由拦截器,重定向服务 --> <jaxws:inInterceptors> <bean class="com.srcb.esb.interceptor.MediatorInterceptor" /> </jaxws:inInterceptors> </jaxws:endpoint> <jaxws:endpoint id="IntervalRateServiceEpt1" implementor="com.srcb.esb.intervalrateservice.v1.IntervalRateServicePortTypeImpl" address="jms://IntervalRateService"> <jaxws:properties> <!-- 修改默认的SOAP编码 --> <entry key="org.apache.cxf.message.Message.ENCODING" value="UTF-8" /> </jaxws:properties> <jaxws:features> <!-- 增加日志特征 --> <bean class="com.main.util.MySysCom.cxflog.CxfLoggingFeature" /> <!-- 注入JMS配置对象 --> <bean class="org.apache.cxf.transport.jms.JMSConfigFeature" p:jmsConfig-ref="intervalRateServiceConfig1" /> </jaxws:features> <!-- 配置路由拦截器,重定向服务 --> <jaxws:inInterceptors> <bean class="com.srcb.esb.interceptor.MediatorInterceptor" /> </jaxws:inInterceptors> </jaxws:endpoint> <jaxws:endpoint id="IntervalRateServiceEpt2" implementor="com.srcb.esb.intervalrateservice.v1.IntervalRateServicePortTypeImpl" address="jms://IntervalRateService"> <jaxws:properties> <!-- 修改默认的SOAP编码 --> <entry key="org.apache.cxf.message.Message.ENCODING" value="UTF-8" /> </jaxws:properties> <jaxws:features> <!-- 增加日志特征 --> <bean class="com.main.util.MySysCom.cxflog.CxfLoggingFeature" /> <!-- 注入JMS配置对象 --> <bean class="org.apache.cxf.transport.jms.JMSConfigFeature" p:jmsConfig-ref="intervalRateServiceConfig2" /> </jaxws:features> <!-- 配置路由拦截器,重定向服务 --> <jaxws:inInterceptors> <bean class="com.srcb.esb.interceptor.MediatorInterceptor" /> </jaxws:inInterceptors> </jaxws:endpoint> <jaxws:endpoint id="IntervalRateServiceEpt3" implementor="com.srcb.esb.intervalrateservice.v1.IntervalRateServicePortTypeImpl" address="jms://IntervalRateService"> <jaxws:properties> <!-- 修改默认的SOAP编码 --> <entry key="org.apache.cxf.message.Message.ENCODING" value="UTF-8" /> </jaxws:properties> <jaxws:features> <!-- 增加日志特征 --> <bean class="com.main.util.MySysCom.cxflog.CxfLoggingFeature" /> <!-- 注入JMS配置对象 --> <bean class="org.apache.cxf.transport.jms.JMSConfigFeature" p:jmsConfig-ref="intervalRateServiceConfig3" /> </jaxws:features> <!-- 配置路由拦截器,重定向服务 --> <jaxws:inInterceptors> <bean class="com.srcb.esb.interceptor.MediatorInterceptor" /> </jaxws:inInterceptors> </jaxws:endpoint> <bean id="intervalRateServiceConfig" class="org.apache.cxf.transport.jms.JMSConfiguration" p:connectionFactory-ref="jmsConnectionFactory" p:targetDestination="LOCALQ.ESB.INTERVALRATESERVICE_V1.REQ" p:sessionTransacted="false" p:concurrentConsumers="1" p:maxConcurrentConsumers="10" /> <bean id="intervalRateServiceConfig1" class="org.apache.cxf.transport.jms.JMSConfiguration" p:connectionFactory-ref="jmsConnectionFactory1" p:targetDestination="LOCALQ.ESB.INTERVALRATESERVICE_V1.REQ" p:sessionTransacted="false" p:concurrentConsumers="1" p:maxConcurrentConsumers="10" /> <bean id="intervalRateServiceConfig2" class="org.apache.cxf.transport.jms.JMSConfiguration" p:connectionFactory-ref="jmsConnectionFactory2" p:targetDestination="LOCALQ.ESB.INTERVALRATESERVICE_V1.REQ" p:sessionTransacted="false" p:concurrentConsumers="1" p:maxConcurrentConsumers="10" /> <bean id="intervalRateServiceConfig3" class="org.apache.cxf.transport.jms.JMSConfiguration" p:connectionFactory-ref="jmsConnectionFactory3" p:targetDestination="LOCALQ.ESB.INTERVALRATESERVICE_V1.REQ" p:sessionTransacted="false" p:concurrentConsumers="1" p:maxConcurrentConsumers="10" /> </beans>
2、请求方jms:
<?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:cxf="http://cxf.apache.org/core" xmlns:soap="http://cxf.apache.org/bindings/soap" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jms="http://cxf.apache.org/transports/jms" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schema/bindings/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-local.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-jms.xml" /> <!-- 图像字符识别 --> <jaxws:client id="RecognizeESBServiceClient" xmlns:s="http://esb.srcb.com/RecognizeESBService/v1" serviceClass="com.srcb.esb.recognizeesbservice.v1.RecognizeESBService" serviceName="s:RecognizeESBService" endpointName="s:RecognizeESBServiceSOAP" wsdlLocation="file:wsdl/ocr/RecognizeESBService1_00/RecognizeESBService.wsdl" address="jms://"> <jaxws:properties> <entry key="org.apache.cxf.message.Message.ENCODING" value="UTF-8" /> </jaxws:properties> <jaxws:features> <bean class="com.pearlsoft.switcher.log.cxflog.CxfLoggingFeature" /> <bean class="org.apache.cxf.transport.jms.JMSConfigFeature"> <property name="jmsConfig"> <ref bean="configRecognizeESBService" /> </property> </bean> </jaxws:features> </jaxws:client> <bean id="configRecognizeESBService" class="org.apache.cxf.transport.jms.JMSConfiguration" p:connectionFactory-ref="jmsConnectionFactory" p:targetDestination="LOCALQ.OCR.RECOGNIZEESBSERVICE_V1.REQ" p:replyDestination="LOCALQ.ATMPITS.RSP"> <!-- 超时时间(ms) --> <property name="receiveTimeout" value="40000" /> <!-- 消息持久性:'1'表示非持久;'2'表示持久;默认为'2' --> <property name="deliveryMode" value="1" /> <property name="explicitQosEnabled" value="true" /> </bean> </beans>
此处我粘贴的两个xml代码不是同一个服务,但是大致差不多,jms文件中标签的具体值还要根据服务对应的wsdl文件来写。
3、wsdl文件(图像字符识别系统):
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://esb.srcb.com/RecognizeESBService/v1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="RecognizeESBService" targetNamespace="http://esb.srcb.com/RecognizeESBService/v1"> <wsdl:types> <xsd:schema targetNamespace="http://esb.srcb.com/RecognizeESBService/v1" xmlns:wstns="http://esb.srcb.com/RecognizeESBService/schema/v1"> <xsd:import schemaLocation="RecognizeESBService.xsd" namespace="http://esb.srcb.com/RecognizeESBService/schema/v1" /> <xsd:element name="recognizeIdcard" type="wstns:intsigIdcardESBRequestType"> </xsd:element> <xsd:element name="recognizeBizLincense" type="wstns:intsigESBBizLincenseRequestType"> </xsd:element> <xsd:element name="recognizeBankCard" type="wstns:intsigESBBankRequestType"> </xsd:element> <xsd:element name="recognizeVATInvoice" type="wstns:intsigESBVatRequestType"> </xsd:element> <xsd:element name="recognizeIdcardImgResponse" type="wstns:intsigESBIdcardResponseType"> </xsd:element> <xsd:element name="recognizeBizLincenseImgResponse" type="wstns:intsigESBBizLincenseResponseType"> </xsd:element> soapAction="http://esb.srcb.com/RecognizeESBService/v1/recognizeBankCard" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="recognizeVATInvoice"> <wsdl:documentation>xxxxxxxx</wsdl:documentation> <soap:operation soapAction="http://esb.srcb.com/RecognizeESBService/v1/recognizeVATInvoice" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="RecognizeESBService"> <wsdl:port name="RecognizeESBServiceSOAP" binding="tns:RecognizeESBServiceSOAP"><!-- 此处端口名的命名 --> <soap:address location="jms://" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
结合ant脚本-请求方根据wsdl生成jar、服务方根据wsdl生成Java文件、二者目录结构一致,进行业务代码的编写,此处不做赘述。
RecognizeESBService