创建SOAP XML请求PHP

时间:2017-07-23 15:38:45

标签: php mysql xml web-services soap

我一直致力于将我们的销售点应用程序(基于Java和MySQL)链接到我们的ERP系统的解决方案。我为数据库创建了一个PHP前端,您可以在其中查看需要发送的所有事务。现在我基于MySQL记录为我们的ERP系统创建一个SOAP请求。我不清楚我应该怎么做。我知道SOAP请求需要具有所有的事务,否则所有条目都不会保持平衡。 (信用卡/借记卡必须相同。)

SOAP请求中的所有必填字段都在数据库中可用,因此我只需要知道如何使用所有事务创建1个XML请求。 (按日期过滤,但已在数据库中完成。)

以下是一个示例SOAP请求,其中1个事务由数据库中的3行组成(Credit / Debit已在DB中分隔):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Afas.Profit.Services">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:Execute>
         <!--Optional:-->
         <urn:token><![CDATA[<token><version>1</version><data>TOKEN-ALWAYS THE SAME</data></token>]]></urn:token>
         <!--Optional:-->
         <urn:connectorType>FiEntries</urn:connectorType>
         <urn:connectorVersion>1</urn:connectorVersion>
         <!--Optional:-->
         <urn:dataXml><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<FiEntryPar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Element>
    <Fields Action="insert">
      <Year>2017</Year>
      <Peri>7</Peri>
      <JoCo>01</JoCo>
    </Fields>
    <Objects>
      <FiEntries>
        <Element>
          <Fields Action="insert">
            <VaAs>2</VaAs>
            <AcNr>10002</AcNr>
            <EnDa>2017-07-21</EnDa>
            <BpDa>2017-07-21</BpDa>
            <BpNr>346</BpNr>
            <InId>346</InId>
            <Ds>20b8be4b-20b2-4d16-a079-7720404cdf4c</Ds>
            <AmDe>20</AmDe>
            <AmCr>0</AmCr>
          </Fields>
        </Element>
        <Element>
          <Fields Action="insert">
            <VaAs>1</VaAs>
            <AcNr>8100</AcNr>
            <EnDa>2017-07-21</EnDa>
            <BpDa>2017-07-21</BpDa>
            <BpNr>346</BpNr>
            <InId>346</InId>
            <Ds>20b8be4b-20b2-4d16-a079-7720404cdf4c</Ds>
            <AmDe>0</AmDe>
            <AmCr>16.53</AmCr>
            <VaId>1</VaId>
          </Fields>
        </Element>
        <Element>
          <Fields Action="insert">
            <VaAs>1</VaAs>
            <AcNr>1510</AcNr>
            <EnDa>2017-07-21</EnDa>
            <BpDa>2017-07-21</BpDa>
            <BpNr>346</BpNr>
            <InId>346</InId>
            <Ds>20b8be4b-20b2-4d16-a079-7720404cdf4c</Ds>
            <AmDe>0</AmDe>
            <AmCr>3.47</AmCr>
            <VaId>1</VaId>
          </Fields>
        </Element>
      </FiEntries>
    </Objects>
  </Element>
</FiEntryPar>]]>
</urn:dataXml>
      </urn:Execute>
   </soapenv:Body>
</soapenv:Envelope>

This is how the database looks and which fields go where in the request:

来自SOAPui的WSDL:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:Afas.Profit.Services">
   <soap:Header/>
   <soap:Body>
      <urn:Execute>
         <!--Optional:-->
         <urn:token>?</urn:token>
         <!--Optional:-->
         <urn:connectorType>?</urn:connectorType>
         <urn:connectorVersion>?</urn:connectorVersion>
         <!--Optional:-->
         <urn:dataXml>?</urn:dataXml>
      </urn:Execute>
   </soap:Body>
</soap:Envelope>

0 个答案:

没有答案