• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Consuming an ASP web service which responds with complex data types...

Guest
Sep 01, 2009 Sep 01, 2009

Copy link to clipboard

Copied

Here's my problem - I'm trying to consume a web service from a provider that uses complex data types.

The starting part of the WSDL looks like this (I've not included the whole thing) - named have been changed to protect the innocent:

<wsdl:definitions targetNamespace="http://domain_name">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://domain_name">
<s:element name="Authentication">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Token"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AuthenticateResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="AuthOK" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="Token"/>
</s:sequence>
</s:complexType>
</s:element>

Since it's a complexType return, with a sequence, I'd expect an array or structure returned, but instead I just get the "AuthOK" value, and no way to get anything else.

Here are the ways I've tried calling it:

<cfscript>

    WS = createObject("webservice", "https://WSDL_URL");

    WS_ret = WS.Authentication(Username = "username", Password = "password", Token = "");

</cfscript>

<cfdump var="#WS_ret#" />

<cfinvoke webservice="WSDL_URL" method="Authentication" returnVariable="WS_ret">

    <cfinvokeargument name="userID" value="7253320" />
    <cfinvokeargument name="password" value="ctpjxs3" />
    <cfinvokeargument name="SecurityToken" value="" />

</cfinvoke>

<cfdump var="#WS_ret#" />

Any ideas how I can get the other variables in the sequence? I have other calls after this that have a much larger amount of variables, and as such I can't use it without being about to get more of the

TOPICS
Advanced techniques

Views

916

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Sep 02, 2009 Sep 02, 2009

You might try using the GetSOAPResponse function to examine the XML you are receiving.

"GetSOAPResponse"

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_e-g_59.html#5054378

"Troubleshooting SOAP requests and responses"

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=webservices_27.html#1222070

As for the docs issue I suspect poor editing is at fault. I suspect that the web service is assumed to have an echoStruct method but this is not clearly stated.

Votes

Translate

Translate
Guest
Sep 01, 2009 Sep 01, 2009

Copy link to clipboard

Copied

Damn stupid thing cut off the end of my last paragraph...

Any ideas how I can get the other variables in the sequence? I have other calls after this that have a much larger amount of variables, and as such I can't use it without being about to get the other sequence entries.

Thanks in advance to anyone who can point me in the right direction...

BTW, please don't point me to the useless docs page, which is blatantly incorrect:

    ws = createObject("webservice", "http://somehost/echosimple.asmx?wsdl");
    myReturnVar = ws.echoStruct(stUser);

Saying to call "echoStruct" when trying to call the updateEmployeeInfo method? how the hell does that work???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 02, 2009 Sep 02, 2009

Copy link to clipboard

Copied

Questions / Things to Check:

Can you post a dump of the WS_ret object ( I'm guessing this will be a struct) returned from the service?

Bear in mind that the definition Token element of AuthenticateResponse specifies that Token is optional.  Are you certain that you should be receiving this optional data?

I regards to the sample code you refer to:
ws = createObject("webservice", "http://somehost/echosimple.asmx?wsdl");
myReturnVar = ws.echoStruct(stUser);

The 'ws' variable is a reference to a web service object.  The 'ws.echoStruct' code is invoking the echoStruct method of the webservice and assigning the returned data to a CF variable 'myReturnVar'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 02, 2009 Sep 02, 2009

Copy link to clipboard

Copied

Thanks for the reply.

If I CFDUMP the variable it returns just "1", no XML tags, nothing at all around the data - according to the web service providers they say that they are supplying the Token part as long as the first variable is "1" (a logical true if the authentication passed). If it is "0" then no Token is returned, that is why it's optional.

As for the CFdocs issue, look here:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=webservices_25.html

The paragraph before it (about 2/3 down the page) states:

In this example, the operation updateEmployeeInfo takes a complex type as input and returns a complex type as output. To handle the input parameter, you create a structure. To handle the returned value, you write it to a ColdFusion variable, as the following example shows:

It even states that you call "updateEmployeeInfo", and nowhere mentions "echoStruct" as a method - it's seemingly been put in as a random method name, or a function call for something else. The WSDL above the example only mentions "updateEmployeeInfo" and "updateEmployeeInfoSoapOut", again not mentioning "echoStruct".

I see this as an error in the docs as it's calling a non-existant entity in the WSDL, which should cause a run-time error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 02, 2009 Sep 02, 2009

Copy link to clipboard

Copied

You might try using the GetSOAPResponse function to examine the XML you are receiving.

"GetSOAPResponse"

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_e-g_59.html#5054378

"Troubleshooting SOAP requests and responses"

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=webservices_27.html#1222070

As for the docs issue I suspect poor editing is at fault. I suspect that the web service is assumed to have an echoStruct method but this is not clearly stated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 03, 2009 Sep 03, 2009

Copy link to clipboard

Copied

LATEST

You are a life-saver - getSOAPresponse() had always returned the same as the standard method call for straight XML web services, so I didn't even think about it.

Thanks,

Phil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation