1 person found this helpful
Disclaimer: I haven't need to use SOAP header for web services in a production system, but I'm interested in how you deal with this problem as I may be facing a similar situation in the future. Please post any follow up questions or solutions to the forum.
In regards to: It seems to me the "new ExigoApi()" is going to be looking for a local reference, but this system is located on a remote server, so I'm not sure how to do that.
The new ExigoApi() is a reference to a local object that acts a proxy for invoking the web service. Whe you reference a web service in ColdFusion, Java classes are automatically created to act as a proxy. The code sample you were given is probably for the Java that would work with proxy objects.
Things to try, I've included some links you *might* find useful.
1. Remove the username and password from your CFINVOKE tag. Those attributes are only relavent to services secured with basic authentication.
2. To set a SOAP header value use the AddSOAPRequestHeader function. I expect this is how the username and password is handled by the service.
3. It may be useful to use Java to invoke the service or look at the Java proxies to see what objects the service requires.
Thank you for your comments and suggestions.
What did it for me was applying the principles presented in a nice, simple blog by Ben Nadel.
One of the solutions we've encountered is to use XML/XMLParse to fake the authorization header entity and adding it to the web service call using the addSOAPRequestHeader() method:
Say, for instance, you were trying to parse a web service that required an authorization header. Assume that the documentation for the method you are ineterested in looks something like this:
<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/">
You can consume this web service by doing the following:
1) Build the AuthenticationHeader XML string:
2) Parse the XML into a CF object:
<cfset objAuthHeader = xmlParse(sAuthHeaderXML)>
3) Instantiate your web service object:
// Create web service object
objWS = CreateObject("webservice", "http://www,some_namespace.com/wsTest.asmx?WSDL");
4) Add your authentication object to your web service request header
// Add authentication header to web service call
addSOAPRequestHeader(objWS, "http://www,some_namespace.com", "AuthenticationHeader", objAuthHeader);
5) Call your remote web service method:
sResponse = objWS.HelloWorld("test");
Be sure to use the correct namespace when generating web service content (especially when dealing with web services built in .NET)
Anyway, it sounds like you've already come up with a good solution for this. I just thought I would add this into the thread in case someone else comes across it later on.