Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Comsume Web Service via ABAP SAP 4.7

Former Member
0 Kudos

Hello Experts

We wanted use an ABAP program to call a web service. We were only given the target WSDL file. Not sure what to do with this and what information can we get from this.

As I checked, the format is different from the conventional web service I found in the blogs. Usually the WSDL URL is format below.

http://www.webservicex.net/airport.asmx?wsdl

and you can see and test the services from this URL http://www.webservicex.net/airport.asmx

But in our case, this the WSDL URL is below.

http://<host>/dd10/services/shipRSS?wsdl

and we cannot see and test service from http://<host>/dd10/services/shipRSS this is what we are getting.

"shipRSS

Hi there, this is an AXIS service!

Perhaps there will be a form for invoking the service here..."

Having this kind of WSDL, can we still create an ABAP program that can consume this? Is there difference in the programming and parameters. Currently we are using the program template from this blog /people/durairaj.athavanraja/blog/2004/09/20/consuming-web-service-from-abap as we are only running on SAP 4.7 but it seems not to be working. Any thoughts?

Thank you very much!

Tony

1 ACCEPTED SOLUTION

former_member184675
Active Participant
0 Kudos

Hi,

With Set method you specify what Web Service function you call. Use this:

call method osoap->set_method

exporting

nsvalue ='http://webservice.<deleted on purpose>' "this is the namespace from WSDL

name = 'exec' . "this is the function that you call

You use the RFC Connection here:

call method otransp->set_destination_by_name "DESTINATION via SM59

exporting

dest = '<NAME OF THE RFC CONNECTION>'.

Edited by: Andrei Sosea on Jun 17, 2011 11:42 AM

9 REPLIES 9

former_member184675
Active Participant
0 Kudos

Hi, from what i've checked on Axis that is a SOAP Web Service.

If you can read the WSDL of the web service then check this link that explains how to call a SOAP web service from an abap program:

[http://help.sap.com/saphelp_47x200/helpdata/en/2d/64d029e74911d6b2e400508b6b8a93/content.htm]

Look in Appendix C.

Hope this helps.

Regards.

Andrei.

0 Kudos

Hi Andrei,

Thank you so much for your reply. I will try the test program in Apendix C and I will let you know the results. For the meantime, I am sending the WSDL contents and can you kindly confirm if this is a SOAP web service and if the test program will do the trick?

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions targetNamespace="http://webservice.<deleted on purpose>" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.<deleted on purpose>" xmlns:intf="http://webservice.<deleted on purpose>" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<!--WSDLはApache Axis version: 1.4

Built on Apr 22, 2006 (06:55:48 PDT)/ [en]-(WSDL created by Apache Axis version: 1.4

Built on Apr 22, 2006 (06:55:48 PDT))-->

<wsdl:message name="execResponse">

<wsdl:part name="execReturn" type="xsd:string"/>

</wsdl:message>

<wsdl:message name="execRequest">

<wsdl:part name="xmlString" type="xsd:string"/>

</wsdl:message>

<wsdl:portType name="shipRSS">

<wsdl:operation name="exec" parameterOrder="xmlString">

<wsdl:input message="impl:execRequest" name="execRequest"/>

<wsdl:output message="impl:execResponse" name="execResponse"/>

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="shipRSSSoapBinding" type="impl:shipRSS">

<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="exec">

<wsdlsoap:operation soapAction=""/>

<wsdl:input name="execRequest">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://webservice.<deleted on purpose>" use="encoded"/>

</wsdl:input>

<wsdl:output name="execResponse">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://webservice.<deleted on purpose>" use="encoded"/>

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="shipRSSService">

<wsdl:port binding="impl:shipRSSSoapBinding" name="shipRSS">

<wsdlsoap:address location="http://<hostname_deleted>/dd10/services/shipRSS"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

former_member184675
Active Participant
0 Kudos

Hi,

Yep that looks like SOAP .

The program should work if you fill in the parameters correctly.

If you encounter difficulties let me know.

Regards,

Andrei

0 Kudos

Hi Andrei,

Thank you very much. It's such as relief to hear that! At least we are now in a good direction of solving this problem. I've been looking everywhere for answers. Iu2019ll definitely feedback to you with our progress and results.

Regards,

Tony

0 Kudos

Hi Andrei.

Do not know if we are doing it right but this what happens when we copy the program from Appendix C and execute it. This is the result as we execute it. Our Dev team also looking into this. Just thought I ask you if you have an idea.

RESULT from PROGRAM Appendix C

http://help.sap.com/saphelp_47x200/helpdata/en/2d/64d053e74911d6b2e400508b6b8a93/content.htm

Test SOAP

>> Starting...

>>

>> TEST: SOAP call to method STFC_CONNECTION

>>

> Error in HTTP call

> text: SOAP Runtime Exception: CSoapExceptionFault : SOAP fault found in SOAP document

>> SOAP fault information:

> actor :

> code : ns1:Client

> string: No such operation 'STFC_CONNECTION'

> detstr:

>> string as block:

<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">servername</ns2:hostn

ame>

> detail:

>>

>> id > 1

>> pid > 0

>> prfx> ns2

>> nsvl> http://xml.apache.org/axis/

>> name> hostname

>> text> servername

<< ...Done

I also have created destination in SM59 (type G) do you it may have something to do with the parameters. Apparently, when we try to do some connection test, this is the result.

HEADER NAME HEADER VALUE

~response_line HTTP/1.0 200 OK

~server_protocol HTTP/1.0

~status_code 200

~status_reason OK

date Fri, 17 Jun 2011 09:21:12 GMT

content-type text/html;charset=utf-8

content-length 131

x-cache MISS from <PROXYSERVER>

via 1.0 <PROXYSERVER> (squid/3.0.STABLE20)

proxy-connection close

HTTP BODY

<h1>shipRSS</h1>##<p>Hi there, this is an AXIS service!</p>##<i>Perhaps

there will be a form for invoking the service here...</i>##

Thank you very much again for your help.

Tony

former_member184675
Active Participant
0 Kudos

Hi,

With Set method you specify what Web Service function you call. Use this:

call method osoap->set_method

exporting

nsvalue ='http://webservice.<deleted on purpose>' "this is the namespace from WSDL

name = 'exec' . "this is the function that you call

You use the RFC Connection here:

call method otransp->set_destination_by_name "DESTINATION via SM59

exporting

dest = '<NAME OF THE RFC CONNECTION>'.

Edited by: Andrei Sosea on Jun 17, 2011 11:42 AM

0 Kudos

Hi Andrei,

We did the changes in the program and we seem to have made some progress here. Here are the test results now.

Test Soap

>> Starting...

>>

>> TEST: SOAP call to method STFC_CONNECTION

>>

>> Result of SOAP call

echotext =

resptext =

<< ...Done

Here is an excerpt of the program of which parameters are inputted. We are suppose to send an XML string. We have not made much changes in the sample program except the one you highlighted to us before. But if there are any concerns it will on the part where to construct soap request document which is shown below. If it is not too much to ask, would you help us check the parameters if they are correct. Thank you very much. You've been very helpful.

  • 1 construct soap request document

CREATE OBJECT osoap.

IF osoap IS INITIAL.

WRITE: / '> cannot create soap document, exiting...'. EXIT.

ENDIF.

TRY.

** OLD VALUE:

** CALL METHOD osoap->set_method

** EXPORTING

** nsprefix = 'saprfc'

** nsvalue = CSoapConstants=>sc_rfc_function_ns

** attributes =

** name = 'STFC_CONNECTION'.

    • NEW VALUE

CALL METHOD osoap->set_method

EXPORTING

nsvalue ='http://webservice.<namespace>;'

name = 'exec' .

"-- parameter: REQUTEXT

GET REFERENCE OF p_requtext INTO dref.

CALL METHOD osoap->add_parameter

EXPORTING

  • nsprefix =

  • nsvalue =

  • attributes =

direction = CSoapConstants=>ic_param_in

name = 'REQUTEXT'

value = dref.

"-- parameter: ECHOTEXT

GET REFERENCE OF p_echotext INTO dref.

CALL METHOD osoap->add_parameter

EXPORTING

  • nsprefix =

  • nsvalue =

  • attributes =

direction = CSoapConstants=>ic_param_out

name = 'ECHOTEXT'

value = dref.

"-- parameter: RESPTEXT

GET REFERENCE OF p_resptext INTO dref.

CALL METHOD osoap->add_parameter

EXPORTING

  • nsprefix =

  • nsvalue =

  • attributes =

direction = CSoapConstants=>ic_param_out

name = 'RESPTEXT'

value = dref.

"-- use ABAP tag names

CALL METHOD osoap->set_tag_name_format

EXPORTING format = CSoapConstants=>ic_tagfmt_default.

CATCH CSoapExceptionUsage INTO usgEx.

WRITE: / ' > exception occurred'.

exTxt = usgEx->get_text( ).

WRITE: / ' > text: ', exTxt.

EXIT.

ENDTRY.

isoap = osoap.

Former Member
0 Kudos

Incorrect ticking of points

former_member184675
Active Participant
0 Kudos

Hi,

From your WSDL :

<wsdl:operation name="exec" parameterOrder="xmlString">

<wsdl:input message="impl:execRequest" name="execRequest"/>

<wsdl:output message="impl:execResponse" name="execResponse"/>

</wsdl:operation>

I think that you only have one input paramters named execRequest and only one output parameter named execResponse.

And why did you put exec between wildcards?

CALL METHOD osoap->set_method

EXPORTING

nsvalue ='http://webservice.<namespace>;'

name = 'exec' .

echotext and reqtext are local variables in program that are used to output error messages

Try this:


CALL METHOD osoap->set_method
EXPORTING
nsvalue ='*http://webservice.<namespace>*'
name = 'exec' .

data: input type string,
        output type string.

"-- parameter: REQUTEXT
GET REFERENCE OF input INTO dref.
CALL METHOD osoap->add_parameter
EXPORTING
* nsprefix =
* nsvalue =
* attributes =
direction = CSoapConstants=>ic_param_in
name = 'execRequest'
value = dref.

"-- parameter: ECHOTEXT
GET REFERENCE OF output INTO dref.
CALL METHOD osoap->add_parameter
EXPORTING
* nsprefix =
* nsvalue =
* attributes =
direction = CSoapConstants=>ic_param_out
name = 'execResponse'
value = dref.

give the "input" variable the input value and check if the web service call returns anything in the "output" variable.

Regards,

Andrei