Encoding XML for SOAP Request into the SOAP Envelope



I'm doing a request via cURL, successfully, to a SOAP service. The WSDL is here. The plan is using a request like this but via Node.js. That's because i can't make this work using a Node.js soap client. I'm trying to code the request using the Node.js request package. The request i can do is using the command


curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:probarConexion" --data @envelope.xml http://ift.tt/1trXjSU


The envelope.xml file contains



<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://ift.tt/sVJIaE" xmlns:xsi="http://ift.tt/ra1lAU" xmlns:SOAP-ENV="http://ift.tt/sVJIaE">
<SOAP-ENV:Header/>
<ns0:Body>
<probarConexion>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;Solicitud
xsi:schemaLocation=&quot;http://ift.tt/1AJCex4 http://ift.tt/1trXj5c;
xmlns=&quot;http://ift.tt/1AJCex8;
xmlns:xsi=&quot;http://ift.tt/1trXjSW;
&lt;rfc&gt;AAA010101AAA&lt;/rfc&gt;
&lt;accion&gt;probarConexion&lt;/accion&gt;
&lt;modo&gt;debug&lt;/modo&gt;
&lt;/Solicitud&gt;
</probarConexion>
</ns0:Body>
</SOAP-ENV:Envelope>


That's because the service, actually, needs an XML like this to do the Request



<?xml version="1.0" encoding="UTF-8"?>
<Solicitud
xsi:schemaLocation="http://ift.tt/1AJCex4 http://ift.tt/1AJCfBf"
xmlns="http://ift.tt/1AJCex4"
xmlns:xsi="http://ift.tt/ra1lAU">
<rfc>AAA010101AAA</rfc>
<accion>probarConexion</accion>
<modo>debug</modo>
</Solicitud>


It is my understand the XML required by the Web Service is placed into the Envelope, but because the Envelope is actually and XML, we need it encoded into something like an HTML Encoding.


So, my first question is: What's the Encode method i need to insert the request XML into the SOAP Full XML request, the envelope?


The second is: With this encoding method, can i encode characters like the 'ñ', or another ones like 'é', 'Ó' and, in general, these i can use to write in spanish?


And the last one is more immediate, i think i can use the node-htmlencode package to do it, but i need a confirmation: When i receive the answer from the Web Service, what's the decode method to get the response XML?


Thanks for your help!


No comments:

Post a Comment