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

Can’t consume SAP web service with ColdFusion

Community Beginner ,
May 01, 2008 May 01, 2008

Copy link to clipboard

Copied

I have been unable to connect to an SAP web service. None of the discussions on the web seem to touch on my problem. This web service doesn’t work like the simple web service examples that are posted all over the web.

When I use the Dreamweaver proxy to write my code, it creates three cfinvokearguments instead of the two I should need. And the return variable that is created by the proxy returns a structure that doesn’t include any methods that allow me to access any of the data.

Can anyone look at the following code from the SAP WSDL and explain to me how to consume the service?

Here is the code that the Dreamweaver proxy creates…

<cfinvoke
webservice=" http://sapwddev/sap/bc/srt/rfc/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>

Here is a portion of the WSDL…

- <xsd:complexType name="ZSVC_HRSTRUC">
- <xsd:sequence>
<xsd:element name="PERNR" type="tns:numeric8" />
<xsd:element name="VORNA" type="tns:char25" />
<xsd:element name="INITS" type="tns:char10" />
<xsd:element name="NACHN" type="tns:char25" />
<xsd:element name="LOCAT" type="tns:char40" />
<xsd:element name="STRAS" type="tns:char60" />
<xsd:element name="ORTO1" type="tns:char40" />
<xsd:element name="ORTO2" type="tns:char40" />
<xsd:element name="PSTLZ" type="tns:char10" />
<xsd:element name="LAND1" type="tns:char3" />
<xsd:element name="TELNR" type="tns:char14" />
<xsd:element name="COM01" type="tns:char4" />
<xsd:element name="NUM01" type="tns:char20" />
<xsd:element name="EMAIL" type="tns:char40" />
<xsd:element name="TITLE" type="tns:char40" />
<xsd:element name="ORGEH" type="tns:char40" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="BAPIRETURN">
- <xsd:sequence>
<xsd:element name="TYPE" type="tns:char1" />
<xsd:element name="CODE" type="tns:char5" />
<xsd:element name="MESSAGE" type="tns:char220" />
<xsd:element name="LOG_NO" type="tns:char20" />
<xsd:element name="LOG_MSG_NO" type="tns:numeric6" />
<xsd:element name="MESSAGE_V1" type="tns:char50" />
<xsd:element name="MESSAGE_V2" type="tns:char50" />
<xsd:element name="MESSAGE_V3" type="tns:char50" />
<xsd:element name="MESSAGE_V4" type="tns:char50" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="TABLE_OF_ZSVC_HRSTRUC">
- <xsd:sequence>
<xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="tns:ZSVC_HRSTRUC" />
</xsd:sequence>
</xsd:complexType>
- <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>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="ZSVC_EMPLOYEE_DATA">
<wsdl:part name="parameters" element="tns:ZSVC_EMPLOYEE_DATA" />
</wsdl:message>
- <wsdl:message name="ZSVC_EMPLOYEE_DATAResponse">
<wsdl:part name="parameters" element="tns:ZSVC_EMPLOYEE_DATAResponse" />
</wsdl:message>
- <wsdl:portType name="zsvc_employee_data">
- <wsdl:operation name="ZSVC_EMPLOYEE_DATA">
<wsdl:input message="tns:ZSVC_EMPLOYEE_DATA" />
<wsdl:output message="tns:ZSVC_EMPLOYEE_DATAResponse" />
</wsdl:operation>
</wsdl:portType>

Thanks for any help that anyone can provide.
Brian
TOPICS
Advanced techniques

Views

1.2K

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

Community Beginner , May 02, 2008 May 02, 2008
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 an...

Votes

Translate

Translate
Community Beginner ,
May 02, 2008 May 02, 2008

Copy link to clipboard

Copied

LATEST
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_...
Handling complex data types
http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFu...
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

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