早安们,非常感谢您为帮助我而付出的时间 下面是suds使用此字典生成的xml:
####DICT####
{'Posizione': [{'item': {'Prezzo': 0,
'Product': 'TESTID',
'Refund': 0,
'Sales': 0,
'Test': 1}},
{'item': {'Prezzo': 0,
'Product': 'STATISTICA',
'Refund': 0,
'Sales': 0,
'Test': 1}},
{'item': {'Prezzo': 200,
'Product': 'VINTAGEID',
'Refund': 0,
'Sales': 3,
'Test': 0}},
{'item': {'Prezzo': 500,
'Product': 'CIEID',
'Refund': 0,
'Sales': 59,
'Test': 1}},
{'item': {'Prezzo': 500,
'Product': 'RPICAOID',
'Refund': 0,
'Sales': 9,
'Test': 1}},
{'item': {'Prezzo': 0,
'Product': 'S2DPRINT',
'Refund': 0,
'Sales': 1,
'Test': 0}}],
'Testata': {'BNS_1': 0,
'BNS_2': 0,
'Bns1': 0,
'Bns10': 0,
'Bns2': 0,
'Bns20': 0,
'Bns5': 0,
'CanaleGettone': 1,
'CanaleProve': 1,
'Cashless': 0.0,
'CashlessApp': 0.0,
'CashlessNayax': 0.0,
'Ch1': 0.0,
'Ch2': 0.0,
'Ch3': 0.0,
'Ch4': 0.0,
'Ch5': 0.0,
'Ch6': 0.0,
'Ch7': 0.0,
'Ch8': 5.0,
'Ch9': 0.0,
'Change': 6200.0,
'CodeMa': '00006137',
'Consumabile': 0,
'ContMonViso': 347.0,
'DateB': datetime.datetime(2019, 7, 18, 9, 35, 17),
'HopperGettone': 0,
'IdTelemetria': 444673,
'MdbInc2': 2,
'MdbInc3': 11,
'MdbInc4': 15,
'MdbInc5': 0,
'MdbInc6': 0,
'MdbTub2': 2,
'MdbTub3': 18,
'MdbTub4': 11,
'MdbTub5': 0,
'MdbTub6': 0,
'MdbVal2': 0.5,
'MdbVal3': 1.0,
'MdbVal4': 2.0,
'MdbVal5': 12.75,
'MdbVal6': 12.75,
'MechValue': 0.0,
'OdmTaskPalmare': '000061372019071809350846',
'Price': 0.0,
'Qty1': 0,
'Qty2': 0,
'Qty3': 0,
'Qty4': 0,
'Qty5': 0,
'Qty6': 0,
'Qty7': 0,
'Qty8': 65,
'Qty9': 0,
'QtyV1': 0,
'QtyV2': 0,
'Sales': 76,
'Ticket': 0,
'TipoDa': 2,
'Token': 0,
'Total': 347.0,
'Vend1Prc': 0.0,
'Vend2Prc': 0.0}}
####DICT####
#####Soap xml######
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) -->
<SOAP-ENV:Envelope xmlns:ns0="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header />
<ns1:Body>
<ns0:ZpmRfcConsumiTelemetria>
<Posizione>
<item>
<Product>TESTID</Product>
<Sales>0</Sales>
<Test>1</Test>
<Refund>0</Refund>
<Prezzo>0</Prezzo>
</item>
</Posizione>
<Posizione>
<item>
<Product>STATISTICA</Product>
<Sales>0</Sales>
<Test>1</Test>
<Refund>0</Refund>
<Prezzo>0</Prezzo>
</item>
</Posizione>
<Posizione>
<item>
<Product>VINTAGEID</Product>
<Sales>3</Sales>
<Test>0</Test>
<Refund>0</Refund>
<Prezzo>200</Prezzo>
</item>
</Posizione>
<Posizione>
<item>
<Product>CIEID</Product>
<Sales>59</Sales>
<Test>1</Test>
<Refund>0</Refund>
<Prezzo>500</Prezzo>
</item>
</Posizione>
<Posizione>
<item>
<Product>RPICAOID</Product>
<Sales>9</Sales>
<Test>1</Test>
<Refund>0</Refund>
<Prezzo>500</Prezzo>
</item>
</Posizione>
<Posizione>
<item>
<Product>S2DPRINT</Product>
<Sales>1</Sales>
<Test>0</Test>
<Refund>0</Refund>
<Prezzo>0</Prezzo>
</item>
</Posizione>
<Testata>
<CodeMa>00006137</CodeMa>
<OdmTaskPalmare>000061372019071809350846</OdmTaskPalmare>
<IdTelemetria>444673</IdTelemetria>
<DateB>2019-07-18 09:35:17</DateB>
<TipoDa>2</TipoDa>
<CanaleGettone>1</CanaleGettone>
<CanaleProve>1</CanaleProve>
<Ch1>0.0</Ch1>
<Qty1>0</Qty1>
<Ch2>0.0</Ch2>
<Qty2>0</Qty2>
<Ch3>0.0</Ch3>
<Qty3>0</Qty3>
<Ch4>0.0</Ch4>
<Qty4>0</Qty4>
<Ch5>0.0</Ch5>
<Qty5>0</Qty5>
<Ch6>0.0</Ch6>
<Qty6>0</Qty6>
<Ch7>0.0</Ch7>
<Qty7>0</Qty7>
<Ch8>5.0</Ch8>
<Qty8>65</Qty8>
<Ch9>0.0</Ch9>
<Qty9>0</Qty9>
<MdbVal2>0.5</MdbVal2>
<MdbInc2>2</MdbInc2>
<MdbTub2>2</MdbTub2>
<MdbVal3>1.0</MdbVal3>
<MdbInc3>11</MdbInc3>
<MdbTub3>18</MdbTub3>
<MdbVal4>2.0</MdbVal4>
<MdbInc4>15</MdbInc4>
<MdbTub4>11</MdbTub4>
<MdbVal5>12.75</MdbVal5>
<MdbInc5>0</MdbInc5>
<MdbTub5>0</MdbTub5>
<MdbVal6>12.75</MdbVal6>
<MdbInc6>0</MdbInc6>
<MdbTub6>0</MdbTub6>
<Cashless>0.0</Cashless>
<Total>347.0</Total>
<Change>6200.0</Change>
<Sales>76</Sales>
<Consumabile>0</Consumabile>
<HopperGettone>0</HopperGettone>
<Vend1Prc>0.0</Vend1Prc>
<QtyV1>0</QtyV1>
<Vend2Prc>0.0</Vend2Prc>
<QtyV2>0</QtyV2>
<Ticket>0</Ticket>
<Price>0.0</Price>
<Bns1>0</Bns1>
<Bns2>0</Bns2>
<BNS_1>0</BNS_1>
<BNS_2>0</BNS_2>
<Bns5>0</Bns5>
<Bns10>0</Bns10>
<Bns20>0</Bns20>
<Token>0</Token>
<ContMonViso>347.0</ContMonViso>
<MechValue>0.0</MechValue>
<CashlessNayax>0.0</CashlessNayax>
<CashlessApp>0.0</CashlessApp>
</Testata>
</ns0:ZpmRfcConsumiTelemetria>
</ns1:Body>
</SOAP-ENV:Envelope>
#####Soap xml######
我真正需要的(许多SAP ERP !!)是将所有ITEM标签包装在一个“ Posizione”标签中,而无需对每个ITEM元素重复它,因此要弄清楚,类似于:
<Posizione>
<item>
<Product>TESTID</Product>
<Sales>0</Sales>
<Test>1</Test>
<Refund>0</Refund>
<Prezzo>0</Prezzo>
</item>
<item>
<Product>STATISTICA</Product>
<Sales>0</Sales>
<Test>1</Test>
<Refund>0</Refund>
<Prezzo>0</Prezzo>
</item>
<item>
<Product>VINTAGEID</Product>
<Sales>3</Sales>
<Test>0</Test>
<Refund>0</Refund>
<Prezzo>200</Prezzo>
</item>
</Posizione>
这是我正在使用的WSDL:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:n1="urn:sap-com:document:sap:rfc:functions" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">
<wsdl:documentation>
<sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl"/>
</wsdl:documentation>
<wsdl:types>
<xsd:schema xmlns:n0="urn:sap-com:document:sap:rfc:functions" attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">
<xsd:import namespace="urn:sap-com:document:sap:rfc:functions"/>
<xsd:simpleType name="char1">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char50">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="numeric1">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="1"/>
<xsd:pattern value="\d*"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="ZgeTelCassaItem">
<xsd:sequence>
<xsd:element name="Product" type="tns:char50"/>
<xsd:element name="Sales" type="xsd:int"/>
<xsd:element name="Test" type="xsd:int"/>
<xsd:element name="Refund" type="xsd:int"/>
<xsd:element name="Prezzo" type="n0:decimal17.2"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ZgeTelCassaHeader">
<xsd:sequence>
<xsd:element name="CodeMa" type="n0:char10"/>
<xsd:element name="OdmTaskPalmare" type="n0:char80"/>
<xsd:element name="IdTelemetria" type="n0:string"/>
<xsd:element name="DateB" type="n0:string"/>
<xsd:element name="TipoDa" type="tns:char1"/>
<xsd:element name="CanaleGettone" type="tns:numeric1"/>
<xsd:element name="CanaleProve" type="tns:numeric1"/>
<xsd:element name="Ch1" type="n0:decimal17.2"/>
<xsd:element name="Qty1" type="xsd:int"/>
<xsd:element name="Ch2" type="n0:decimal17.2"/>
<xsd:element name="Qty2" type="xsd:int"/>
<xsd:element name="Ch3" type="n0:decimal17.2"/>
<xsd:element name="Qty3" type="xsd:int"/>
<xsd:element name="Ch4" type="n0:decimal17.2"/>
<xsd:element name="Qty4" type="xsd:int"/>
<xsd:element name="Ch5" type="n0:decimal17.2"/>
<xsd:element name="Qty5" type="xsd:int"/>
<xsd:element name="Ch6" type="n0:decimal17.2"/>
<xsd:element name="Qty6" type="xsd:int"/>
<xsd:element name="Ch7" type="n0:decimal17.2"/>
<xsd:element name="Qty7" type="xsd:int"/>
<xsd:element name="Ch8" type="n0:decimal17.2"/>
<xsd:element name="Qty8" type="xsd:int"/>
<xsd:element name="Ch9" type="n0:decimal17.2"/>
<xsd:element name="Qty9" type="xsd:int"/>
<xsd:element name="MdbVal2" type="n0:decimal17.2"/>
<xsd:element name="MdbInc2" type="xsd:int"/>
<xsd:element name="MdbTub2" type="xsd:int"/>
<xsd:element name="MdbVal3" type="n0:decimal17.2"/>
<xsd:element name="MdbInc3" type="xsd:int"/>
<xsd:element name="MdbTub3" type="xsd:int"/>
<xsd:element name="MdbVal4" type="n0:decimal17.2"/>
<xsd:element name="MdbInc4" type="xsd:int"/>
<xsd:element name="MdbTub4" type="xsd:int"/>
<xsd:element name="MdbVal5" type="n0:decimal17.2"/>
<xsd:element name="MdbInc5" type="xsd:int"/>
<xsd:element name="MdbTub5" type="xsd:int"/>
<xsd:element name="MdbVal6" type="n0:decimal17.2"/>
<xsd:element name="MdbInc6" type="xsd:int"/>
<xsd:element name="MdbTub6" type="xsd:int"/>
<xsd:element name="Cashless" type="n0:decimal17.2"/>
<xsd:element name="Total" type="n0:decimal17.2"/>
<xsd:element name="Change" type="n0:decimal17.2"/>
<xsd:element name="Sales" type="xsd:int"/>
<xsd:element name="Consumabile" type="xsd:int"/>
<xsd:element name="HopperGettone" type="n0:char1"/>
<xsd:element name="Vend1Prc" type="n0:decimal17.2"/>
<xsd:element name="QtyV1" type="xsd:int"/>
<xsd:element name="Vend2Prc" type="n0:decimal17.2"/>
<xsd:element name="QtyV2" type="xsd:int"/>
<xsd:element name="Ticket" type="xsd:int"/>
<xsd:element name="Price" type="n0:decimal17.2"/>
<xsd:element name="Bns1" type="xsd:int"/>
<xsd:element name="Bns2" type="xsd:int"/>
<xsd:element name="BNS_1" type="xsd:int"/>
<xsd:element name="BNS_2" type="xsd:int"/>
<xsd:element name="Bns5" type="xsd:int"/>
<xsd:element name="Bns10" type="xsd:int"/>
<xsd:element name="Bns20" type="xsd:int"/>
<xsd:element name="Token" type="xsd:int"/>
<xsd:element name="ContMonViso" type="n0:decimal17.2"/>
<xsd:element name="MechValue" type="n0:decimal17.2"/>
<xsd:element name="CashlessNayax" type="n0:decimal17.2"/>
<xsd:element name="CashlessApp" type="n0:decimal17.2"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ZgeTelError">
<xsd:sequence>
<xsd:element name="Type" type="n0:char1"/>
<xsd:element name="Number" type="n0:numeric3"/>
<xsd:element name="Message" type="n0:char220"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ZgeTtTelCassaItem">
<xsd:sequence>
<xsd:element name="item" type="tns:ZgeTelCassaItem" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ZpmRfcConsumiTelemetria">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Posizione" type="tns:ZgeTtTelCassaItem" minOccurs="0"/>
<xsd:element name="Testata" type="tns:ZgeTelCassaHeader" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ZpmRfcConsumiTelemetriaResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Errore" type="tns:ZgeTelError"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
<xsd:simpleType name="char1">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char10">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char220">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="220"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="char80">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="80"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="decimal17.2">
<xsd:restriction base="xsd:decimal">
<xsd:totalDigits value="17"/>
<xsd:fractionDigits value="2"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="numeric3">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="3"/>
<xsd:pattern value="\d*"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ZpmRfcConsumiTelemetria">
<wsdl:part name="parameters" element="tns:ZpmRfcConsumiTelemetria"/>
</wsdl:message>
<wsdl:message name="ZpmRfcConsumiTelemetriaResponse">
<wsdl:part name="parameter" element="tns:ZpmRfcConsumiTelemetriaResponse"/>
</wsdl:message>
<wsdl:portType name="ZPM_RFC_CONSUMI_TELEMETRIA">
<wsdl:operation name="ZpmRfcConsumiTelemetria">
<wsdl:input message="tns:ZpmRfcConsumiTelemetria"/>
<wsdl:output message="tns:ZpmRfcConsumiTelemetriaResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ZPM_RFC_CONSUMI_TELEMETRIA" type="tns:ZPM_RFC_CONSUMI_TELEMETRIA">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="ZpmRfcConsumiTelemetria">
<soap:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:ZPM_RFC_CONSUMI_TELEMETRIA:ZpmRfcConsumiTelemetriaRequest" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ZPM_RFC_CONSUMI_TELEMETRIA_soap12" type="tns:ZPM_RFC_CONSUMI_TELEMETRIA">
<wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="ZpmRfcConsumiTelemetria">
<wsoap12:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:ZPM_RFC_CONSUMI_TELEMETRIA:ZpmRfcConsumiTelemetriaRequest" style="document"/>
<wsdl:input>
<wsoap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsoap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ZPM_RFC_CONSUMI_TELEMETRIA">
<wsdl:port name="ZPM_RFC_CONSUMI_TELEMETRIA" binding="tns:ZPM_RFC_CONSUMI_TELEMETRIA">
<soap:address location="http://BLABLABLA:8000/sap/bc/srt/rfc/sap/zpm_rfc_consumi_telemetria/300/zpm_rfc_consumi_telemetria/zpm_rfc_consumi_telemetria"/>
</wsdl:port>
<wsdl:port name="ZPM_RFC_CONSUMI_TELEMETRIA_soap12" binding="tns:ZPM_RFC_CONSUMI_TELEMETRIA_soap12">
<wsoap12:address location="http://BLABLABLA:8000/sap/bc/srt/rfc/sap/zpm_rfc_consumi_telemetria/300/zpm_rfc_consumi_telemetria/zpm_rfc_consumi_telemetria"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
这是生成它的代码
if (biggus_dictus_cash['exit-code']==True):
#container for massive dict :
build_container = {}
prods_container = []
for cash_id,inner_dic_cash in biggus_dictus_cash['data'].items():
printandlog_cash("Sending Cash ID {}".format(inner_dic_cash['build_data']['id']),"info")
record_id = inner_dic_cash['build_data']['id']
timestamp_cur_try = inner_dic_cash['build_data']['timestamp_next_try']
counter_cur = inner_dic_cash['build_data']['counter']
for i in range (len(inner_dic_cash['products'])):
prods_container.append({"item":inner_dic_cash['products'][i]})
build_container['Testata'] = inner_dic_cash['build_data']
build_container['Posizione'] = prods_container
client = Client(WSDL_path, unwrap=True,username=username, password=password)#creating client for consuming wsdl
cash_paoo = {}
cash_paoo = client.factory.create('ZpmRfcConsumiTelemetria')
cash_paoo=build_container
result = client.service.ZpmRfcConsumiTelemetria(**cash_paoo) #SHOOTING !
expose =basic_sobject_to_dict(result) #TRANSLATE TO DICT RESULT FOR PARSING
manage_cash_status(expose,record_id,inner_dic_cash['build_data']['CodeMa'],timestamp_cur_try,counter_cur,cursor)
printandlog_cash("Cash ID {} Sent. Response is {}".format(record_id,expose),"info")
else:
printandlog_cash("No Pending Elaboration Found!","info")
如果我错过了写文章的内容,请耐心等待,这是我第一次来这里:)