SOAP Envelope namespace not seen in response

Here should go questions about transforming XML with XSLT and FOP.
anboss
Posts: 8
Joined: Wed May 07, 2008 4:43 pm

SOAP Envelope namespace not seen in response

Post by anboss »

Hello

For logging requirement, i am creating a log message of type SOAP that contains request to our application and response from theapplication. These request and response messages are of type SOAP. The request and response messages are enclosed in CDATA tags.

After the required log message is created as an outcome of a transform action, i am not able to see the namespace of the "soapenv" prefix in the request message that is contained in the log message. (prob because the prefix of "Envelope" in log message and that of request is the same) how to get the namespace in the request message also?

the log request is shown below:

<soapenv:Envelope xmlns:v002="http://www.company.com/schema/app/Loggi ... Types/V001" xmlns:v1="http://www.company.com/wsdl/app/EnterpriseLogging/V1_0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dp="http://www.datapower.com/schemas/management">
<soapenv:Header/>
<soapenv:Body>
<v002:verbosityData>
<v002:request>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soapenv:Body>
<!-- request message body -->
</soapenv:Body>
</soapenv:Envelope>
</v002:request>
<v002:response>
<ns1:Envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:osa="http://www.company.com/xmlschema/resour ... cture/v001">
<ns1:Body>
<!-- response message body -->
</ns1:Body>
</ns1:Envelope>
</v002:response>
</v002:verbosityData>
</soapenv:Body>
</soapenv:Envelope>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: SOAP Envelope namespace not seen in response

Post by sorin_ristache »

Hello,
anboss wrote:After the required log message is created as an outcome of a transform action, i am not able to see the namespace of the "soapenv" prefix in the request message that is contained in the log message.
Do you mean that you generate the SOAP message with an XSLT transformation?

If yes then it seems the "soapenv" prefix is excluded from the output prefixes in your XSLT stylesheet with the attribute exclude-result-prefixes. You should check your stylesheet and allow the "soapenv" prefix to be passed to the output so that the XSLT processor inserts the declaration of this namespace prefix automatically in the output.

If no please give more details about the problem.


Regards,
Sorin
anboss
Posts: 8
Joined: Wed May 07, 2008 4:43 pm

Re: SOAP Envelope namespace not seen in response

Post by anboss »

here is my xsl. i am creating a soap message (stored in variable 'test') that contains soap messages as values for tags.

i am able to see the prefix in the output. but what happens is the name space definition for soapenv prefix.. of the soap message present in the v002:request tag is truncated and the namespace definiton is present only once at the top... in the soap message (stored in 'test') that is created.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:template match="/">
<xsl:variable name="test">
<soapenv:Envelope xmlns:dp="http://www.datapower.com/schemas/management" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v002="http://www.company.com/schema/app/Loggi ... Types/V001" xmlns:v1="http://www.company.com/wsdl/app/EnterpriseLogging/V1_0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<soapenv:Header/>
<soapenv:Body>
<v002:verbosityData>
<v002:request>
<soapenv:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body/>
</soapenv:Envelope>
</v002:request>
<v002:response>
<ns1:Envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:osa="http://www.company.com/xmlschema/resour ... cture/v001">
<ns1:Body/>
</ns1:Envelope>
</v002:response>
</v002:verbosityData>
</soapenv:Body>
</soapenv:Envelope>
</xsl:variable>
<xsl:copy-of select="$test"/>
</xsl:template>
</xsl:stylesheet>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: SOAP Envelope namespace not seen in response

Post by sorin_ristache »

Hello,

I think there is no problem with the SOAP message generated by the XSLT stylesheet. It is a well formed XML document in which it is enough to declare the soapenv prefix on the root element soapenv:Envelope. The prefix does not have to be declared again on the v002:request element.

The soapenv prefix must be declared on the root element because the start tag and end tag of that element use it.


Regards,
Sorin
anboss
Posts: 8
Joined: Wed May 07, 2008 4:43 pm

Re: SOAP Envelope namespace not seen in response

Post by anboss »

Sorin...

is there a way to include namespace definition within each tag instead at one place?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: SOAP Envelope namespace not seen in response

Post by sorin_ristache »

Hello,

You can just repeat the declaration of the prefix on every XML element of your XML document generated by the XSLT stylesheet:

Code: Select all

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
But I do not understand why you want to repeat the declaration of an XML namespace prefix for every element instead of declaring it once on the root element. The declaration of the soapenv prefix is needed on the root element anyway so repeating it in child elements is redundant.


Regards,
Sorin
anboss
Posts: 8
Joined: Wed May 07, 2008 4:43 pm

Re: SOAP Envelope namespace not seen in response

Post by anboss »

the reason is we are sending the soap message containing soap messages to another web service which extracts the soap messages present inside the big one. and logs that in linux box. the remove webservice extracts the soap messages which ultimately does not contain the namespace. as a result the extracted soap message becomes invalid. we dont want the remote webservice to take the extra task of inserting appropriate namespaces.
Post Reply