标注调解员发送奇怪的信封

时间:2016-01-17 20:53:45

标签: wso2 wso2esb

使用smooks mediator读取逗号分隔文件。对于每个拨打另一个服务的行。监控此请求(见下文)。这不是我所期望的,它失败了。

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="agreementsCSVFileProxy"
       transports="vfs"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence>
         <log level="full"/>
         <smooks config-key="smooks">
            <input type="text"/>
            <output type="xml"/>
         </smooks>
         <iterate xmlns:ns2="http://org.apache.synapse/xsd"
                  xmlns:sec="http://secservice.samples.esb.wso2.org"
                  expression="//csv-set/csv-record">
            <target>
               <sequence>
                  <property name="customer_id" expression="//csv-record/customer_id/text()"/>
                  <property name="date_time" expression="//csv-record/date_time/text()"/>
                  <property name="agreement_id" expression="//csv-record/agreement_id/text()"/>
                  <property name="product_id" expression="//csv-record/product_id/text()"/>
                  <property name="product_name" expression="//csv-record/product_name/text()"/>
                  <payloadFactory media-type="xml">
                     <format>
                        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                          xmlns:sch="http://domain.com/mifid/timeline/schema/">
                           <soapenv:Header/>
                           <soapenv:Body>
                              <sch:productLookupRequest>
                                 <sch:productId>$1</sch:productId>
                              </sch:productLookupRequest>
                           </soapenv:Body>
                        </soapenv:Envelope>
                     </format>
                     <args>
                        <arg xmlns:ns="http://org.apache.synapse/xsd"
                             evaluator="xml"
                             expression="get-property('product_id')"/>
                     </args>
                  </payloadFactory>
                  <property name="Content-Type"
                            value="application/xml"
                            scope="axis2"
                            type="STRING"/>
                  <callout serviceURL="http://localhost:9088/mockproductLookupSoapBinding"
                           action="urn:lookupProduct">
                     <source xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
                             xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
                             xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
                     <target xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
                             xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
                             xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
                  </callout>
                  <property xmlns:ns="http://org.apache.synapse/xsd"
                            xmlns:sch="http://domain.com/mifid/timeline/schema/"
                            name="product_name"
                            expression="//sch:productName"/>
                  <payloadFactory media-type="xml">
                     <format>
                        <dat:insertAgreement xmlns:dat="http://ws.wso2.org/dataservice">
                           <dat:p_customer_id>$1</dat:p_customer_id>
                           <dat:p_record_type_id>1</dat:p_record_type_id>
                           <dat:p_date_time>$2</dat:p_date_time>
                           <dat:p_agreement_id>$3</dat:p_agreement_id>
                           <dat:p_product_id>$4</dat:p_product_id>
                           <dat:p_product_name>$5</dat:p_product_name>
                        </dat:insertAgreement>
                     </format>
                     <args>
                        <arg evaluator="xml" expression="get-property('customer_id')"/>
                        <arg evaluator="xml" expression="get-property('date_time')"/>
                        <arg evaluator="xml" expression="get-property('agreement_id')"/>
                        <arg evaluator="xml" expression="get-property('product_id')"/>
                        <arg evaluator="xml" expression="get-property('product_name')"/>
                     </args>
                  </payloadFactory>
                  <header name="Action"
                          scope="default"
                          value="http://ws.wso2.org/dataservice"/>
                  <send>
                     <endpoint>
                        <address uri="http://localhost:9767/services/Timeline/" format="soap11"/>
                     </endpoint>
                  </send>
               </sequence>
            </target>
         </iterate>
      </inSequence>
      <outSequence/>
      <faultSequence/>
   </target>
   <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
   <parameter name="transport.PollInterval">15</parameter>
   <parameter name="transport.vfs.MoveAfterProcess">file://C:\temp\test\original</parameter>
   <parameter name="transport.vfs.FileURI">file://C:\temp\test\in</parameter>
   <parameter name="transport.vfs.MoveAfterFailure">file://C:\temp\test\fail</parameter>
   <parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
   <parameter name="transport.vfs.ContentType">text/plain</parameter>
   <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
</proxy>

以下是对tcpmon监控的外部服务的请求。这就像callout之前的payloadfactory不存在。

POST /mockproductLookupSoapBinding HTTP/1.1
Content-Type: text/plain; charset=UTF-8;action="urn:lookupProduct";
FILE_NAME: agreement_small.txt
FILE_PATH: /temp/test/in/agreement_small.txt
FILE_URI: file:///C:/temp/test/in/agreement_small.txt
User-Agent: Axis2
Host: 127.0.0.1:9088
Transfer-Encoding: chunked

0

有预期的结果。

HTTP/1.1 500 Internal Server Error
Content-Type: text/html; charset=iso-8859-1
Transfer-Encoding: chunked
Server: Jetty(6.1.26)

151
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">  
   <soapenv:Body>    
      <soapenv:Fault>      
         <faultcode>Server</faultcode>      
         <faultstring>Missing operation for soapAction [] and body element [null] with SOAP Version [SOAP 1.1]</faultstring>    
      </soapenv:Fault>  
   </soapenv:Body></soapenv:Envelope>
0

我错过了什么?

1 个答案:

答案 0 :(得分:1)

当inSequence启动时,内容类型是text / plain,你不会在callout mediator之前更改它(参见tcpmon: Content-Type:text / plain; charset = UTF-8; action =“urn :lookupProduct“;

没有任何文本节点可以检测您的肥皂体,因此无需发送

在callout mediator之前设置此属性:

<property name="messageType" value="text/xml" scope="axis2"/>