Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

Problems consuming SOAP API that uses preemptive authentication

$
0
0

I am attempting to communicate with a SOAP API that uses preemptive authentication and have run into some problems getting the API to provide appropriate responses.  The API has several different functions, but for testing purposes, I am only interested in one; ping.

 

I have attempted to interface with this API using createObject, cfinvoke, and cfhttp.  None of the methods available seem to be working, createObject and cfinvoke return the same error, and cfhttp returns something different.  For now, I just want to focus on cfhttp since I've been able to progress further here than with createObject/cfinvoke.

 

For purposes of comparison, I have set up SOAP UI to communicate with this API and after a lot of trial and error, I was finally able to get SOAP UI to return appropriate XML when calling the ping function.  I have attempted to copy the header information SOAP UI presents into my cfhttp call but instead of getting a ping response, I get a 500 bad request error.

 

The SOAP UI call that returns appropriate responses looks like this (information redacted due to corporate and vendor privacy policies):

 

POST https://[REDACTED] HTTP/1.1

Accept-Encoding: gzip,deflate

Content-Type: text/xml;charset=UTF-8

SOAPAction: "https://[REDACTED]/ping"

Authorization: Basic [REDACTED]

Content-Length: 237

Host: [REDACTED]

Connection: Keep-Alive

User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="https://[REDACTED]">

   <soapenv:Header/>

   <soapenv:Body>

      <con:ping/>

   </soapenv:Body>

</soapenv:Envelope>

 

The code I have written to mimic this call looks like this:

 

<cfsavecontent variable="soapRequest">

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="https://[REDACTED]">

        <soapenv:Header/>

        <soapenv:Body>

            <con:ping/>

        </soapenv:Body>

    </soapenv:Envelope>

</cfsavecontent>

 

<!--- Send SOAP request to the Web Service --->

<cfhttp url="https://[REDACTED]" username="[REDACTED]" password="[REDACTED]" method="post" result="httpResponse" timeout="300">

    <cfhttpparam type="header" name="SOAPAction" value="https://[REDACTED]/ping" />

    <cfhttpparam type="header" name="accept-encoding" value="no-compression" />

    <cfhttpparam type="header" name="Authorization" value="Basic [REDACTED]" />

    <cfhttpparam type="header" name="MIME-Version" value="1.0" />

    <cfhttpparam type="header" name="content-type" value="text/xml" />

    <cfhttpparam type="header" name="content-length" value="#Len(Trim(soapRequest))#" />

    <cfhttpparam type="xml" value="#trim(soapRequest)#" />

</cfhttp>

 

At this point, I'm grasping at straws.  I don't know enough about SOAP to know whether this is a problem on my end, a compatibility issue of some sort, or a problem on the vendor's end.  The vendor's support for this problem has been virtually useless; I would change vendors for this service, but I can't make that decision. 

 

A couple of quick notes relating to specific things in my version of the code:

  • I am not setting a header value for MIME type because according to this article from Ben Nadel, setting the XML cfhttpparam should pass an appropriate mimetype for me.  I have tried it previously however, removing the XML line and replacing it with <cfoutput>#soapRequest#</cfoutput>, which did not make a difference.
  • I set accept-encoding to no-compression for the same reason listed above.  I have tried it previously with gzip/deflate however, but it also made no difference.
  • I have tried setting a user agent previously to match the value above, and again, it did not resolve the problem.
  • I have copy/pasted the URL values from the SOAP UI call into my code to ensure they match.

 

Does anybody know of an application I can use that will allow me to actually SEE what ColdFusion and SOAP UI are sending to this API so I can compare the outputted calls?  I've tried to use Fiddler for this, but I can't figure out how to get it to interact with anything other then my browser, which does me no good.

 

If you see anything that appears to be even the simplest overlook, please present it.  I am desparate to resolve this problem.


Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>