Skip to main content
reuv1
Participant
September 16, 2015
Answered

problems with xml returned when invoking a web service with CF11

  • September 16, 2015
  • 1 reply
  • 317 views

hi, i have run into an unusual behavior when invoking web services.

i am calling a web service that returns an XML like this:

<children>

     <child>

          <firstname>john</firstname>

          <lastname>doe</lastname>

     </child>

</children>

when invoking this web service from CF10, it works just fine. However, when invoking from CF11, i only get this:

<child>

      <firstname>john</firstname>

      <lastname>doe</lastname>

</child>


no <children>? for some reason, CF11 ignores/hides the topmost XML level. this doesn't happen on previous versions. why? the server that hosts the web service is CF11 too.

This topic has been closed for replies.
Correct answer BKBK

Report it as a Coldfusion bug. In any case, I would advise you to ensure that your web service returns a string, not an XML object.

That is because a web service should be universal. Callers from .NET, Java, PHP, ASP, and so on, will interpret a string in exactly the same way. Whereas, a Coldfusion XML object is a construct that is understood only in CFML.

Your return string should also begin with the XML declaration, like this

<?xml version="1.0" encoding="UTF-8"?>

<children>

     <child>

          <firstname>john</firstname>

          <lastname>doe</lastname>

     </child>

</children>


Then it is clear to the caller what the cat has brought in.

1 reply

BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
September 17, 2015

Report it as a Coldfusion bug. In any case, I would advise you to ensure that your web service returns a string, not an XML object.

That is because a web service should be universal. Callers from .NET, Java, PHP, ASP, and so on, will interpret a string in exactly the same way. Whereas, a Coldfusion XML object is a construct that is understood only in CFML.

Your return string should also begin with the XML declaration, like this

<?xml version="1.0" encoding="UTF-8"?>

<children>

     <child>

          <firstname>john</firstname>

          <lastname>doe</lastname>

     </child>

</children>


Then it is clear to the caller what the cat has brought in.

reuv1
reuv1Author
Participant
September 17, 2015

Thanks,

I have reported it as a bug. It does make more sense to return the XML as a string rather than a CF XML object. Though this is a pre-existing web service that is used by several internal CF apps.