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: 

Add values to the HTTP header

Former Member
0 Kudos

HI

I having a method that call to Web service and i need to add additional info

like key and value ,

there is API (method or FM )which i can use for the purpose ?

Regards

James

Edited by: James Herb on Apr 7, 2010 3:37 PM

1 ACCEPTED SOLUTION

brad_bohn
Active Contributor
0 Kudos

I don't think these guys recommending CL_HTTP_CLIENT understand the web service protocols. Since you are using a consumer proxy to call a web service method, then to add a message header field (SOAP envelope header), you need to use the web service runtime protocol WS_HEADER provided for that. You would access this through method IF_PROXY_BASIS~GET_PROTOCOL which is attached to your proxy object. See the documentation in the help files or for interface IF_WSPROTOCOL for an example.

10 REPLIES 10

former_member721730
Active Participant
0 Kudos

Hi James,

There are plenty of classes starting with CL_HTTP_*. We were used cl_http_client and http_client classes for webservices purpose. Please try with this classes. Below are might be useful.

cl_http_client=>create_by_url

http_client->send

http_client->receive

http_client->close

Saravanan V

0 Kudos

HI SARAVANAN ,

Thanks ,

i call to a client WS maybe do you know how can i do that ,any example ?

Regards

James

Edited by: James Herb on Apr 7, 2010 10:50 PM

0 Kudos

To call a web service, you have to create a proxy in SAP (SE80, other object, enterprise services). See sap library http://help.sap.com/saphelp_nw70/helpdata/EN/02/265c3cf311070ae10000000a114084/frameset.htm.

What kind of header do you want to add??

0 Kudos

HI Sandra ,

I create Client proxy from WSDL (.Net service) that my colleague

send to me and I call to it as follows

DATA: lo_client_proxy TYPE REF TO co_task_web_service.

     CALL METHOD lo_client_proxy->crt_task
        EXPORTING
          input  = ls_input
        IMPORTING
          output = ls_output.

but he told me that he want that I add additional data to the HTTP header as follows

Request.Headers.Add("X-FORS_BASED_A_APTED", "t");

How I can do that ?

if it not possible please let me know

Thanks and Regards

James

Edited by: James Herb on Apr 8, 2010 2:00 PM

Edited by: James Herb on Apr 8, 2010 2:20 PM

Former Member
0 Kudos

Hi James,

I would recommend to use the class CL_HTTP_CLIENT.

Here we have been provided with the method SET_HEADER_FIELD.

We can add extra information through this method.

Please revert if something is unclear.

Thanks,

Daya.

0 Kudos

HI daya mishra

Thanks ,

How i can use it in my case before or after the call to the WS can you give me some example ?

Regards

James

Edited by: James Herb on Apr 8, 2010 4:22 PM

brad_bohn
Active Contributor
0 Kudos

I don't think these guys recommending CL_HTTP_CLIENT understand the web service protocols. Since you are using a consumer proxy to call a web service method, then to add a message header field (SOAP envelope header), you need to use the web service runtime protocol WS_HEADER provided for that. You would access this through method IF_PROXY_BASIS~GET_PROTOCOL which is attached to your proxy object. See the documentation in the help files or for interface IF_WSPROTOCOL for an example.

0 Kudos

Based on Brad answer, I could find one snippet of code in SDN:

Former Member
0 Kudos

HI ,

Thanks but this is for soap envelope and not for the HTTP header .

Regards

James

0 Kudos

HI James ,

Unfortunately you cannot set any attributes on the HTTP header when you using Web service .

Regards

Shimon Tal