
Data Structure
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.example.org/Invoices"
elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.example.org/Invoices"
xmlns:cust="http://www.example.org/Customers">
<xsd:import schemaLocation="../xsd/Customers.xsd"
namespace="http://www.example.org/Customers" />
<xsd:element name="Invoices" type="tns:Invoices" />
<xsd:complexType name="Invoices">
<xsd:sequence>
<xsd:element name="Invoice" type="tns:Invoice" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Invoice">
<xsd:sequence>
<xsd:element name="Id" type="xsd:ID" />
<xsd:element name="BillTo" type="cust:Customer" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://www.example.org/Customers"
elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.example.org/Customers">
<xsd:complexType name="Customer">
<xsd:sequence>
<xsd:element name="Id" type="xsd:ID" />
<xsd:element name="Name" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Mapping using XSDs
<?xml version="1.0" encoding="UTF-8"?>
<inv:Invoices xmlns:cust="http://www.example.org/Customers"
xmlns:inv="http://www.example.org/Invoices">
<inv:Invoice>
<inv:Id>INV-1234</inv:Id>
<inv:BillTo>
<cust:Id>CUS-5678</cust:Id>
<cust:Name>SAP</cust:Name>
</inv:BillTo>
</inv:Invoice>
</inv:Invoices>
<?xml version="1.0" encoding="UTF-8"?>
<inv:Invoices xmlns:inv="http://www.example.org/Invoices">
<inv:Invoice>
<inv:Id>INV-1234</inv:Id>
<inv:BillTo>
<Id>CUS-5678</Id>
<Name>SAP</Name>
</inv:BillTo>
</inv:Invoice>
</inv:Invoices>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.example.org/Invoices"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Invoices"
targetNamespace="http://www.example.org/Invoices">
<wsdl:types>
<xsd:schema
targetNamespace="http://www.example.org/Customers"
elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.example.org/Customers">
<xsd:complexType name="Customer">
<xsd:sequence>
<xsd:element name="Id" type="xsd:ID" />
<xsd:element name="Name" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema
targetNamespace="http://www.example.org/Invoices"
elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.example.org/Invoices"
xmlns:cust="http://www.example.org/Customers">
<xsd:import namespace="http://www.example.org/Customers" />
<xsd:element name="Invoices" type="tns:Invoices" />
<xsd:complexType name="Invoices">
<xsd:sequence>
<xsd:element name="Invoice" type="tns:Invoice" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Invoice">
<xsd:sequence>
<xsd:element name="Id" type="xsd:ID" />
<xsd:element name="BillTo" type="cust:Customer" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
</wsdl:definitions>
Mapping with WSDL before refactoring
Mapping with WSDL after refactoring
<?xml version="1.0" encoding="UTF-8"?>
<inv:Invoices xmlns:inv="http://www.example.org/Invoices">
<inv:Invoice>
<inv:Id>INV-1234</inv:Id>
<inv:BillTo>
<cust:Id xmlns:cust="http://www.example.org/Customers">CUS-5678</cust:Id>
<cust:Name xmlns:cust="http://www.example.org/Customers">SAP</cust:Name>
</inv:BillTo>
</inv:Invoice>
</inv:Invoices>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cust="http://www.example.org/Customers"
xmlns:inv="http://www.example.org/Invoices">
<xsl:mode on-no-match="shallow-copy"></xsl:mode>
<xsl:template match="/inv:Invoices/inv:Invoice/inv:BillTo/Id">
<cust:Id>
<xsl:value-of select="/inv:Invoices/inv:Invoice/inv:BillTo/Id"></xsl:value-of>
</cust:Id>
</xsl:template>
<xsl:template match="/inv:Invoices/inv:Invoice/inv:BillTo/Name">
<cust:Name>
<xsl:value-of select="/inv:Invoices/inv:Invoice/inv:BillTo/Name"></xsl:value-of>
</cust:Name>
</xsl:template>
</xsl:stylesheet>
import com.sap.gateway.ip.core.customdev.util.Message
import groovy.xml.XmlUtil
def Message processData(Message message) {
def invoices = new XmlSlurper().parse(message.getBody(Reader))
invoices.Invoice.each {
it.BillTo.Id.@xmlns = 'http://www.example.org/Customers'
it.BillTo.Name.@xmlns = 'http://www.example.org/Customers'
}
message.setBody(XmlUtil.serialize(invoices))
return message
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |