[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with a very particular case of HTTPAPI



Hi Jeff,

> 
> Thanks for the response, but I got the same error, but ´pointing to 
> another position,take a look to the attache file.
> 

Take a look at the WSDL file that you uploaded to the list.  Look at 
what it says!  Here's a quote:

   <wsdl:service name="Citas">
     <wsdl:port name="CitasSoap" binding="tns:CitasSoap">
       <soap:address 
location="http://172.30.7.2/singecmotorcitas/citas.asmx"; />
     </wsdl:port>
   </wsdl:service>

Do you see anywhere there that it says there's more than one way to 
access the service?  I don't.  All I see is ONE port named CitasSoap. 
It does not say that you can simply POST some HTTP form data to the 
service, does it?  It only says that you can access it via one binding, 
and that binding is called CitasSoap.  Let's look at the definition for 
that binding:

   <wsdl:binding name="CitasSoap" type="tns:CitasSoap">
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http"; 
style="document" />
     <wsdl:operation name="RecibeXML">
       <soap:operation 
soapAction="http://tempuri.org/ws_MotorSINGEC/Citas/RecibeXML"; 
style="document" />
       <wsdl:input>
         <soap:body use="literal" />
       </wsdl:input>
       <wsdl:output>
         <soap:body use="literal" />
       </wsdl:output>
     </wsdl:operation>
   </wsdl:binding>

So what sort of binding does this port use?  It uses this one 
"http://schemas.xmlsoap.org/soap/http";.  That string means SOAP OVER 
HTTP.  It does not mean that you can post form data to the service.  IT 
only means that you can send a SOAP document over HTTP.  There's only 
one operation supported, adn that operation is called RecibeXML.

Let's look at the PortType of the RecibeXML operation, next:

   <wsdl:portType name="CitasSoap">
     <wsdl:operation name="RecibeXML">
       <wsdl:input message="tns:RecibeXMLSoapIn" />
       <wsdl:output message="tns:RecibeXMLSoapOut" />
     </wsdl:operation>
   </wsdl:portType>

It accepts one input message called RecibeXMLSoapIn, and one output 
message called RecibeXMLSoapOut. Since we're currently trying to figure 
out the input message, let's look at the documentation for that message:

   <wsdl:message name="RecibeXMLSoapIn">
     <wsdl:part name="parameters" element="tns:RecibeXML" />
   </wsdl:message>

So this message consists of only one parameter, it's name is 
"parameters" and it's data type is "RecibeXML".  Let's look at the 
definition of the "RecibeXML" data type next:

   <wsdl:types>
     <s:schema elementFormDefault="qualified" 
targetNamespace="http://tempuri.org/ws_MotorSINGEC/Citas";>
       <s:element name="RecibeXML">
         <s:complexType>
           <s:sequence>
             <s:element minOccurs="0" maxOccurs="1" name="stringXML" 
type="s:string" />
           </s:sequence>
         </s:complexType>
       </s:element>

RecibeXML is a "complex" data type that consists of one element named 
stringXML, which is a STRING.  It can only occur once.  IT does not say 
anything about this element containing any additional sub-elements or 
XML tags within it.  It's just a string.

 From that, I come up with the following SOAP message:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
      xmlns:tns="http://tempuri.org/ws_MotorSINGEC/Citas"; >
<SOAP-ENV:Body>
<tns:RecibeXML xmlns:tns="http://tempuri.org/ws_MotorSINGEC/Citas";>
    <tns:stringXML>
... string to send goes here ...
    </tns:stringXML>
</tns:RecibeXML>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Okay, so that is the message to send.  Nothing else.  There's no <cita> 
tag.  No <numeroIdentidad>, <nombreCompleto>, <numeroIdentificacion>, 
etc, etc.  According to the WSDL document that you posted, none of 
sub-tags that your program has within the stringXML tag should be 
included in the SOAP message.

Does that all make sense to you?  To summarize:

a) You *must* use SOAP to call this web service.
b) You *cannot* put other XML tags within the <stringXML> tag.

For that reason, I agree completely with what Magne stated yesterday 
(which is why I did not reply earlier).  All of the XML tags that were 
in the "XML Bancos.doc" Word document that you uploaded are NOT part of 
the SOAP envelope.  They need to be "escaped" or "encoded" so that they 
won't be recognized as XML tags when the SOAP document is parsed!!  They 
need to look like an ordinary character string to the SOAP parser.

In other words, they should be normal character data ("CDATA")

Does that make sense to you?  I want to make sure that this is clear, 
because it's where you're running into trouble. I would like you to be 
able to understand the problem so that you know how to properly solve 
it. Your question has ABSOLUTELY NOTHING TO DO WITH HTTPAPI.  You 
question is about XML in general.  Your question amounts to this:

"How do I escape XML tags so that they appear as an ordinary character 
string to an XML parser?"

There are two ways to escape XML tags.  The first one (and the one 
that's most common) is to escape the < and > symbols.  That way an XML 
parser won't see them as XML tags.

For example, instead of

       <cita>

You'd code:

      &lt;cita&gt;

When the XML parser interprets the data, it won't make it an XML tag. 
Instead, it'll convert &lt; into <, and &gt; into >, and it'll return 
<cita> as data to the application.

You'd have to do that for every < or > symbol that's in the Word 
document that you uploaded.  (But not the SOAP message itself!)

The other way, which is probably simpler, is to declare the inner XML 
document as CDATA.  This is what Magne (correctly) suggested. 
Unfortunately, the syntax of the CDATA element that Magne posted was not 
correct, so it didn't work.

I encourage you to learn and understand what this means.  Please go 
through the XML CDATA tutorial at the following link:
http://www.w3schools.com/xml/xml_cdata.asp

Once you understand, I think you'll see what you need to do.  You need 
to write code that looks something like this (note the <![CDATA[ and ]]> 
that I added to the SOAP document):

        SOAP =
          '<?xml version="1.0" encoding="utf-8"?>'+ CRLF
         +'<soap:Envelope 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; '
         +CRLF +'xmlns:xsd="http://www.w3.org/2001/XMLSchema";'+ CRLF
         +'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>'+ CRLF
         +' <soap:Body>'+ CRLF
         +'  <RecibeXML 
xmlns="http://tempuri.org/ws_MotorSINGEC/Citas";>'+ CRLF
         +'   <stringXML><![CDATA['
         +'<cita ciudad="3" tipoCita="" numTransaccion="" idCita="" 
fechaCita=""'
         +' horaCita="" confirm="" estatusConfirm=""> '+ CRLF
         +' ' +CRLF
         +'    <ciudadano>'
         +'<numeroIdentidad>0101-1978-01018</numeroIdentidad>'
         +'<nombreCompleto>AMERICA IVONNE ALEMAN ARGUETA </nombreCompleto>'
         +'<numeroIdentificacion></numeroIdentificacion>'
         +'    </ciudadano>'
         +'<datosTransaccion>'
         +'<fechaTransaccion>08/24/04</fechaTransaccion>'
         +'<idSucursal>314</idSucursal>'
         +'<duracionPasaporte>1</duracionPasaporte>'
         +'<costoPasaporte></costoPasaporte>'
         +'<costoCita></costoCita>'
         +'<montoCredito></montoCredito>'
         +'<totalTransaccion></totalTransaccion>'
         +'<tipoCambio>18.182</tipoCambio>'
         +'<folioTGR1>0</folioTGR1>'
         +'<transaccionExtranjero>'
         +'<pais></pais>'
         +'<ciudad></ciudad>'
         +'<tipoServicio></tipoServicio>'
         +'<numDocPago></numDocPago>'
         +'<comentarioPago></comentarioPago>'
         +'<montoPago></montoPago>'
         +'</transaccionExtranjero>'
         +'</datosTransaccion>'
         +'<pasaporteAnterior>'
         +'<libretaAnterior>B038626 </libretaAnterior>'
         +'<fechaExpedicion>02/04/2004</fechaExpedicion>'
         +'<fechaVencimiento>02/04/2009</fechaVencimiento>'
         +'<tiempoVigencia></tiempoVigencia>'
         +'<mesesVigencia></mesesVigencia>'
         +'</pasaporteAnterior>'
         +'</cita>'
         + ']]></stringXML>' + CRLF
         +'  </RecibeXML>' + CRLF
         +' </soap:Body>' + CRLF
         +'</soap:Envelope>';

Now, <![CDATA[ ]]> is not exactly a standard.  Most XML parsers 
understand it and handle it correctly, but it's not part of the official 
standard, so if this doesn't work, you'll have no choice but to convert
the XML tags to use &lt; and &gt; and possibly &amp; to replace <, > and 
& symbols.

But, please make sure you undersatand why you're doing this, and what 
the correct procedure is to do these things in XML.  Hopefully the link 
I provided above will make this all clear to you.
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------