CUCM 6.13 - cURL Issue

Version 1
    This document was generated from CDN thread

    Created by: Keith Lunn on 07-08-2009 12:46:24 AM
    Hey Folks! - Has anyone used cURL with AXL? Im trying to connect to a 6.13 server using cURL and i get a 5001 error - Content is not allowed in prolog.
    >D:\Data\Utils\cURL\curl-7.19.5\curl.exe -k -u user1:pass1 -H "Content-type: text/xml;" -H "SOAPAction: CUCMB ver=6.1" -d executeSQLQuery.xml <a>https://10.28.21.66:8443/axl/</a>]
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="<a>http://schemas.xmlsoap.org/soap/envelope/</a>]"
    SOAP-ENV:encodingStyle="<a>http://schemas.xmlsoap.org/soap/encoding/</a>]">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
    <faultcode>SOAP-ENV:Client</faultcode>
    <faultstring>Content is not allowed in prolog.</faultstring>
    <detail>
    <axl:Error xmlns:axl="<a>http://www.cisco.com/AXL/API/6.1</a>]">
    <axl:code>5001</axl:code>
    <axl:message>Content is not allowed in prolog.</axl:message>
    <request/>
    </axl:Error>
    </detail>
    </SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
    The xml request file (executeSQLQuery.xml ) contents:
    <?xml version="1.0"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="<a>http://schemas.xmlsoap.org/soap/envelope/</a>]" xmlns:axlns="<a>http://www.cisco.com/AXL/API/6.1</a>]">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
    <axlns:executeSQLQuery sequence="600">
    <sql>SELECT userid, firstname, lastname FROM enduser WHERE firstname LIKE 'Ke%';<sql>
    </axlns:executeSQLQuery>
    </SOAP-ENV:Body></SOAP-ENV:Envelope>
     
    Any ideas as to what is causing the "Content is not allowed in prolog" error. I use the exact same SOAP payload in a program and it works fine in my program.
    Thanks!

    Subject: RE: CUCM 6.13 - cURL Issue
    Replied by: David Staudt on 07-08-2009 03:32:20 AM
    I'm pretty sure that error is specific to having anything at all (white space, BOM) before the XML content.  This is especially common when you edit the XML file in notepad, and save it as Unicode rather than ANSI - this results in an invisible 3 byte byte-order-mark (BOM) being placed at the beginning of the file which will caues the server-side parser to fail.  You can see this in a hex editor; you can correct it by resaving the XML file as ANSI in notepad, or otherwise remove the BOM.
     
    There is a small how-to for Serviceability SOAP using CURL here: http://developer.cisco.com/web/axl/wikidocs?src=/wiki/display/AXL/how-to_CURL

    Subject: RE: CUCM 6.13 - cURL Issue
    Replied by: Keith Lunn on 07-08-2009 03:23:37 PM
    Hi David - I found my issue! Option -d indicates what to send as POST data.
    I used -d executeSQLQuery.xml. This actually sent to the AXL Web service "executeSQLQuery.xml" instead of the contents of the file executeSQLQuery.xml - thus it was a malformed XML stream - thus the error "Content is not allowed in prolog.".
    The solution is to use this form of the -d option: -d @executeSQLQuery.xml. Using the prefix "@" in front of the filename means to use the contents of the file.
    Corrected cURL Command line:
    curl.exe -k -u user1:pass1 -H "Content-type: text/xml;" -H "SOAPAction: CUCMB ver=6.1" -d @executeSQLQuery.xml https://10.28.21.66:8443/axl/
    I just started using cURL so it's one of those newbie gotchas!


    Thanks,
    Keith