Copy link to clipboard
Copied
Greetings,
I have been stuck trying to get CF 8 to talk to SAP serviced Web
Service. Here is code I am using:
<cfscript>
ws = CreateObject("webservice", "http://xxx.xxxxx.com:8002/sap/bc/
srt/rfc/sap/Z_ZRFC_TEST?sap-client=235&wsdl=1.1");
xlatstring = ws.ZZrfcTest(Rfcin = "Hello");
</cfscript>
Here is WSDL file
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions targetNamespace="urn:sap-
com:document:sap:soap:functions:mc-style" xmlns:wsdl="http://
schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/
XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://
schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-
com:document:sap:soap:functions:mc-style" xmlns:n1="urn:sap-
com:document:sap:rfc:functions">
- <wsdl:documentation>
<sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl" />
</wsdl:documentation>
- <wsdl:types>
- <xsd:schema attributeFormDefault="qualified"
targetNamespace="urn:sap-com:document:sap:rfc:functions">
- <xsd:simpleType name="char10">
- <xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
- <xsd:schema attributeFormDefault="qualified"
targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style"
xmlns:n0="urn:sap-com:document:sap:rfc:functions">
<xsd:import namespace="urn:sap-com:document:sap:rfc:functions" />
- <xsd:element name="ZZrfcTest">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element name="Rfcin" type="n0:char10" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="ZZrfcTestResponse">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element name="Rfcout" type="n0:char10" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="ZZrfcTest">
<wsdl:part name="parameters" element="tns:ZZrfcTest" />
</wsdl:message>
- <wsdl:message name="ZZrfcTestResponse">
<wsdl:part name="parameter" element="tns:ZZrfcTestResponse" />
</wsdl:message>
- <wsdl:portType name="Z_ZRFC_TEST">
- <wsdl:operation name="ZZrfcTest">
<wsdl:input message="tns:ZZrfcTest" />
<wsdl:output message="tns:ZZrfcTestResponse" />
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
here is error message I am getting
The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.
Unable to read WSDL from URL:
http://xxxx.xxxxxxx.com:8002/sap/bc/srt/rfc/sap/Z_ZRFC_TEST?sap-client=235&wsdl=1.1
Please advice what to check...
Regards,
Egils
Copy link to clipboard
Copied
Can you retrieve the WSDL using your browser from the same machine (i.e. your Coldfusion 8 box)?
If not, that it might be a connection problem between the servers.
If you can view the WSDL using a browser from the same machine, then try saving the WSDL to a local file and pointing your webservice object instantiation to the local file. Not a great solution - but it should give you an idea on whether or not there is a networking issue or a file format issue with accessing the WSDL.
Hope that helps
- Michael
Copy link to clipboard
Copied
I can read WSDL file from CF 8 server and any other computer on my companies network. It does require that I submit usercode and passward which I did when reading WSDL via web-browser. Furthermore SAB Basis admin and I conducted few tests to see if SAP receives any communication request from CF and it does.
I checked code since initial testing to use CFINVOKE
<cfinvoke
webservice="http://xxx.xxxxxxx.com:8006/sap/bc/srt/rfc/sap/Z_PO_GETDETAIL1?sap-client=330&wsdl=1.1"
method="BAPI_PO_GETDETAIL1"
refreshWSDL="yes"
username="xxxxxxx"
password="xxxxxxx"
returnvariable="aReturn"
>
For testing purposes every call refreshes WSDL and SAP Basis admin could see WSDL request and WSDL returned back by SAP WebService. However we did not see BAPI call initiated from CF
I have never heard of saving and using WSDL file locally. Could you provide more info how it could be done and how it could help with testing WebService interfaces? Idea of the WebService call CF makes is that SAP will return something back
Copy link to clipboard
Copied
Are you certain that the username/password attributes in the cfinvoke tag are the same as the usercode/password fields that you have to enter to view the WSDL via a browser? Perhaps the web service call is being stopped at the login screen which is why CF doesn't see a WSDL file at that location. When you said that you performed some tests with the admin, did that include consuming a simple web service using CF?
Since the WSDL file just contains a standardized description of the web service methods and data types available to use, it doesn't neccessarily have to reside on the remote web server in order for CF to consume it. Many WSDL files include a server port element which points back to the remote server - in that case you can download the file as a .wsdl file and point your CF invoke statement to this new file. For the instances like this where the WSDL xml actually has an element with the URL of your remote server, you can consume the remote web service this way using the local WSDL.
<cfinvoke
webservice="http://mycf8server/path/to/file/myfile.wsdl
...
>
That being said, its not a great idea to do it this way. For one, you'd have to set up a system to automatically download and update the local WSDL file on your CF server otherwise it would quickly become outdated and stop working. For testing purposes, though, saving the wsdl file locally and calling it from coldfusion should give you an idea whether the issue is the WSDL/XML content or an issue with the data transmission between the CF server and the SAP server.
Copy link to clipboard
Copied
I am pretty sure that the CF call gets back WSDL file from SAP - SAB Basis admin and I both could see post request for WSDL comming from CF and WSDL file returned back from SAP via SAP trace file.
I am positive that usercode and password is not an issue - during one of the tests I intentionally supplied invalid password in CF code and I got unauthorized error.
I tried approach when I downloaded WSDL file to CF server and changed references in the code - that worked. Your explanation make sense regarding ports. I agree that it is not desired way to do it long term but at least it can be tested this way.
Is there a way to record XML code generated by CF when CF make web-service call? I am getting suspicion that it's how I am passing parameters to web-service. I found references in other posts that everything worked fine once programmer figured out how to pass complex parameters to SAP Web Service
Copy link to clipboard
Copied
Complex data types can be real trouble for CF web service developers. Though usually the error it generates is something along the lines of:
Web service method with parameters(...) cannot be found
The fact that your error message mentioned the WSDL file made me think that it was a communication issue between the CF server and the SAP server. So far the best method I've found for modeling complex objects for web service invocations is to create an object via an XML-text-parsing operation in then passing the resulting complex object to the web service:
Say you have a WS who takes a custom complex object called "person", which has attributes "fname" and "lname":
1) Store xml text that models the object structure in a cf variable*
<cfsavecontent variable="sXML">
<person>
<fname>Joe</fnam>
<lname>Smith</lname>
</person>
</cfsavecontent>
* not sure if you want to use XML children or attributes here. might need to play around with this one
2) Parse the XML into another CF variable
<cfset xmlObj = XMLParse(sXML)>
3) Pass the xmlObj variable as the input value for your web service invocation variable.
4) Celebrate
I've had to play around with a number of different techniques in getting complex objects working in web services over the years, so there are a bunch of options out there - from simply passing a CF structure to using java to create a custom input class to creating custom web service stubs. In every case, though, the error message for getting it wrong always seems to be about not being able to find/match up the web service method with the method definitions in the WSDL and nothing to do with being able to access the WSDL file itself.
Copy link to clipboard
Copied
insuractive wrote:
Complex data types can be real trouble for CF web service developers.
I ran across this article the other day. As much as I dislike the source it looks very interesting. I have not had a chance to try any of this yet so I would love to hear how it goes if anybody gives it a try.
Consuming Complex Web Services with ColdFusion
http://coldfusion.sys-con.com/node/86131
Copy link to clipboard
Copied
I should have updated that I am no longer get initial error message that WSDL cannot be accessed. New error message is following:
"Web service method with parameters(...) cannot be found"
Which is leads me to think that it is an issue with passing complex parameters. This issue does have a feel that once I get it working I will be celebrating...
Copy link to clipboard
Copied
Ah, that does sound like a complex parameters issue. I've actually used the WSDL2Java tool that Ian suggested, which does work but requires a number of steps. If your complex parameter is not too crazy, I would recommend trying the CF structure or XML-to-object solution. Otherwise, creating the java object from the WSDL would probably be the way to go.
Copy link to clipboard
Copied
I am still strugling even with parsed XML attribute however I am not ready investigating WSDL2Java yet...
Here is how parameters are described in WSDL
Copy link to clipboard
Copied
My guess is that it's either the custom data types or the namespace that are what's tripping you up. Not sure what to do about the data typing aside from the WSDL2Java thing. You can try adding a namespace to the XML:
<BAPI_PO_GETDETAIL1 xmlns="http://use/tns/namespace/here">
<ACCOUNT_ASSIGNMENT />
...
</BAPI_PO_GETDETAIL1>
Copy link to clipboard
Copied
Tried that but it did not work. Since I tried to figure out WSDL2JAVA. I got java classes created. I installed Exclipse but that's where it became too complex for me since I have zero to non java experience at this point.
I run into following article and decided to try it out to run into new issue.
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_19352
When I tried executing sniffer. I got following errors:
ERROR: transport error 202: bind failed: address already in use. ERROR: JDWP Transport td_socked failed to initialize...
I did not find any references in google search regarding error messages listed. Ether way - if sniffer was working it would probably give me some idea what SOAP messages my CF code is sending. I will open new log for sniffer.exe problems I am running into but I just wanted to let anyone who was following this thread to know about sniffer.exe if you did not know about it already.
Copy link to clipboard
Copied
I gave up for now after almost two weeks of trying CFINVOKE and CFOBJECT.
I tried using CFHTTP and it worked. Sure it seems like step backwards but - hey, it works!!!
I might try using CFINVOKE and CFOBJECT later on but for now I have to deliver something that is functional.
Thank you for your suggestions. It was great learning experience.