Search code examples
web-servicessoapcoldfusionlucee

Using ColdFusion to parse WSDL/SOAP


I'm passing in a USERID into what I believe to be either a SOAP request. I've never worked with SOAP and not quite sure where to start so if my question doesn't quite make sense, let me know and I'll try to fill in missing details.

Context for question: I'm converting an excel macro (the macro will query pass the userid to the server and the server will return employee details such as name, email, address, etc.) and turning into a web lookup.

I have the following code:

<cfscript>
variables.sso = '55555';
variables.serverURL = "http://search.corporate.ge.com/ldq/Query";
variables.queryString = "?serverID=ssoprod&searchBase=ou=domainWorker,+o=domain.com&Prebuilt=true&scope=2&filter=(domainoraclehrid=#variables.sso#)";
variables.webservice = "#variables.serverURL##variables.queryString#";
</cfscript>

<cfdump var="#variables.webservice#">
<cfhttp url="#variables.webservice#" method="get" result="response"></cfhttp>
<cfdump var="#response.fileContent#" label="soap content">

When I take the value from the dump of variables.webservice, and paste it directly into a browser, I get the following (assume userID of 55555):

This XML file does not appear to have any style information associated with it. The document tree is shown below.  
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dsml="http://www.dsml.org/DSML">
    <SOAP-ENV:Body>
    <dsml:dsml xmlns:dsml="http://www.dsml.org/DSML">
        <dsml:directory-entries>
            <dsml:entry dn="domainssouid=1D8B0D04-91F0-1CAE-9BD7-002128B20D70,ou=domainWorker, o=domain.com">
            ...
            <dsml:attr name="employeetype">
                <dsml:value>Contractor</dsml:value>
            </dsml:attr>
            <dsml:attr name="givenname">
                <dsml:value>John</dsml:value>
            </dsml:attr>
            <dsml:attr name="postalcode">
                <dsml:value>90210</dsml:value>
            </dsml:attr>
            <dsml:attr name="domainoraclehrid">
                <dsml:value>456456987</dsml:value>
            </dsml:attr>
            <dsml:attr name="mail">
                <dsml:value>[email protected]</dsml:value>
            </dsml:attr>
            <dsml:attr name="cn">
                <dsml:value>Doe, John</dsml:value>
            </dsml:attr>
            ...
        </dsml:entry>
    </dsml:directory-entries>
</dsml:dsml>
</SOAP-ENV:Body>

BUT when I dump of #response.fileContent#, I get something different, I get:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:f="http://www.w3.org/2001/06/soap-faults">
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <SOAP-ENV:faultcode>MustUnderstand</SOAP-ENV:faultcode>
            <SOAP-ENV:faultstring>ou=domainWorker,+o=domain.com: [LDAP: error code 34 - Invalid DN], Name Not valid - ou=domainWorker,+o=domain.com - filter -(domainoraclehrid=55555) </SOAP-ENV:faultstring>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Ultimately what I'd like to do is parse out the "cn", and "mail" details. What am I missing here? I suspect it might have something to do with ME accessing the URL directly (logged in user) where as the request is being made from a server and isn't "authenticated". If that is the case, how can I resolve this?


Solution

  • Update:

    (Originally, I was a little perplexed about why I couldn't reproduce your results with CF2018, but now that I know you're using Lucee, the difference makes sense.)

    Looking over the successful response, I noticed it doesn't contain a +, before the "o" (organization Name):

    <dsml:entry dn="domainssouid=xxxx,ou=domainWorker, o=domain.com">
    

    Which means the VBA call is treating the + as an encoding for a space, but CFHTTP is encoding it as a literal plus sign instead, causing an error because it breaks the LDAP query:

    [LDAP: error code 34 - Invalid DN], Name Not valid - ou=domainWorker,+o=domain.com

    The solution is to get rid of the plus sign + and replace it with a space:

    searchBase=ou=domainWorker, o=domain.com
    

    Interestingly, dumping the http request data shows that apparently CF2018 does things differently. Unlike Lucee, CF2018 treats the plus sign as a space.

    CF2018 => %20 (space)

    searchBase=ou%3DdomainWorker%2C%20o%3Ddomain.com
    

    Lucee 5.2.8.50 => %2B (plus sign)

    searchBase=ou%3DdomainWorker%2C%2Bo%3Ddomain.com