I'd like to hit the list up again on this subject if I could. Ezra helped me
immensley, but I'm still having trouble.
First, just so Ezra knows, this authHeader business you gave me worked just
fine. I'm authenticating and am able to call methods.
.... BUT, it's not working like I expected -- or even like the getIPAddress()
example earlier in this thread. I take for my example another relatively
simple method call: getYears(). This method takes exactly one argument: a
string representing the CountryCode (U = United States, C = Canada, B =
Both).
Now the C# example shows something like:
ws.getYears("U")
Wouldn't it be lovely if that's all *I* had to do, too? But no. When I look
up the Years element in the WSDL I find:
<s:element name="Years">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="sCountryCode"
type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
It's a complex type. Well, thanks to Ezra I know that this means a CF
structure. So I create a structure with a member called 'sCountryCode' and I
set it to "U". So my code becomes:
<cfscript>
wsurl = "https://www.blackbookws.com/UsedCarWS.asmx?WSDL";
portname = "UsedCarWS1";
portname = "UsedCarWS";
ws = CreateObject("webservice", wsurl, portname);
authHeader = xmlNew();
authHeader.UserCredentials = xmlElemNew(authHeader,"
http://localhost/webservices/UsedCarWS", "UserCredentials");
// authHeader stuff here... ommitted for space...
args = structNew();
args.sCountryCode = "U";
response = ws.getYears(args);
</cfscript>
<cfdump var="#response#">
So, response is now an object of type
localhost.webservices.UsedCarWS.YearsResponse that contains several
functions. Just like in the getIPAddress() example there was a method that
required no arguments that allowed me to get the returned data. In this case
it's called getYearsResult().
Here comes the problem. When I run getYearsResult(), instead of getting back
some sort of data structure with all of the available years in it, I get
another object with methods like:
equals(java.lang.Object)
getDeserializer(java.lang.String, java.lang.Class,
javax.xml.namespace.QName)
getSerializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName)
getTypeDesc()
get_any()
hashCode()
set_any(org.apache.axis.message.MessageElement[])
This confuses me even more. I have verified with the web service provider
that I am authenticting correctly and that the function is getting called. I
can't tell what data is coming back, but it is running and wouldn't do so if
I didn't authenticate correctly, so that's not the issue.
Any ideas what I'm doing wrong (other than trying to consume a SOAP based
web service)? This is obviously much, much easier in a .NET environment.
Thanks,
Chris
On Sat, Jan 24, 2009 at 12:50 PM, Ezra Parker <[email protected]> wrote:
> You're welcome, I'm glad that helped. As far as authentication goes,
> it looks like this needs to be submitted as a SOAP header. I'm not too
> familiar with that aspect of web services, but here is my stab at it:
>
> <cfscript>
> wsurl = "https://www.blackbookws.com/UsedCarWS.asmx?WSDL";
> portname = "UsedCarWS";
> ws = CreateObject("webservice", wsurl, portname);
>
> authHeader = xmlNew();
> authHeader.UserCredentials = xmlElemNew(authHeader,
> "http://localhost/webservices/UsedCarWS", "UserCredentials");
>
> authHeader.UserCredentials.userid = xmlElemNew(authHeader, "userid");
> authHeader.UserCredentials.userid.xmlText = "userid"; //plug in
> your userid value here
>
> authHeader.UserCredentials.password = xmlElemNew(authHeader, "password");
> authHeader.UserCredentials.password.xmlText = "password"; //plug in
> your password value here
>
> authHeader.UserCredentials.company = xmlElemNew(authHeader, "company");
> authHeader.UserCredentials.company.xmlText = "company"; //plug in
> your company value here
>
> authHeader.UserCredentials.producttype = xmlElemNew(authHeader,
> "producttype");
> authHeader.UserCredentials.producttype.xmlText = "producttype";
> //plug in your producttype value here
>
> authHeader.UserCredentials.returncode = xmlElemNew(authHeader,
> "returncode");
> authHeader.UserCredentials.returncode.xmlText = "0"; //this needs
> to be an integer
>
> authHeader.UserCredentials.returnmessage = xmlElemNew(authHeader,
> "returnmessage");
> authHeader.UserCredentials.returnmessage.xmlText = "returnmessage";
> //can this be an empty string?
>
> addSOAPRequestHeader(ws, "ignored", "ignored", authHeader);
> body = structNew();
>
> response = ws.getAllStates(body);
> </cfscript>
>
> <cfdump var="#response#">
>
> I'm creating the header as an XML document (there may be a less
> verbose way of dealing with this -- if so, I'd love to hear it), and
> using the namespace indicated in the examples listed here:
>
> https://www.blackbookws.com/UsedCarWS.asmx?op=AllStates
>
> You will need to plug in the correct values for userid, password,
> etc., of course. I cannot tell if this works, as I obviously do not
> have the authentication credentials, but it does not thrown an error,
> and returns what appears to be a valid response (without any data).
>
> I'd be curious to hear if this actually works or not...
>
> --
> Ezra Parker
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:318566
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4