Question

I am trying to rename a SOAP method with XSLT but i didn't got it yet

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:unk="http://unknown.namespace/">
    <soapenv:Header/>
       <soapenv:Body>
          <unk:sum>
             <arg0>1</arg0>
             <arg1>2</arg1>
          </unk:sum>
       </soapenv:Body>
</soapenv:Envelope>

And i want to get this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:unk="http://unknown.namespace/">
  <soapenv:Header/>
 <soapenv:Body>
    <unk:multiply>
        <arg0>1</arg0>
        <arg1>2</arg1>
     </unk:multiply>
</soapenv:Body>
</soapenv:Envelope>

On the other hand i am trying to consume a web service renaming by hand the method with soap UI and get this error:

<faultcode>soap:Client</faultcode>
<faultstring>Unexpected wrapper element {http://unknown.namespace/}multiply found. Expected {http://unknown.namespace/}sum.</faultstring>

Any suggestion?

Was it helpful?

Solution

Is the multiply method defined in the WSDL?

As for the transformation in the SOAP envelope, you can use this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0" xmlns:unk="http://unknown.namespace/">

    <xsl:template match="unk:sum">
        <unk:multiply>
            <xsl:apply-templates/>
        </unk:multiply>
    </xsl:template>

    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>

The first template matches the node <unk:sum>, replaces the tag and recursively processes the child nodes, running any templates matched for the nodes encountered. The second template recursively copies all other nodes with attributes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top