AssignMessage with payload in xml

Hi all,

I use a AssignMessage policy to return xml payload. How could I insert "<?xml version="1.0" encoding="UTF-8" ?>" in the payload.

When I set this object in AssignMessage policy:

<Payload contentType="application/xml"> <?xml version="1.0" encoding="UTF-8" ?>xxxx </Payload>

Apigee designer display "Invalid XML".

Any idea ?

Thanks

Solved Solved
1 3 772
1 ACCEPTED SOLUTION

That is invalid XML. It's not valid to include a declaration in the middle of ... an XML Document. The assignmessage configuration is XML, so you can't insert that declaration under <Payload>.

Well, you can't do it in the usual way. But have you tried CDATA?

<Payload contentType="application/xml"><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
xxxx ]]> </Payload>

CDATA is a way to "escape" whatever is contained within. That might work.

View solution in original post

3 REPLIES 3

That is invalid XML. It's not valid to include a declaration in the middle of ... an XML Document. The assignmessage configuration is XML, so you can't insert that declaration under <Payload>.

Well, you can't do it in the usual way. But have you tried CDATA?

<Payload contentType="application/xml"><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
xxxx ]]> </Payload>

CDATA is a way to "escape" whatever is contained within. That might work.

Hi Dino-at-Google,

It works with CDATA. Thanks a lot.

Bertrand

Hi @Bertrand Bely you have to set XML in payload , using set variable u can get solution.