First, thank you to Kris Jones and João Fernandes for your help.  Your 
assistance guided me towards my final solution.

I must complete this story for everyone who finds themselves as confused as I 
was.  I am now successful consuming my SAP web services.  There are so many 
pieces that were needed to make it happen; I am shocked that I couldn’t 
explicitly find answers to my problems.  Well here is what I did.

1st Issue – I used Dreamweaver > Application Panel > Web Services > plus-sign 
(+) to create a ColdFusion proxy to the SAP web service.  This is where I was 
first confused.  You see, in Dreamweaver you can drag and drop the web service 
proxy into your code and it creates a cfinvoke tag with associated arguments.  
Well, I knew that my web service only took two arguments, but the proxy created 
three.  Here is what it looked like:

<cfinvoke 
 webservice="http://...sap/ZSVC_EMPLOYEE_DATA?sap-client=090&wsdl=1.1";
 method="ZSVC_EMPLOYEE_DATA"
 returnvariable="aBAPIRETURN">
        <cfinvokeargument name="NACHN" value="enter_value_here"/>
        <cfinvokeargument name="RESULTS" value="enter_value_here"/>
        <cfinvokeargument name="VORNA" value="enter_value_here"/>
</cfinvoke> 

What is “RESULTS”?  Well, I will skip everything I did wrong and tell you 
what it is.  I am not an expert, so please forgive any mistakes in my 
explanation.  If you look at the WSDL for this file, you will notice that there 
is an input element named “results” and there is also an output element 
named “results”.  

- <xsd:element name="ZSVC_EMPLOYEE_DATA">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element name="NACHN" minOccurs="0" type="tns:char25" /> 
  <xsd:element name="RESULTS" type="tns:TABLE_OF_ZSVC_HRSTRUC" /> 
  <xsd:element name="VORNA" minOccurs="0" type="tns:char25" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
- <xsd:element name="ZSVC_EMPLOYEE_DATAResponse">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element name="RESULTS" type="tns:TABLE_OF_ZSVC_HRSTRUC" /> 
  <xsd:element name="RETURN" type="tns:BAPIRETURN" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>


This is called an “inout” variable.  I had never heard of this before.  I 
thought that the only way to get something returned from a webservice was if it 
came to you in the returnvariable.  This is incorrect.  A web service can take 
an inout variable that is passed to it and then write new values to it for use 
on the calling web page.

2nd Issue – Knowing about the existence of “inout” variables wasn’t 
enough.  I had a difficult time learning how to use it.  If you have an inout 
variable, you need to set the value equal to the name of the variable… but 
read carefully here – don’t include the customary pound signs (#) around 
the variable.  Using my example above:

<cfinvokeargument name="RESULTS" value="RESULTS"/>

Let me reiterate that you don’t see any pound signs in the above 
cfinvokeargument.  You will not be able to output your results if you 
mistakenly use pound signs.  Now you can see the results.

<cfdump var="#RESULTS#">

3rd Issue – So once I figured out issues 1 and 2, I was finally able to 
cfdump the results and see the available methods.  In my case, I needed to use 
a method “getItem()”.  So I added another cfdump for the getItem() method.  
This showed me an array, and the first item of the array was a function that 
contained methods for the data I was attempting to access.  I was getting close.

<cfdump var="#RESULTS.getItem()#">

4th Issue - This was not the end of my struggles.  I had to figure out how to 
access the values.  My experiments kept failing.  How can I get the values?  I 
wasn’t comprehending that getItem() was a method to get the “Item” array. 
 And likewise inside the Item array, the methods were similarly written – the 
getEmail() was a method to get the “Email”.  I needed to get rid of the 
“get” to use the data values.  Here is the solution:

<cfdump var="#RESULTS.Item[1].Email#">

Done!

And as a note, I also learned that ColdFusion can consume inout variables, but 
it cannot publish them.

The following links are to some of the web page articles and discussions that 
were critical towards me finally figuring out what to do.

Connecting to a Lotus Notes WebService
http://www.sagewire.org/advanced-cfml-techniques/Connecting-to-Lotus-Notes-WebService-55190.aspx
 

Programming ColdFusion MX: Web Services
http://www.webreference.com/programming/coldfusion/1/5.html

Notes on Interfacing ColdFusion MX to External Web Services Requiring 
Complex-within-Complex XML Documents as Input
http://web.archive.org/web/20070309173903/http://hcc.musc.edu/research/shared_resources/xml_complex_types_to_cf_structure_notes.cfm

Handling complex data types
http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00001554.htm

Axis User's Guide
http://ws.apache.org/axis/java/user-guide.html

Consume NET web service with complex arguments 
http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:52942


>Hi Brian,
>
>we invoke SAP webservices with ColdFusion and we usually use this approach:
>
><cfset params = structnew()>
><cfset params.firstInput = someting>
><cfset params.secondInput = someOtherValue>
><cfset params.returnedTable = structnew()>
><cfset params.anotherTable = structnew()>
>
><cfset ws = createObject( 'webservice' , sapwdsl )>
><cfset ws.someMethod( params )>
>
>-- 
>
>João Fernandes
>
>http://www.onflexwithcf.org
>http://www.riapt.org
>Portugal Adobe User Group (http://aug.riapt.org)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304692
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to