Interact with ColdFusion API?

Ok so my business just threw a wrench in my software. Normally I get all the days work orders from a CSV export. Easy, so I built my management software (myself) around the CSV import. Done, worked great for the last few years. So now this company is forcing me to switch over to a Coldfusion API. Basically I ask it for the work order info and it’s supposed to comes back in an XML format. Not exactly sure how it returns it at this point, but that isn’t important yet.

Basically what I am asking. Is there a way to use PHP to talk to the ColdFusion API or am I screwed? By screwed I mean have to pay adobe for the right just to learn their stupid language to talk to an API that should have been made into a universal javascript api? Sorry, frustration over the last few weeks working on this is getting to me :slight_smile:

Thanks for reading…

When you get the XML response, you could parse it in PHP easily enough (e.g. with the SimpleXML functions).

Do you know anything about how to get the data from ColdFusion? Do you send an HTTP request?

I’m not exactly sure how to work with coldfusion. I know they gave me a handful of URLs. Basically a URL for each different part of the API system. So basically I have the URL for, say, getting my daily work orders and I’m supposed to send my Username, Password, and Date to that URL. Problem is, I doubt it works like a javascript api and you just include it in the URL.

Thanks for giving me an example of an XML parser, already worked with that one before and it works good enough for me. It’s actually already part of the software I’ve been working on.

You could try sending POST requests to the URL(s). Did they tell you the field names for username / password etc?

Ok so, I finally got an example of the request that needs to be made and response that I get back. I am not completely sure how coldfusion talks to itself (as in using it to request from an API)

REQUEST:
[php]
<soapenv:Envelope xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:wor=“http://workorder.services.RSP.Dishnetwork.pub”>
soapenv:Header/
soapenv:Body
<wor:WorkOrderDetailsByWorkOrderNumber soapenv:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/”>
USER
PASS
XXXXXXXXXXXXXXXX
</wor:WorkOrderDetailsByWorkOrderNumber>
</soapenv:Body>
</soapenv:Envelope>
[/php]

RESPONSE
[php]
<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
soapenv:Body
<ns1:WorkOrderDetailsByWorkOrderNumberResponse soapenv:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/” xmlns:ns1=“http://workorder.services.RSP.Dishnetwork.pub”>

		<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
			<xmlResponse>
				<xmlWorkOrders>						
					<workOrder>
						<Number>88011805100015005</Number>
					</workOrder>
				</xmlWorkOrders>
			</xmlResponse>
		]]>
			
		</WorkOrderDetailsByWorkOrderNumberReturn>
	</ns1:WorkOrderDetailsByWorkOrderNumberResponse>
</soapenv:Body>

</soapenv:Envelope>
[/php]

So how in the heck do I request something like that?

Would something like this create the same effect?
[php]
$content = xxx // the xml stuff like the request
$url = xxx // URL to ColdFusion API

$request = stream_context_create($content);
$response = file_get_contents($url, false, $request);
[/php]

Or am I off?

The API uses SOAP for communication. You may want to look at SOAP in the manual.

I also found these tutorials:
http://www.w3schools.com/soap/default.asp (General Soap)
http://devzone.zend.com/25/php-soap-extension/ (Soap + PHP)
http://www.codewalkers.com/c/a/Miscellaneous/Using-SOAP-with-PHP/ (Soap + PHP)

Please feel free to say it…you can call me an idiot. You are completely right. I’ve messed with SOAP before and I have no idea why I didn’t put one and one together and come up with two. Hopefully next week I’ll get authorization to start running tests and hopefully I won’t have to post again :slight_smile:

Thank you so much.

Sponsor our Newsletter | Privacy Policy | Terms of Service