DataPower

 View Only

 Preserve white space in Web Service Proxy

Ruedi Lehmann's profile image
Ruedi Lehmann posted Thu May 22, 2025 08:30 AM

Having a request containing a whitespace XML element (<cc:stringValue> </cc:stringValue>)  the element is replaced with <cc:stringValue/> in the input context. Is there a way to force Datapower to preserve the whitespace.

I know that a whitespace element is not the proper way to go, bit this is out of my scope.

Thank you for any input.

Joseph Morgan's profile image
Joseph Morgan IBM Champion

I should have setup a test scenario before answering, but...are you doing some kind of transform, or is DataPower automatically dropping it?

If you are doing a transform, (and I'm shooting for the moon here because I don't think I've ever tried this in DataPower), have you tried to use something like <xsl:preserve-space elements="*"/>?

Ruedi Lehmann's profile image
Ruedi Lehmann

To be more precise: The element is replaced after Datapower has executed the schema validation and before I have any access to the document.
I tried xml:space="preserve" in the request.
<xsl:preserve-space elements="*"/> is not an option. The WSDL and schemas are provided by the external service provider.

Joseph Morgan's profile image
Joseph Morgan IBM Champion

The only thing, now, that comes to mind if to see if you can get the message creator to embed spaces as entities.   I think it is  '&#32;' or something very close to that.  

Are you using a WSP or MPG or XMLFW?   If WSP, I get it, but if the others, is it possible to pre-transform it (again, I should really setup a test service on this and try it myself before answering..)?

EDIT:  OK... my curiosity go the best of me.  I found this stackoverflow article on using entities for spaces in XML:

https://stackoverflow.com/questions/514635/represent-space-and-tab-in-xml-tag

Hermanni Pernaa's profile image
Hermanni Pernaa IBM Champion

Are you applying the transform to the output that comes from the schema validate action? If that is the problem you can just use the original INPUT context as the input for the transform. No need to use the output from the validate action.

Ajitabh Sharma's profile image
Ajitabh Sharma

How about using <cc:stringValue><xsl:text>#x20;</xsl:text></cc:stringValue>?

Ajey Chekravarthi's profile image
Ajey Chekravarthi

For webservice proxy we need to send a request with &#xA0; to preserve the space

SOAPUI request and response:

datapower screen:

Ruedi Lehmann's profile image
Ruedi Lehmann

Hi all
Thank you for support.
We finally ended up to modify the xml schema with the <xsd:whiteSpace value="preserve" /> restriction in the simple type.