soap-client icon indicating copy to clipboard operation
soap-client copied to clipboard

CDATA

Open victorgp89 opened this issue 7 years ago • 8 comments

Hi, It's possible extract CDATA when XML is generate? Thanks for advance.

victorgp89 avatar Oct 17 '18 11:10 victorgp89

Can you elaborate?

goetas avatar Oct 17 '18 11:10 goetas

Yes, I have this request:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://www.w3.org/2003/05/soap-envelope">
 <SOAP:Header xmlns:SOAP="http://www.w3.org/2003/05/soap-envelope">
   <ns-7067d4bd:user_validation xmlns:ns-7067d4bd="http://ws.link.hotelresb2b.com/login">
     <ns-7067d4bd:usr_code><![CDATA[IGM]]></ns-7067d4bd:usr_code>
     <ns-7067d4bd:usr_name><![CDATA[IGM_WEB_P]]></ns-7067d4bd:usr_name>
     <ns-7067d4bd:usr_pwd><![CDATA[igm_98ghot]]></ns-7067d4bd:usr_pwd>
     <ns-7067d4bd:language><![CDATA[1]]></ns-7067d4bd:language>
   </ns-7067d4bd:user_validation>
 </SOAP:Header>
 <SOAP:Body>
   <ns-8022e3d1:request_books xmlns:ns-8022e3d1="http://ws.link.hotelresb2b.com/hotel">
     <ns-8022e3d1:hotel>
       <ns-8022e3d1:hotel_code><![CDATA[139719]]></ns-8022e3d1:hotel_code>
       <ns-8022e3d1:hotel_user><![CDATA[OGUCSF]]></ns-8022e3d1:hotel_user>
       <ns-8022e3d1:hotel_pwd><![CDATA[HA139719]]></ns-8022e3d1:hotel_pwd>
     </ns-8022e3d1:hotel>
     <ns-8022e3d1:start_date>2018-10-15</ns-8022e3d1:start_date>
     <ns-8022e3d1:end_date>2018-10-16</ns-8022e3d1:end_date>
   </ns-8022e3d1:request_books>
 </SOAP:Body>
</SOAP:Envelope>

I know prefic in namespace is just randomly generated. But when I send to channel it return void response. Without it the response is OK.

It means that his XML compilant is not working sure?

It only happens when the SOAP:Header or the SOAP:Body have prefixes. If only one of the two has it works correctly

victorgp89 avatar Oct 17 '18 11:10 victorgp89

It means that his XML compilant is not working sure?

Most likely yes

if you want to get rid or CDATA, you have to set cdata: false in the metadata files (see https://jmsyst.com/libs/serializer/master/reference/yml_reference)

goetas avatar Oct 17 '18 12:10 goetas

And is it possible to change the prefix: ns-8022e3d1 for an ns1 for example?

victorgp89 avatar Oct 17 '18 13:10 victorgp89

not easily, you will have to set them on your metadata somehow

goetas avatar Oct 17 '18 14:10 goetas

I see in YamlConverter.php

In line: 150

$data["xml_root_name"] = "ns-" . substr(sha1($data["xml_root_namespace"]), 0, 8) . ":" . $data["xml_root_name"];

Then modifying it in the metadata will not solve the problem, will it?

victorgp89 avatar Oct 17 '18 14:10 victorgp89

yes, it that, but you need to find one that does not conflict with other

goetas avatar Oct 17 '18 14:10 goetas

For example add attribute in metadatas and set it in Schema.php. xml_element: prefix: 'ns1' namespace: 'http://ws.link.hotelresb2b.com/hotel'

For xml-sematics prefix should be almost irrelevant but for some clients is not the same for some reason...

victorgp89 avatar Oct 17 '18 15:10 victorgp89