用于抽象数据类型的Mule SOAP

时间:2014-06-05 06:49:43

标签: mule soap-client abstract-data-type

我正在尝试从Mule到NetSuite Web服务进行SOAP调用

这是WSDL

https://webservices.sandbox.netsuite.com/wsdl/v2013_2_0/netsuite.wsdl

在WSDL中定义了一个名为“add”的通用服务,该服务接收需要在NetSuite中添加的“Record”实体。

现在Record是一个抽象类型,我需要添加的实体是“PurchaseOrder”,它扩展了“Record”。

“Record”和“PurchaseOrder”的模式在WSDL中定义如下

记录:

<complexType name="Record" abstract="true">
    <sequence>
        <element name="nullFieldList" type="platformCore:NullField" minOccurs="0" maxOccurs="1"/>
    </sequence>
</complexType>

购买订单:

<complexType name="PurchaseOrder">
    <complexContent>
        <extension base="platformCore:Record">
            <sequence>
                <element name="createdDate" type="xsd:dateTime" minOccurs="0"/>
                <element name="lastModifiedDate" type="xsd:dateTime" minOccurs="0"/>
                <element name="customForm" type="platformCore:RecordRef" minOccurs="0"/>
                ...
                    //skipping unnecessary details
                ...
                <element name="itemList" type="tranPurch:PurchaseOrderItemList" minOccurs="0"/>
                <element name="expenseList" type="tranPurch:PurchaseOrderExpenseList" minOccurs="0"/>
                <element name="customFieldList" type="platformCore:CustomFieldList" minOccurs="0"/>
            </sequence>
            <!-- primary record internalId -->
            <attribute name="internalId" type="xsd:string"/>
            <attribute name="externalId" type="xsd:string"/>
        </extension>
    </complexContent>
</complexType>

理想情况下,需要生成的SOAP请求如下

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
    <ns1:passport xmlns:ns1="urn:messages.platform.webservices.netsuite.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
    <ns2:email xmlns:ns2="urn:core_2013_2.platform.webservices.netsuite.com">user1@zycus.com</ns2:email>
    <ns3:password xmlns:ns3="urn:core_2013_2.platform.webservices.netsuite.com">Zycus12345</ns3:password>
    <ns4:account xmlns:ns4="urn:core_2013_2.platform.webservices.netsuite.com">1013502</ns4:account>
    <ns5:role xmlns:ns5="urn:core_2013_2.platform.webservices.netsuite.com" internalId="3"/>
</ns1:passport>
<ns6:searchPreferences xmlns:ns6="urn:messages.platform.webservices.netsuite.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
<ns7:bodyFieldsOnly xmlns:ns7="urn:messages_2013_2.platform.webservices.netsuite.com">false</ns7:bodyFieldsOnly>
<ns8:pageSize xmlns:ns8="urn:messages_2013_2.platform.webservices.netsuite.com">20</ns8:pageSize>
</ns6:searchPreferences>
<ns9:preferences xmlns:ns9="urn:messages.platform.webservices.netsuite.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
<ns10:ignoreReadOnlyFields xmlns:ns10="urn:messages_2013_2.platform.webservices.netsuite.com">true</ns10:ignoreReadOnlyFields>
</ns9:preferences>
</soapenv:Header>
<soapenv:Body>
    <add xmlns="urn:messages_2013_2.platform.webservices.netsuite.com">
        <record xmlns:ns11="urn:purchases_2013_2.transactions.webservices.netsuite.com" externalId="ACMTECH/13/3" xsi:type="ns11:PurchaseOrder">
        <ns11:createdDate xsi:type="xsd:dateTime">2013-12-12T12:31:00.583Z</ns11:createdDate>
        <ns11:entity xmlns:ns12="urn:core_2013_2.platform.webservices.netsuite.com" externalId="ACMTECH/13/3" type="purchaseOrder" xsi:type="ns12:RecordRef"/>
        <ns11:dueDate xsi:type="xsd:dateTime">2013-12-12T12:31:00.583Z</ns11:dueDate>
        <ns11:exchangeRate xsi:type="xsd:double">1.03928497</ns11:exchangeRate>
        <ns11:currencyName xsi:type="xsd:string">USD</ns11:currencyName>
        <ns11:toBePrinted xsi:type="xsd:boolean">false</ns11:toBePrinted>
        <ns11:toBeEmailed xsi:type="xsd:boolean">true</ns11:toBeEmailed>
        <ns11:email xsi:type="xsd:string">vivek.kt@zycus.com</ns11:email>
        <ns11:toBeFaxed xsi:type="xsd:boolean">false</ns11:toBeFaxed>
        <ns11:billAddress xsi:type="xsd:string">4701 DOMINION ST, MORRISBURG, Omsk, RU, ZIP : 613, POBOX : 36544</ns11:billAddress>
        <ns11:shipAddress xsi:type="xsd:string">ADD02</ns11:shipAddress>
        <ns11:fob xsi:type="xsd:string">Shipping Point</ns11:fob>
        <ns11:total xsi:type="xsd:double">20.785699</ns11:total>
        <ns11:orderStatus xmlns:ns13="urn:types.purchases_2013_2.transactions.webservices.netsuite.com" xsi:type="ns13:PurchaseOrderOrderStatus">_pendingBilling</ns11:orderStatus>
    </record>
</add>
</soapenv:Body>
</soapenv:Envelope>

很明显,“添加”操作包含一个“记录”实体,其类型为“PurchaseOrder”。

但是当我使用Mule时,生成的SOAP请求有一个“add”操作,其type属性为“PurcahseOrder”。完全跳过“记录”标记。

这是实际生成的SOAP请求

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns24:add xmlns="urn:core_2013_2.platform.webservices.netsuite.com"
            xmlns:ns2="urn:faults_2013_2.platform.webservices.netsuite.com"
            xmlns:ns3="urn:common_2013_2.platform.webservices.netsuite.com"
            xmlns:ns4="urn:scheduling_2013_2.activities.webservices.netsuite.com"
            xmlns:ns5="urn:communication_2013_2.general.webservices.netsuite.com"
            xmlns:ns6="urn:filecabinet_2013_2.documents.webservices.netsuite.com"
            xmlns:ns7="urn:relationships_2013_2.lists.webservices.netsuite.com"
            xmlns:ns8="urn:support_2013_2.lists.webservices.netsuite.com"
            xmlns:ns9="urn:accounting_2013_2.lists.webservices.netsuite.com"
            xmlns:ns10="urn:sales_2013_2.transactions.webservices.netsuite.com"
            xmlns:ns11="urn:purchases_2013_2.transactions.webservices.netsuite.com"
            xmlns:ns12="urn:customers_2013_2.transactions.webservices.netsuite.com"
            xmlns:ns13="urn:financial_2013_2.transactions.webservices.netsuite.com"
            xmlns:ns14="urn:bank_2013_2.transactions.webservices.netsuite.com"
            xmlns:ns15="urn:inventory_2013_2.transactions.webservices.netsuite.com"
            xmlns:ns16="urn:general_2013_2.transactions.webservices.netsuite.com"
            xmlns:ns17="urn:customization_2013_2.setup.webservices.netsuite.com"
            xmlns:ns18="urn:employees_2013_2.lists.webservices.netsuite.com"
            xmlns:ns19="urn:website_2013_2.lists.webservices.netsuite.com"
            xmlns:ns20="urn:employees_2013_2.transactions.webservices.netsuite.com"
            xmlns:ns21="urn:marketing_2013_2.lists.webservices.netsuite.com"
            xmlns:ns22="urn:demandplanning_2013_2.transactions.webservices.netsuite.com"
            xmlns:ns23="urn:supplychain_2013_2.lists.webservices.netsuite.com"
            xmlns:ns24="urn:messages_2013_2.platform.webservices.netsuite.com"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns11:PurchaseOrder"
            externalId="ACMTECH/13/3">
                <ns11:createdDate xsi:type="xsd:dateTime">2013-12-12T12:31:00.583Z</ns11:createdDate>
                <ns11:entity xmlns:ns12="urn:core_2013_2.platform.webservices.netsuite.com" externalId="ACMTECH/13/3" type="purchaseOrder" xsi:type="ns12:RecordRef"/>
                <ns11:dueDate xsi:type="xsd:dateTime">2013-12-12T12:31:00.583Z</ns11:dueDate>
                <ns11:exchangeRate xsi:type="xsd:double">1.03928497</ns11:exchangeRate>
                <ns11:currencyName xsi:type="xsd:string">USD</ns11:currencyName>
                <ns11:toBePrinted xsi:type="xsd:boolean">false</ns11:toBePrinted>
                <ns11:toBeEmailed xsi:type="xsd:boolean">true</ns11:toBeEmailed>
                <ns11:email xsi:type="xsd:string">vivek.kt@zycus.com</ns11:email>
                <ns11:toBeFaxed xsi:type="xsd:boolean">false</ns11:toBeFaxed>
                <ns11:billAddress xsi:type="xsd:string">4701 DOMINION ST, MORRISBURG, Omsk, RU, ZIP : 613, POBOX : 36544</ns11:billAddress>
                <ns11:shipAddress xsi:type="xsd:string">ADD02</ns11:shipAddress>
                <ns11:fob xsi:type="xsd:string">Shipping Point</ns11:fob>
                <ns11:total xsi:type="xsd:double">20.785699</ns11:total>
                <ns11:orderStatus xmlns:ns13="urn:types.purchases_2013_2.transactions.webservices.netsuite.com" xsi:type="ns13:PurchaseOrderOrderStatus">_pendingBilling</ns11:orderStatus>
        </ns24:add>
    </soap:Body>
</soap:Envelope>

这是Mule项目的配置XML

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd">
    <file:connector name="File" autoDelete="false" streaming="true" validateConnections="true" doc:name="File"/>
    <data-mapper:config name="xml_to_pojo" transformationGraphPath="xml_to_pojo.grf" doc:name="xml_to_pojo"/>

    <cxf:configuration name="CXF_Configuration1" enableMuleSoapHeaders="true" initializeStaticBusInstance="true" doc:name="CXF Configuration"/>
    <https:connector name="HTTP_HTTPS" cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" doc:name="HTTP\HTTPS"/>
    <flow name="SOAPIgnitor" doc:name="SOAPIgnitor">
        <file:inbound-endpoint path="E:\MuleWorkspace\netsuitetest\src\main\resources" responseTimeout="10000" connector-ref="File" doc:name="File" pollingFrequency="30000">
            <file:filename-regex-filter pattern="eProc_PO.xml" caseSensitive="true"/>
        </file:inbound-endpoint>
        <logger message="&quot;File Output ---------&gt;&quot;         #[payload]" level="INFO" doc:name="Logger"/>
        <data-mapper:transform doc:name="XML To Pojo" config-ref="xml_to_pojo"/>
        <logger message="&quot;Data Mapper Output ------------&gt; &quot;   #[payload]" level="INFO" doc:name="Logger"/>
        <flow-ref name="NonIgnitorSoapClient" doc:name="Flow Reference"/>
    </flow>
    <sub-flow name="NonIgnitorSoapClient" doc:name="NonIgnitorSoapClient">

        <cxf:jaxws-client operation="add" clientClass="com.netsuite.webservices.platform_2013_2.NetSuiteService" port="NetSuitePort" doc:name="SOAP" soapVersion="1.2" wsdlLocation="https://webservices.sandbox.netsuite.com/wsdl/v2013_2_0/netsuite.wsdl">
        </cxf:jaxws-client>
        <mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
        <file:outbound-endpoint path="E:\MuleWorkspace\netsuitetest\src\main\resources" outputPattern="test.xml" responseTimeout="10000" connector-ref="File" doc:name="File"/>
        <mulexml:xml-to-dom-transformer doc:name="XML to DOM"/>
        <https:outbound-endpoint exchange-pattern="request-response" method="PUT" address="https://webservices.sandbox.netsuite.com/services/NetSuitePort_2013_2" connector-ref="HTTP_HTTPS" doc:name="HTTP"/>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <logger message="#[payload]" level="INFO" doc:name="Logger"/>
    </sub-flow>
</mule>

请告知项目需要进行哪些更改,以便获得预期的输出

0 个答案:

没有答案