Skip to main content
October 28, 2010
Question

CFinvoke returned error...anyone know why?

  • October 28, 2010
  • 1 reply
  • 1854 views

I am trying to connect to SAP using cfinvoke and I get the error msg below. Anyone know what is the error in my code or setting?

Cannot locate an API in the generated service class that returned the right interface for web service invocation.

Name: http://xxx.xx.com.my:8000/sap/bc/srt/rfc/sap/z_voucher_upload/400/z_voucher_upload?sap-client=400&wsdl=1.1. WSDL: http://xxx.xx.com.my:8000/sap/bc/srt/rfc/sap/z_voucher_upload/400/z_voucher_upload?sap-client=400&wsdl=1.1. It is recommended that you use a web browser to retrieve and examine the requested WSDL document for correctness, including a missing service element.

below is my code : -

<cfinvoke
  webservice="http://xxx.xx.com.my:8000/sap/bc/srt/rfc/sap/z_voucher_upload/400/z_voucher_upload?sap-client=400&wsdl=1.1"
  method="Z_VOUCHER_UPLOAD"
  refreshWSDL="yes"
  returnvariable="aString"
  username = "xxxx"
  password = "xxxxx"
  Lifnr = "30086"
  Sort1 = "A106"
  Bldat = "23082010"
  Budat = "23082010"
  Bktxt = "T03"
  Xblnr = "T04"
  Dmbtr = "55.55"
  Kostl = "8033"
  Hkont = "1234567"
  Zuonr = "45333"
  Xref3 = "CHASSIS99999"
  Xref2 = "ABC1234"
  Xref1 = "850412122121">
   
</cfinvoke>
  
<cfoutput>
#aString#
</cfoutput>

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    October 28, 2010

    Hi Dom_CF,

    it seems that the SAP webservice you're trying to call provides its WSDL-description auto-generated. Have you tried what CF suggests, e.g. "It is recommended that you use a web browser to retrieve and examine the requested WSDL document for correctness, including a missing service element."

    Just call the URL in a browser and have a look at the source of the page (most likely it will just show you an empty/blank page _IN_ the browser, hence the needs to look at the source). Make sure the XML returned is valid (you could test that in Eclipse for instance).

    If all that's fine, the data structure of the parameters you're passing in might be different from what the web service expects. To get help with that you'd need to post the WSDL though.

    Cheers

    Kai

    November 8, 2010
    below is the WSDL file : - I still facing the same problem without knowing the reason. Thanks for helping.
    <?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:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:n1="urn:sap-com:document:sap:rfc:functions">
    - <wsdl:documentation>
    <sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl" />
    </wsdl:documentation>
    <wsp:UsingPolicy wsdl:required="true" />
    - <wsp:Policy wsu:Id="IF_Z_VOUCHER_UPLOAD">
    - <sapsession:Session xmlns:sapsession="http://www.sap.com/webas/630/soap/features/session/">
    <sapsession:enableSession>false</sapsession:enableSession>
    </sapsession:Session>
    </wsp:Policy>
    - <wsp:Policy wsu:Id="OP_ZVoucherUpload">
    <sapblock:enableBlocking xmlns:sapblock="http://www.sap.com/NW05/soap/features/blocking/">true</sapblock:enableBlocking>
    <sapcomhnd:enableCommit xmlns:sapcomhnd="http://www.sap.com/NW05/soap/features/commit/">false</sapcomhnd:enableCommit>
    <saptrhnw05:required xmlns:saptrhnw05="http://www.sap.com/NW05/soap/features/transaction/">no</saptrhnw05:required>
    <saprmnw05:enableWSRM xmlns:saprmnw05="http://www.sap.com/NW05/soap/features/wsrm/">false</saprmnw05:enableWSRM>
    </wsp:Policy>
    - <wsdl:types>
    - <xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
    - <xsd:simpleType name="char1">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="1" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char10">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="10" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char12">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="12" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char16">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="16" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char18">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="18" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char20">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="20" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char220">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="220" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char25">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="25" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char30">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="30" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char32">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="32" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="char50">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="50" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="curr13.2">
    - <xsd:restriction base="xsd:decimal">
    <xsd:totalDigits value="13" />
    <xsd:fractionDigits value="2" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="date">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="10" />
    <xsd:pattern value="\d\d\d\d-\d\d-\d\d" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="numeric3">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="3" />
    <xsd:pattern value="\d*" />
    </xsd:restriction>
    </xsd:simpleType>
    - <xsd:simpleType name="numeric6">
    - <xsd:restriction base="xsd:string">
    <xsd:maxLength value="6" />
    <xsd:pattern value="\d*" />
    </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:complexType name="Zvoucher">
    - <xsd:sequence>
    <xsd:element name="Lifnr" type="n0:char10" />
    <xsd:element name="Sort1" type="n0:char20" />
    <xsd:element name="Bldat" type="n0:date" />
    <xsd:element name="Budat" type="n0:date" />
    <xsd:element name="Bktxt" type="n0:char25" />
    <xsd:element name="Xblnr" type="n0:char16" />
    <xsd:element name="Dmbtr" type="n0:curr13.2" />
    <xsd:element name="Kostl" type="n0:char10" />
    <xsd:element name="Hkont" type="n0:char10" />
    <xsd:element name="Zuonr" type="n0:char18" />
    <xsd:element name="Xref3" type="n0:char20" />
    <xsd:element name="Xref2" type="n0:char12" />
    <xsd:element name="Xref1" type="n0:char12" />
    </xsd:sequence>
    </xsd:complexType>
    - <xsd:complexType name="Bapiret2">
    - <xsd:sequence>
    <xsd:element name="Type" type="n0:char1" />
    <xsd:element name="Id" type="n0:char20" />
    <xsd:element name="Number" type="n0:numeric3" />
    <xsd:element name="Message" type="n0:char220" />
    <xsd:element name="LogNo" type="n0:char20" />
    <xsd:element name="LogMsgNo" type="n0:numeric6" />
    <xsd:element name="MessageV1" type="n0:char50" />
    <xsd:element name="MessageV2" type="n0:char50" />
    <xsd:element name="MessageV3" type="n0:char50" />
    <xsd:element name="MessageV4" type="n0:char50" />
    <xsd:element name="Parameter" type="n0:char32" />
    <xsd:element name="Row" type="xsd:int" />
    <xsd:element name="Field" type="n0:char30" />
    <xsd:element name="System" type="n0:char10" />
    </xsd:sequence>
    </xsd:complexType>
    - <xsd:complexType name="TableOfZvoucher">
    - <xsd:sequence>
    <xsd:element name="item" type="tns:Zvoucher" minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
    </xsd:complexType>
    - <xsd:complexType name="TableOfBapiret2">
    - <xsd:sequence>
    <xsd:element name="item" type="tns:Bapiret2" minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
    </xsd:complexType>
    - <xsd:element name="ZVoucherUpload">
    - <xsd:complexType>
    - <xsd:sequence>
    <xsd:element name="Msg" type="tns:TableOfBapiret2" />
    <xsd:element name="Zvoucher" type="tns:TableOfZvoucher" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    - <xsd:element name="ZVoucherUploadResponse">
    - <xsd:complexType>
    - <xsd:sequence>
    <xsd:element name="Msg" type="tns:TableOfBapiret2" />
    <xsd:element name="Zvoucher" type="tns:TableOfZvoucher" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    </wsdl:types>
    - <wsdl:message name="ZVoucherUpload">
    <wsdl:part name="parameters" element="tns:ZVoucherUpload" />
    </wsdl:message>
    - <wsdl:message name="ZVoucherUploadResponse">
    <wsdl:part name="parameter" element="tns:ZVoucherUploadResponse" />
    </wsdl:message>
    - <wsdl:portType name="Z_VOUCHER_UPLOAD">
    - <wsp:Policy>
    <wsp:PolicyReference URI="#IF_Z_VOUCHER_UPLOAD" />
    </wsp:Policy>
    - <wsdl:operation name="ZVoucherUpload">
    - <wsp:Policy>
    <wsp:PolicyReference URI="#OP_ZVoucherUpload" />
    </wsp:Policy>
    <wsdl:input message="tns:ZVoucherUpload" />
    <wsdl:output message="tns:ZVoucherUploadResponse" />
    </wsdl:operation>
    </wsdl:portType>
    </wsdl:definitions>
    Participating Frequently
    November 8, 2010

    One obvious problem I can see from looking at the WSDL is that your operation is this:

    - <wsdl:operation name="ZVoucherUpload">
    - <wsp:Policy>
    <wsp:PolicyReference URI="#OP_ZVoucherUpload" />
    </wsp:Policy>
    <wsdl:input message="tns:ZVoucherUpload" />
    <wsdl:output message="tns:ZVoucherUploadResponse" />
    </wsdl:operation>
    and the input message you need to provide is of type tns:ZVoucherUpload.
    This consists of one parameter of element type ZVoucherUpload:
    - <wsdl:message name="ZVoucherUpload">
    <wsdl:part name="parameters" element="tns:ZVoucherUpload" />
    </wsdl:message>
    The element is a complexType comprising 2 nested elements: TableOfBapiret2 and TableOfZvoucher
    - <xsd:element name="ZVoucherUpload">
    - <xsd:complexType>
    - <xsd:sequence>
    <xsd:element name="Msg" type="tns:TableOfBapiret2" />
    <xsd:element name="Zvoucher" type="tns:TableOfZvoucher" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    Both the table types consists of elements again, in particular of 0 to many occurences of one of those (this is for the TableOfZvoucher):
    - <xsd:complexType name="Zvoucher">
    - <xsd:sequence>
    <xsd:element name="Lifnr" type="n0:char10" />
    <xsd:element name="Sort1" type="n0:char20" />
    <xsd:element name="Bldat" type="n0:date" />
    <xsd:element name="Budat" type="n0:date" />
    <xsd:element name="Bktxt" type="n0:char25" />
    <xsd:element name="Xblnr" type="n0:char16" />
    <xsd:element name="Dmbtr" type="n0:curr13.2" />
    <xsd:element name="Kostl" type="n0:char10" />
    <xsd:element name="Hkont" type="n0:char10" />
    <xsd:element name="Zuonr" type="n0:char18" />
    <xsd:element name="Xref3" type="n0:char20" />
    <xsd:element name="Xref2" type="n0:char12" />
    <xsd:element name="Xref1" type="n0:char12" />
    </xsd:sequence>
    </xsd:complexType>
    So - you have to appreciate that the webservice is asking for a fairly complex and nested structure and that's it's not possible to just pass in a collection of attributes as you've tried in your cfinvoke.

    What you need to do instead is to rebuild this object/data structure in CF so that the marshalling and unmarshaling during the web service call will actually produce and XML document to arrive on the SAP side that can be understood by the SAP webservice endpoint.
    Have a read of this article, it's a must-read for what you're trying to do:

    http://tjordahl.blogspot.com/2008/04/reprint-consuming-web-service-complex.html

    Cheers,

    Kai