0
Hat jemand XML-Dateien mit SQL Server in einem SOAP-Format generiert? Ich versuche, die folgende Struktur von SQL zu erzeugen, aber ich kann es nicht herausfinden, wenn die FOR XML
Klausel der beste Ansatz dafür ist. Kann jemand ein paar Vorschläge machen? Vielleicht ein anderer Ansatz für diese Art von Dateien?Generieren von SOAP XML mit SQL Server
SOAP XML-Struktur
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<To s:mustUnderstand="1" xmlns=""></To>
<Action s:mustUnderstand="1" xmlns=""></Action>
</s:Header>
<soapenv:Body>
<tns:StoreDocument xmlns:tns="">
<tns:StoreDocumentMessage>
<q1:SystemCode xmlns:q1=""></q1:SystemCode>
<q1:TransmissionUID xmlns:q1="">d2032705-5478-4694-98f9-d2eafa3933b2</q1:TransmissionUID>
<q1:DocumentSection xmlns:q1="">
<q17:DocumentType xmlns:q17="">1</q17:DocumentType>
<q17:DocumentNumber xmlns:q17="">0000006965</q17:DocumentNumber>
<q17:DocumentUID xsi:nil="true" xmlns:q17="" xmlns:xsi=""/>
<q17:CreationDateTimeUTC xmlns:q17="">2017-08-04 09:09:29 -03:00</q17:CreationDateTimeUTC>
<q17:DocumentStatus xmlns:q17="">2</q17:DocumentStatus>
<q17:LatestGoodIssueDate xmlns:q17="">2017-08-04 13:35:16 -03:00</q17:LatestGoodIssueDate>
<q17:Reference xmlns:q17="">0000013254</q17:Reference>
<q17:TotalOrderedProducts xsi:nil="true" xmlns:q17="" xmlns:xsi=""/>
<q17:OrderedProducts xmlns:q17="">
<q17:OrderedProductSection>
<q17:ProductCode>2152157</q17:ProductCode>
<q17:OrderedQuantity>500000</q17:OrderedQuantity>
</q17:OrderedProducts>
<q17:RelatedDocumentSection xsi:nil="true" xmlns:q17="" xmlns:xsi=""/>
<q17:StockOwnerSection xmlns:q17="">
<q17:StockOwnerCode></q17:StockOwnerCode>
<q17:StockOwnerName></q17:StockOwnerName>
<q17:StockOwnerAddress1></q17:StockOwnerAddress1>
<q17:StockOwnerAddress2/>
<q17:StockOwnerZIP>1407</q17:StockOwnerZIP>
<q17:StockOwnerCity></q17:StockOwnerCity>
<q17:StockOwnerNameRomanized></q17:StockOwnerNameRomanized>
<q17:StockOwnerAddress1Romanized></q17:StockOwnerAddress1Romanized>
<q17:StockOwnerAddress2Romanized/>
<q17:StockOwnerZIPRomanized></q17:StockOwnerZIPRomanized>
<q17:StockOwnerCityRomanized></q17:StockOwnerCityRomanized>
<q17:StockOwnerCountry></q17:StockOwnerCountry>
<q17:StockOwnerGLN xsi:nil="true" xmlns:xsi=""/>
</q17:StockOwnerSection>
</tns:StoreDocumentMessage>
</tns:StoreDocument>
</soapenv:Body>
</soapenv:Envelope>
Um den Namespace für die Elemente erzeugt mit der "FOR XML-Klausel", verwenden Sie "FOR XML RAW" (siehe https://docs.microsoft.com/en-us/sql/relational- zu verwenden/bewahren Datenbanken/XML/Add-Namespaces-zu-Abfragen-mit-mit-XML-Namensräume) mit oder ohne die Klausel WITH XMLNAMESPACES ('uri' as ns1) ... –