I've been a cf developer for 11 years, but embarrassed to say that I've done nothing substantial with webservices.
How to I form a cfhttp call to consume the following webservice API provided by the vendor?
Soap 1.2 Request:
POST /Portal/internet.asmx HTTP/1.1
Host: 192.168.222.240
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Usage xmlns="http://portal/internet.asmx">
<SessionID>string</SessionID>
<CustomerCode>int</CustomerCode>
<FullUserName>string</FullUserName>
<StartDate>dateTime</StartDate>
<EndDate>dateTime</EndDate>
</Usage>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
Soap 1.2 Response:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UsageResponse xmlns="http://portal/internet.asmx">
<UsageResult>
<xsd:schema>schema</xsd:schema>xml</UsageResult>
</UsageResponse>
</soap12:Body>
</soap12:Envelope>
I want to do it manually at the moment (I know about cfinvoke and createobject). I came up with the following from a Ben Nadel blog, but I get a "connection failure" error. I guess I just need someone to check for obvious flaws in the code before I look at whether it is genuinely connection/authorisation related.
<cfsavecontent variable="soapBody">
<cfoutput>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Usage xmlns="http://portal/internet.asmx">
<SessionID>F7B3B3FB-DE35-45CB-A785-8229E91FAEC9</SessionID>
<CustomerCode>1112221</CustomerCode>
<FullUserName>MR DAVE GEORGE</FullUserName>
<StartDate>2010-01-01</StartDate>
<EndDate>2009-01-01</EndDate>
</Usage>
</soap:Body>
</soap:Envelope>
</cfoutput>
</cfsavecontent>
<cfhttp
url="http://portal/internet.asmx"
method="post"
result="httpResponse">
<cfhttpparam
type="header"
name="SOAPAction"
value="http://portal/internet.asmx/Usage"
/>
<cfhttpparam
type="header"
name="accept-encoding"
value="no-compression"
/>
<cfhttpparam
type="xml"
value="#trim( soapBody )#"
/>
</cfhttp>
<cfoutput>
#httpResponse.fileContent# <!--- ouputs "connection failure" --->
</cfoutput>
Many thanks, Paul