Skip to main content
Inspiring
October 9, 2011
Answered

web service return value

  • October 9, 2011
  • 2 replies
  • 1255 views

I have a web service and I'm cfdumping the return variable, but I don't know how to get the value out.  This is what it is giving me.

1

object of com.nextaxiom.www.soapservice.xsd1.APApprovalList
Class Namecom.nextaxiom.www.soapservice.xsd1.APApprovalList
Methods
MethodReturn Type
equals(java.lang.Object)boolean
getAlertDate()java.lang.String
getDescription()java.lang.String
getDeserializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName)org.apache.axis.encoding.Deserializer
getInvoiceAmount()java.lang.Double
getPaymentReferenceNumber()java.lang.String
getSerializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName)org.apache.axis.encoding.Serializer
getTypeDesc()org.apache.axis.description.TypeDesc
getUserName()java.lang.String
getVendorName()java.lang.String
hashCode()int
setAlertDate(java.lang.String)void
setDescription(java.lang.String)void
setInvoiceAmount(java.lang.Double)void
setPaymentReferenceNumber(java.lang.String)void
setUserName(java.lang.String)void
setVendorName(java.lang.String)void

So some of this is the fields I want, but I want the value: description, alert date, invoice amt, etc.  Can anyone help me.  What do I need to do next to get the values?

Here is my CF statement and the WSDL file.

thanks for the help,

BJ

Invoke statement

            <cfinvoke

                                         webservice="http://127.0.0.1:8500/APApproval/GetAPApprovalList.wsdl"

                                         method="GetAPApprovalList" refreshwsdl="true"

                                         returnvariable="response">

                                                  <cfinvokeargument name="UserName" value="DAVBRY"/>

                              </cfinvoke>

            <cfoutput>#response#</cfoutput>

WSDL FILE

<?xml version="1.0"?>

<!--Automatically generated 10/07/2011 by Hyperservice Business Platform, NextAxiom Technology, Inc.-->

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"

    name="BSAPrototype.APApproval.GetAPApprovalList"

    targetNamespace="http://www.nextaxiom.com/soapservice/BSAPrototype.APApproval.GetAPApprovalList/wsdl"

    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

    xmlns:tns="http://www.nextaxiom.com/soapservice/BSAPrototype.APApproval.GetAPApprovalList/wsdl"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://www.nextaxiom.com/soapservice/xsd1">

    <types>

        <schema xmlns="http://www.w3.org/2001/XMLSchema"

            elementFormDefault="qualified" targetNamespace="http://www.nextaxiom.com/soapservice/xsd1">

            <element name="GetAPApprovalList">

                <complexType>

                    <sequence>

                        <element name="UserName" type="string"/>

                    </sequence>

                </complexType>

            </element>

            <element name="GetAPApprovalListResult">

                <complexType>

                    <sequence>

                        <element maxOccurs="unbounded"

                            name="APApprovalList" type="xsd1:APApprovalList"/>

                    </sequence>

                </complexType>

            </element>

            <complexType name="APApprovalList">

                <sequence>

                    <element minOccurs="0" name="UserName" type="string"/>

                    <element minOccurs="0" name="AlertDate" type="string"/>

                    <element minOccurs="0" name="Description" type="string"/>

                    <element minOccurs="0" name="PaymentReferenceNumber" type="string"/>

                    <element minOccurs="0" name="InvoiceAmount" type="double"/>

                    <element minOccurs="0" name="VendorName" type="string"/>

                </sequence>

            </complexType>

        </schema>

    </types>

    <message name="GetAPApprovalListRequest">

        <part element="xsd1:GetAPApprovalList" name="GetAPApprovalList"/>

    </message>

    <message name="GetAPApprovalListResponse">

        <part element="xsd1:GetAPApprovalListResult" name="GetAPApprovalListResult"/>

    </message>

    <portType name="BSAPrototype.APApproval.GetAPApprovalListSoapPort">

        <operation name="GetAPApprovalList">

            <input message="tns:GetAPApprovalListRequest"/>

            <output message="tns:GetAPApprovalListResponse"/>

        </operation>

    </portType>

    <binding name="BSAPrototype.APApproval.GetAPApprovalListSoapBinding" type="tns:BSAPrototype.APApproval.GetAPApprovalListSoapPort">

        <soap:binding xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

            style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

        <operation name="GetAPApprovalList">

            <soap:operation

                xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:doc?in=GetAPApprovalList?out=GetAPApprovalListResult?path=BSAPrototype.APApproval.GetAPApprovalList"/>

            <input>

                <soap:body use="literal"/>

            </input>

            <output>

                <soap:body use="literal"/>

            </output>

        </operation>

    </binding>

    <service name="BSAPrototype.APApproval.GetAPApprovalList">

        <port

            binding="tns:BSAPrototype.APApproval.GetAPApprovalListSoapBinding" name="BSAPrototype.APApproval.GetAPApprovalListPort">

            <soap:address

                xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="http://nextaxb:7777/NXAServer/NextAxiomServer"/>

        </port>

    </service>

</definitions>

This topic has been closed for replies.
Correct answer BJ_-_CF

sorry, i was cfdump and cfoutput the #response# on and off to see what each would give me.  In my code that I showed, I probably took out the cfdump statement.

I did finally figure this out.  I kept messing with arrays tags to figure out how it was storing the data.  After a bunch of array statements I figure out the structure.

thanks for the reply,

BJ

2 replies

BJ_-_CFAuthorCorrect answer
Inspiring
November 3, 2011

sorry, i was cfdump and cfoutput the #response# on and off to see what each would give me.  In my code that I showed, I probably took out the cfdump statement.

I did finally figure this out.  I kept messing with arrays tags to figure out how it was storing the data.  After a bunch of array statements I figure out the structure.

thanks for the reply,

BJ

Inspiring
November 3, 2011

Getting complex objects back from web service calls are always tricky  - especially when they've been desearialized as an object.  We've found its a lot easier to deal with the Raw SOAP messages so at least we're working with an XML document, rather than a series of Getter functions, any of which that may return a NULL value (which does really unpleasant things to a CF variable).

When you absolutely have to deal with a complex non-CF originating object in CF, we've found that you can actually use the underlying Java classes to identify and automatically execute the getter functions to effective dump out the variables.  We've rolled it up into a custom tag.  The base code for the logic is below:

<cfset objVar = VARIABLE_CONTAINING_OBJECT_FROM_WEB_SERVICE>

<cfset arrMethods = objVar.getClass().getMethods()>

<cfoutput>

<cfif isDefined("arrMethods") AND isArray(arrMethods) AND ArrayLen(arrMethods) gt 0>

<table border="1" cellspacing="0" cellpadding="5" style="border-collapse:collapse;border:1px solid black;">

<tr>

<td colspan="3" style="background-color:##CCCCCC;">RESULT</td>

</tr>

<tr>

<td>Method</td>

<td>Class</td>

<td>Return Value</td>

</tr>

<cfset sComplexMethods = "">

<cfloop from="1" to="#ArrayLen(arrMethods)#" index="iMethod">

<cfset sReturnType = arrMethods[iMethod].getReturnType().toString()>

<cfif ListFindNoCase("int,java.lang.String,class java.lang.String,double,float,char", sReturnType)>

<tr>

<td>#arrMethods[iMethod].getName()#</td>

<td>#sReturnType#</td>

<cfset sReturnValue = EVALUATE("objVar." & arrMethods[iMethod].getName() & "()")>

<td><cfif isDefined("sReturnValue") AND sReturnValue neq "">#sReturnValue#<cfelse> </cfif></td>

</tr>

</cfif>

#sComplexMethods#

</cfloop>

</table>

</cfif>

</cfoutput>


BKBK
Community Expert
Community Expert
November 3, 2011

BJ - CF wrote:

I have a web service and I'm cfdumping the return variable, but I don't know how to get the value out.  This is what it is giving me.

Not quite. You say cfdump, but your code says cfoutput. What is the output?