cancel
Showing results for 
Search instead for 
Did you mean: 

calling a BAPI from WD using webservice

Former Member
0 Kudos

Hi,

I need to call a BAPI from my WD for Java app.I have created a webservice out of the BAPI and relesed it using the WSCONFIG transation.

Now when I go to my WD app and try to create a new model based on the web service,there is an option to select a <b>WSDL source</b> with three values: 1)Local Server,2)File Sytem or URL and 3)UDDI or URL

My question is :Which <b>one should I choose and what value should i give</b>?

My set up is like this:

On my machine,there is NDS.

On another server,The RFC(BAPI_FLIGHT_GETLIST) is in the ABAP stack of a XI server.

Kindly help with as much details as possible.

thanx,

Bhupesh

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Bhupesh,

When you have exposed your BAPI as web service, you can have the url of the WSDL of this web service.

While creating web service model, use second option:

File system or URL and give this WSDL url in it.

Regards,

Bhavik

Former Member
0 Kudos

Hi Bhavik,

where do I get the WSDL url from?When I click on the WSDL icon in WSADMIN ,the WSDL opens in the following url:

http://<hostname>:8000/sap/bc/srt/rfc/sap/Z_FLIGHT_SERVICE_WSD?sap-client=100&wsdl=1.1?

Is this the value that I need to enter.?

When I give this url,I get the error in NDS:Invalid WSDL or WSDL not found.

Let me know if i am inputting the correct value.

Former Member
0 Kudos

Hi Bhupesh,

Whether you were able to open contents of that url?

If yes, then save that file on the local system and then give this file path.

If possible, post the content of this file.

Regards,

Bhavik

Former Member
0 Kudos

Hi Bhavik,

I can generate the proxies by saving the file locally and using that as the WSDL source.But what could be wrong with the url.

For your reference,here's the wsdl file:

  <?xml version="1.0" encoding="utf-8" ?> 
- <wsdl:definitions targetNamespace="urn:sap-com:document:sap:rfc:functions" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:sap-com:document:sap:rfc:functions" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <wsdl:types>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:sap-com:document:sap:rfc:functions" targetNamespace="urn:sap-com:document:sap:rfc:functions" elementFormDefault="unqualified" attributeFormDefault="qualified">
- <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="char2">
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="2" /> 
  </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="char240">
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="240" /> 
  </xsd:restriction>
  </xsd:simpleType>
- <xsd:simpleType name="char3">
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="3" /> 
  </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="cuky5">
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="5" /> 
  </xsd:restriction>
  </xsd:simpleType>
- <xsd:simpleType name="date">
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="10" /> 
  <xsd:pattern value="dddd-dd-dd" /> 
  </xsd:restriction>
  </xsd:simpleType>
- <xsd:simpleType name="decimal23.4">
- <xsd:restriction base="xsd:decimal">
  <xsd:totalDigits value="23" /> 
  <xsd:fractionDigits value="4" /> 
  </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="numeric4">
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="4" /> 
  <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:simpleType name="time">
- <xsd:restriction base="xsd:string">
  <xsd:maxLength value="8" /> 
  <xsd:pattern value="dd:dd:dd" /> 
  </xsd:restriction>
  </xsd:simpleType>
- <xsd:complexType name="BAPISFLDRA">
- <xsd:sequence>
  <xsd:element name="SIGN" type="tns:char1" /> 
  <xsd:element name="OPTION" type="tns:char2" /> 
  <xsd:element name="LOW" type="tns:date" /> 
  <xsd:element name="HIGH" type="tns:date" /> 
  </xsd:sequence>
  </xsd:complexType>
- <xsd:complexType name="BAPISFLDST">
- <xsd:sequence>
  <xsd:element name="AIRPORTID" type="tns:char3" /> 
  <xsd:element name="CITY" type="tns:char20" /> 
  <xsd:element name="COUNTR" type="tns:char3" /> 
  <xsd:element name="COUNTR_ISO" type="tns:char2" /> 
  </xsd:sequence>
  </xsd:complexType>
- <xsd:complexType name="BAPIPAREX">
- <xsd:sequence>
  <xsd:element name="STRUCTURE" type="tns:char30" /> 
  <xsd:element name="VALUEPART1" type="tns:char240" /> 
  <xsd:element name="VALUEPART2" type="tns:char240" /> 
  <xsd:element name="VALUEPART3" type="tns:char240" /> 
  <xsd:element name="VALUEPART4" type="tns:char240" /> 
  </xsd:sequence>
  </xsd:complexType>
- <xsd:complexType name="BAPISFLDAT">
- <xsd:sequence>
  <xsd:element name="AIRLINEID" type="tns:char3" /> 
  <xsd:element name="AIRLINE" type="tns:char20" /> 
  <xsd:element name="CONNECTID" type="tns:numeric4" /> 
  <xsd:element name="FLIGHTDATE" type="tns:date" /> 
  <xsd:element name="AIRPORTFR" type="tns:char3" /> 
  <xsd:element name="CITYFROM" type="tns:char20" /> 
  <xsd:element name="AIRPORTTO" type="tns:char3" /> 
  <xsd:element name="CITYTO" type="tns:char20" /> 
  <xsd:element name="DEPTIME" type="tns:time" /> 
  <xsd:element name="ARRTIME" type="tns:time" /> 
  <xsd:element name="ARRDATE" type="tns:date" /> 
  <xsd:element name="PRICE" type="tns:decimal23.4" /> 
  <xsd:element name="CURR" type="tns:cuky5" /> 
  <xsd:element name="CURR_ISO" type="tns:char3" /> 
  </xsd:sequence>
  </xsd:complexType>
- <xsd:complexType name="BAPIRET2">
- <xsd:sequence>
  <xsd:element name="TYPE" type="tns:char1" /> 
  <xsd:element name="ID" type="tns:char20" /> 
  <xsd:element name="NUMBER" type="tns:numeric3" /> 
  <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:element name="PARAMETER" type="tns:char32" /> 
  <xsd:element name="ROW" type="xsd:int" /> 
  <xsd:element name="FIELD" type="tns:char30" /> 
  <xsd:element name="SYSTEM" type="tns:char10" /> 
  </xsd:sequence>
  </xsd:complexType>
- <xsd:complexType name="TableOfBAPISFLDRA">
- <xsd:sequence>
  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="tns:BAPISFLDRA" /> 
  </xsd:sequence>
  </xsd:complexType>
- <xsd:complexType name="TableOfBAPIPAREX">
- <xsd:sequence>
  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="tns:BAPIPAREX" /> 
  </xsd:sequence>
  </xsd:complexType>
- <xsd:complexType name="TableOfBAPISFLDAT">
- <xsd:sequence>
  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="tns:BAPISFLDAT" /> 
  </xsd:sequence>
  </xsd:complexType>
- <xsd:complexType name="TableOfBAPIRET2">
- <xsd:sequence>
  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="tns:BAPIRET2" /> 
  </xsd:sequence>
  </xsd:complexType>
- <xsd:element name="BAPI_FLIGHT_GETLIST">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element name="AIRLINE" minOccurs="0" type="tns:char3" /> 
  <xsd:element name="DATE_RANGE" minOccurs="0" type="tns:TableOfBAPISFLDRA" /> 
  <xsd:element name="DESTINATION_FROM" minOccurs="0" type="tns:BAPISFLDST" /> 
  <xsd:element name="DESTINATION_TO" minOccurs="0" type="tns:BAPISFLDST" /> 
  <xsd:element name="EXTENSION_IN" minOccurs="0" type="tns:TableOfBAPIPAREX" /> 
  <xsd:element name="EXTENSION_OUT" minOccurs="0" type="tns:TableOfBAPIPAREX" /> 
  <xsd:element name="FLIGHT_LIST" minOccurs="0" type="tns:TableOfBAPISFLDAT" /> 
  <xsd:element name="MAX_ROWS" minOccurs="0" type="xsd:int" /> 
  <xsd:element name="RETURN" minOccurs="0" type="tns:TableOfBAPIRET2" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
- <xsd:element name="BAPI_FLIGHT_GETLISTResponse">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element name="DATE_RANGE" type="tns:TableOfBAPISFLDRA" /> 
  <xsd:element name="EXTENSION_IN" type="tns:TableOfBAPIPAREX" /> 
  <xsd:element name="EXTENSION_OUT" type="tns:TableOfBAPIPAREX" /> 
  <xsd:element name="FLIGHT_LIST" type="tns:TableOfBAPISFLDAT" /> 
  <xsd:element name="RETURN" type="tns:TableOfBAPIRET2" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
  </xsd:schema>
  </wsdl:types>
- <wsdl:message name="BAPI_FLIGHT_GETLIST">
  <wsdl:part name="parameters" element="tns:BAPI_FLIGHT_GETLIST" /> 
  </wsdl:message>
- <wsdl:message name="BAPI_FLIGHT_GETLISTResponse">
  <wsdl:part name="parameters" element="tns:BAPI_FLIGHT_GETLISTResponse" /> 
  </wsdl:message>
- <wsdl:portType name="Z_FLIGHT_SERVICE_WSD">
- <wsdl:operation name="BAPI_FLIGHT_GETLIST">
  <wsdl:input message="tns:BAPI_FLIGHT_GETLIST" /> 
  <wsdl:output message="tns:BAPI_FLIGHT_GETLISTResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="Z_FLIGHT_SERVICE_WSDSoapBinding" type="tns:Z_FLIGHT_SERVICE_WSD">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="BAPI_FLIGHT_GETLIST">
  <soap:operation soapAction="" /> 
- <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="Z_FLIGHT_SERVICE_WSDService">
- <wsdl:port name="Z_FLIGHT_SERVICE_WSDSoapBinding" binding="tns:Z_FLIGHT_SERVICE_WSDSoapBinding">
  <soap:address location="http://q8t15.sbr03.telekom.de:8000/sap/bc/srt/rfc/sap/Z_FLIGHT_SERVICE_WSD?sap-client=100" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

Now that I have managed to create the model classes,is there any material that can guide me on how and where to use these classes?I would like to have two input fields (Say DEST FROM and DEST TO) and a table to display the flight data based on these inputs.

regards,

Bhupesh

Former Member
0 Kudos

Hi Bhupesh,

You can get the code from the tutorial on how to call web service from SDN web site.

Tutorials link:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/49f2ea90-0201-0010-ce8e-de1...

Go through it.

Here is the link for the Car service tutorial:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial on accessing the car rental web service - 7.htm

Please award points if answer was helpful.

Former Member
0 Kudos

Thax Bhavika.

Points awarded.

One question,when I call a abap BAPI (BAPI_USER_GET_DETAIL),do I get the following err msg:

Service call exception; nested exception is: com.sap.engine.services.webservices.jaxrpc.exceptions.XmlMarshalException: XML Serialization Error. Property [RETURN] of class [com.tsi.model.proxies.types.BAPI_USER_GET_DETAIL] must exist and can not be null. This is required by schema description.

What could be the reason?

regd,

Bhupesh

Former Member
0 Kudos

Hi Bhupesh,

I guess, some input parameters are missing. You have to provide all the required parameters to call the web service.

Regards,

Bhavik

Former Member
0 Kudos

Hi Bhavik,

How exactly does one provide input parameters to a webservice constructed out of a BAP?In this case my BAPI has a TABLE in the interface (of type BAPIRET2).

I want to pass the user id to my BAPI and get the user profile in return.Why should the table RETURN matter here?

Is there any document/link available that shows how to map between the generated model classes and the import,export,tables parameters of a BAP?This seems to be very confusing.

thanx,

Bhupesh

Former Member
0 Kudos

Hi Bhupesh,

If it is return parameter then you do not have to do anything, I guess.

You take a look at the webservice tutorial available in the SDN tutorial page.

Regards,

Bhavik