ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportSpace Character not showing up in Response XML

Post new topicReply to topic
Space Character not showing up in Response XML View previous topic :: View next topic
Author Message
akkypaul
PostPosted: Mon Jun 22, 2020 12:11 pm Post subject: Space Character not showing up in Response XML Reply with quote

Apprentice

Joined: 30 Jun 2014
Posts: 44
Location: India

I am trying to create an XML response which with one of the fields which has be has the values of SAPCE [' '].

I have kept the encoding as 546 and the ccsid as 1208.

The simple assignment statement does assign a space character to response which I can see while debugging.
However, when I see the response in ReadyAPI's output, I don't see the space character.

Code:
SET OutputRoot.SOAP.Body.SomeField.Somefield   = ' ';


Actual Output:
Code:
<Somefield></Somefield>


Required Output:
Code:
<Somefield> </Somefield>



Can someone please tell me what am I missing here?

Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jun 22, 2020 12:34 pm Post subject: Re: Space Character not showing up in Response XML Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 25995
Location: Texas, USA

akkypaul wrote:
Can someone please tell me what am I missing here?


Potentially nothing.

Upfront let me be clear: I don't know "ReadyAPI", never used it, never heard of it.

Firstly are you sure that the space you're adding isn't being parsed out by the ReadyAPI tool? Whitespace can be handled in a number of different ways and it's highly likely that this tool is considering the whitespace to be irrelevant content & removing it.

Secondly, and on the same line, are you sure you want a space? There's a difference between these:

Code:

<Somefield> </Somefield>
<Somefield></Somefield>
<Somefield/>


Even though a lot of people use them interchangeably, parsers do not.

I would put a bet down (especially as you claim to be able to see the space while debugging) that it's getting removed somewhere in the serialization/deserialization/parsing space and I'd double down on parsing.

Take a user trace (which is not the same as using the debugger) to confirm that you're getting the space in the message tree. Then use something like Wireshark to see what's actually being delivered over the wire to this ReadyAPI tool. As I said, I bet what's getting delivered has a space there.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Mon Jun 22, 2020 3:41 pm Post subject: Reply with quote

Jedi

Joined: 25 Mar 2003
Posts: 2126
Location: Melbourne, Australia

You may be missing an understanding of "whitespace" in the XML element content space. Adding spaces may cause ambiguities with some parsers, and many will ignore or compact spaces unless they are told otherwise. Do a search for the reserved attribute "xml:space".
_________________
Glenn
Back to top
View user's profile Send private message
akkypaul
PostPosted: Mon Jun 22, 2020 10:54 pm Post subject: Reply with quote

Apprentice

Joined: 30 Jun 2014
Posts: 44
Location: India

Hello Vitor,

Thank you for replying.
You are correct. The ReadyAPI tool trims the whitespace (in this case a Space Character) and presents the output.
I confirmed this by feeding the response directly to the backend and they confirmed that they were able confirm that they could see a space in the Request XML that they received. I also confirmed the same with a user trace as suggested.



Quote:
Secondly, and on the same line, are you sure you want a space? There's a difference between these:

>> Yes, I understand the difference between them. I am sure that I want to send a space character and also receive a space character but I do not see it in my main flow.

Now, there is a problem with receiving the SPACE character from the backend.
The backend flow sends a field containing a SPACE Character.

To give you a background, I am sending a SOAP request to Backend and getting a SOAP response from it using a SOAP Request Node. The SOAP request node is configured with a WSDL.

In the backend, I am reading an XML file from a File Input node using XMLNSC parser and the backend flow is able to read the SPACE Character just fine.

Code:
<AnotherField> </AnotherField>


However, when this backend response is supplied back to the main flow via a SOAP Request Node, it trims that character and presents it as a null field.

Code:
<AnotherfField/>


Is there anyway in which I can retain that SPACE Character????

Back to top
View user's profile Send private message
akkypaul
PostPosted: Mon Jun 22, 2020 10:57 pm Post subject: Reply with quote

Apprentice

Joined: 30 Jun 2014
Posts: 44
Location: India

gbaddeley wrote:
You may be missing an understanding of "whitespace" in the XML element content space. Adding spaces may cause ambiguities with some parsers, and many will ignore or compact spaces unless they are told otherwise. Do a search for the reserved attribute "xml:space".


Hello Glen,

Thank you so much for replying.
I read through the "xml:space" documentation and found it to be very helpful. Unfortunately, I would not be able to include this attribute in my XML request and neither would I be able to receive this attribute from the response because of schema restrictions.

Back to top
View user's profile Send private message
timber
PostPosted: Tue Jun 23, 2020 1:35 am Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1120

Check the XSD definition and the simple type for the offending tag. I wonder if the XSD type has a facet <xs:whitespace value="collapse"/>
Back to top
View user's profile Send private message
akkypaul
PostPosted: Tue Jun 23, 2020 4:19 am Post subject: Reply with quote

Apprentice

Joined: 30 Jun 2014
Posts: 44
Location: India

Thank for your replying timber.

The XSD definition has nothing of this sort.
It has an enumeration though.

Code:
<xsd:simpleType name="AnotherField">
    <xsd:annotation>
     <xsd:documentation xml:lang="EN">
      <ccts:RepresentationTerm>Code</ccts:RepresentationTerm>
     </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:token">
     <xsd:enumeration value=" "/>
     <xsd:enumeration value="A"/>
     <xsd:enumeration value="B"/>
     <xsd:enumeration value="C"/>
     <xsd:enumeration value="D"/>
     <xsd:maxLength value="1"/>
    </xsd:restriction>
   </xsd:simpleType>
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Tue Jun 23, 2020 3:04 pm Post subject: Reply with quote

Jedi

Joined: 25 Mar 2003
Posts: 2126
Location: Melbourne, Australia

You may need to rethink the requirement for SPACE character in XML content. Can its meaning be represented by another character? Can it be encoded using & # 032 ; & #160 ; or \u0020 ? Can the SPACE be moved into an attribute in the element start tag? eg. <myelem AnotherField=' '>
_________________
Glenn
Back to top
View user's profile Send private message
timber
PostPosted: Thu Jun 25, 2020 4:52 am Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1120

akkypaul said:
Quote:
The XSD definition has nothing of this sort.

The xsd says:
Code:
<xsd:restriction base="xsd:token">

The XSD spec says: https://www.w3.org/TR/xmlschema-2/#token

All the information is out there - you just have to know where to look!
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportSpace Character not showing up in Response XML
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.