cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a WebService from a BSP

Former Member
0 Kudos

Hi,

I have to call a web service published in another web server from a BSP (SAP WAS 620). I know how to use the WAS as client and I also know how to create the XML. The problem is that I dont know if there is some technique or function module or something like this to create the SOAP message to send to the webservice publisher (something to automate the process).

Also If someone has some code to share it will be welcome...

Thanks

Ariel

Message was edited by: Ariel Ferreiro

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You might be out of luck as far as code supplied by SAP to help with the SOAP message. We saw at TechEd how WebAS 640 has the functionality you are looking for. You can generate proxies for WebServices much like other tools do (Visual Studio for instance). This new functionality takes care of the SOAP message for you.

In 620 there is a SOAP package. There are examples in this package, but they only call RFCs as SOAP. According to the service marketplace (http://service.sap.com/connectors), SOAP processing is released in 620 but will be incompatiable with future releases (640).

The following is what it says about the SOAP Client possiblities:

SOAP Client API

This API enables Web services that can be represented on function modules to be called synchronously using SOAP 1.1. This is realized as an ABAP Class Library.

Now on the other hand I have used external WebServices using a REST approach with the SOAP overhead. You simply work with the external webservice using HTTP Client requests and responses. There have been a few discussions on SDN about the topic and I can share a small code sample if you are interested.

Former Member
0 Kudos

Hi Thomas:

first thanks for your quick answer. I dont know if the SOAP package will be usefull for me because I have to consume a web service published by an document mangament system (Hummingbird). What I have to do is to upload a file and put it somewhere in my WAS and then I have to send the SOAP message to the Hummingbird system. Then Hummingbird uploads and deletes the document and gives me a confirmation message. So I think that the second (REST) approach is what I need. So if you can share your small code it will be great for me to start with something.

PD: put the code here or sendit to me to (ariel.ferreiro@ya.com).

Thank you again.

Ariel

eddy_declercq
Active Contributor
0 Kudos

What about calling a external command? Write a client in any language you like (php, java, ...), define it as external command (via trx sm69) and call it via the FM

SXPG_COMMAND_EXECUTE. Sure it ain't the most cool solution but it works and in NW04 it's even better.

athavanraja
Active Contributor
0 Kudos

Checkout this web log. it might give you some idea.

/people/durairaj.athavanraja/blog/2004/09/20/consuming-web-service-from-abap

Regards

Raja

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The following is the code example. We just put all of our input parameters on the request URL. The response body then contains the results which we parse out. This is very similar to the HTTP interface to SAP's own content and cache server. This example happens to be a SMS Message Provider in Eastern Eurpoe.


 data:  client    type ref to if_http_client,
         url       type string.

****Build the Sending URL
  concatenate
    page_srv-send_url
    `&Message=`
    message
    `&Class=`
    class
    `&Number=`
    sms_number
    `&Priority=`
    priority
    `&Project=`
    page_srv-project_name
    `&Sendingnumber=`
    page_srv-sending_number
    into url.

****Create the HTTP client
  call method cl_http_client=>create_by_url
    exporting
      url    = url
      ssl_id = page_srv-ssl_id
    importing
      client = client
    exceptions
      others = 1.

****Set the Request type to GET
  client->request->set_header_field( name  = '~request_method'
                             value = 'GET' ).               "#EC *

****Make the call
  client->send( ).

****Receive the Response Object
  call method client->receive
    exceptions
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      others                     = 4.

****Get the response content in Character format
  p_content = client->response->get_cdata( ).


  data: result_string type string,
        id_string     type string,
        junk          type string.

****Pull out the Result and the ID
  split p_content at `&` into result_string id_string.
  if result_string cs `Result`.
    split result_string at `=` into junk status.
  else.
    raise unknown_error.
  endif.

Hope this helps.

Former Member
0 Kudos

Thanks Thomas and Raja..

Regards. Ariel