Copy link to clipboard
Copied
I am working with a company named Exigo. They have posted their webservices API publicly at http://api.exigo.com/3.0/ since you need proper credentials (which I have, of course) in order to actually use it.
If you go there, let's say to the GetCustomers area (http://api.exigo.com/3.0/ExigoApi.asmx?op=GetCustomers) you will see that they give multiple methods for using their web services. I know that my credentials and test works because I can manually do their CSV method.
I cannot get ColdFusion to work with a CFINVOKE command, however:
<CFINVOKE webservice="http://api.exigo.com/3.0/ExigoApi.asmx?WSDL" username="yourLoginName" password="yourPassword"
company="yourCompany" method="GetCustomers" CustomerID="123" returnvariable="adzCustInfo" />
I get the message "Web service operation GetCustomers with parameters {COMPANY={yourCompany},CUSTOMERID={123}} cannot be found." even though I have tested and know that it does exist (of course I am using real values, not the example ones shown here).
Now, the main IT guy told me that I need to reference this:
//Create Main API Context Object
ExigoApi api = new ExigoApi();
//Create Authentication Header
ApiAuthentication auth = new ApiAuthentication();
auth.setLoginName("yourLoginName");
auth.setPassword("yourPassword");
auth.setCompany("yourCompany");
api.setApiAuthenticationValue(auth);
every time I call their service.
How do I do this? How do I get the credentials so that I can call the service? 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.
Any help would be most appreciated.
Thank youi!
RLS
Message was edited by: RLS
Copy link to clipboard
Copied
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.
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6c84.html
http://stackoverflow.com/questions/168798/how-do-i-create-a-cold-fusion-web-service-client-that-uses-ws-security
http://www.coldfusionjedi.com/index.cfm/2009/6/4/Working-with-XML-in-ColdFusion--Struct-versus-XML-functions
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.
http://kb2.adobe.com/cps/039/eaf0396.html
Copy link to clipboard
Copied
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.
http://www.bennadel.com/blog/1809-Making-SOAP-Web-Service-Requests-With-ColdFusion-And-CFHTTP.htm
RLS
Copy link to clipboard
Copied
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/">
<soap:Header>
<AuthenticationHeader xmlns="http://www.some_namespace.com/">
<UserName>string</UserName>
<Password>string</Password>
</AuthenticationHeader>
</soap:Header>
<soap:Body>
<HelloWorld xmlns="http://www.some_namespace.com/">
<Foo>string</Foo>
</HelloWorld>
</soap:Body>
</soap:Envelope>
You can consume this web service by doing the following:
1) Build the AuthenticationHeader XML string:
<cfsavecontent variable="sAuthHeaderXML">
<AuthenticationHeader xmlns=http://www.some_namespace.com/>
<UserName>my_username</UserName>
<Password>my_password</Password>
</AuthenticationHeader>
</cfsavecontent>
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.