cancel
Showing results for 
Search instead for 
Did you mean: 

Using cl_http_client for calling WSDL(URL) method

Former Member
0 Kudos

Hi Experts,

I am trying to consume WSDL using  class CL_HTTP_CLIENT, may be I am missing some thing in below code, could any one please correct what I am missing? , I am not pretty sure how to use methods but written below code for reference written using other codes in SDN

Actually I need to pass multiple parameters to SubmitEx2 method at a time,

is there any best example with WSDL and code for regarding methods to use while calling URL and parameters to pass...,

like any WSDL like Currency Convertor in http://www.webservicex.net     

my code for your information :

DATA: http_client TYPE REF TO if_http_client,
host_str
TYPE string VALUE 'X.y.z.a,
    service_str
TYPE string,
    path
TYPE string VALUE 'itpserver/itpserver.asmx',
    errortext
TYPE string. "used for error handlingDATA  : wf_string1 TYPE string,

         lw_input
TYPE zcrm_aia_wsdl_cpsubmit_ex2soa1,
         lw_output
TYPE  zcrm_aia_wsdl_cpsubmit_ex2soap,

         lw_inputs
TYPE string,
         lw_outputs
TYPE  string.


*CALL METHOD cl_http_client=>create

*  EXPORTING

*    host               = host_str

*   service            = service_str

**   proxy_host         = proxy_host

**   proxy_service      = proxy_service

**   scheme             = '1'"scheme

*  IMPORTING

*    client             = http_client

*  EXCEPTIONS

*    argument_not_found = 1*    internal_error     = 2*    plugin_not_active  = 3*    OTHERS             = 4.

CALL METHOD cl_http_client=>create_by_url
 
EXPORTING
    url                =
'http://x.y.z.a/itpserver/itpserver.asmx'

*   proxy_host         =

*   proxy_service      =

*   ssl_id             =*   sap_username       =*   sap_client         =
 
IMPORTING
   
client             = http_client
 
EXCEPTIONS
    argument_not_found =
1
    plugin_not_active  =
2
    internal_error     =
3
   
OTHERS             = 4.IF sy-subrc <> 0.
 
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

CALL METHOD http_client->request->set_header_field
 
EXPORTING
    name  =
'~request_method'
   
value = 'POST'.CALL METHOD http_client->request->set_header_field
 
EXPORTING
    name  =
'~server_protocol'
   
value = 'HTTP/1.1'.CALL METHOD http_client->request->set_header_field
 
EXPORTING
    name  =
'~request_uri'
   
value = '/itpserver/itpserver.asmx'.

CALL METHOD http_client->request->set_header_field
 
EXPORTING
    name  =
'Content-Type'
   
value = 'application/soap+xml; charset=utf-8'."'text/xml; charset=utf-8'.

CALL METHOD http_client->request->set_header_field
 
EXPORTING
    name  =
'Content-Length'
   
value = '19000'."txlen.CALL METHOD http_client->request->set_header_field
 
EXPORTING
    name  =
'SOAPAction'
   
value = 'http://www.aia-itp.com/itpserver/wsdl/SubmitEx2'.


CONCATENATE'<?xml version="1.0" encoding="utf-8"?>''<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"''xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
' <soap:Body>'
   
'<service xmlns="http://www.aia-itp.com/itpserver/wsdl">generatedocument</service>'
   
'<parms xmlns="http://www.aia-itp.com/itpserver/wsdl">'
     
'<string>Quote</string>'
     
'<string></string>'
   
'</parms>'
   
'<inKeyValues xmlns="http://www.aia-itp.com/itpserver/wsdl">'
     
'<KeyValue>'
       
'<key></key>'
       
'<value></value>'
     
'</KeyValue>'
     
'<KeyValue>'
       
'<key></key>'
       
'<value></value>'
     
'</KeyValue>'
   
'</inKeyValues>'
   
'<inDocuments xmlns="http://www.aia-itp.com/itpserver/wsdl">'
     
'<Doc>'
       
'<id>xmldoc</id>'
       
'<content></content>'
     
'</Doc>'
     
'<Doc>'
       
'<id>xmldoc</id>'
       
'<content></content>'
     
'</Doc>'
   
'</inDocuments>'
   
'<sessionID xmlns="http://www.aia-itp.com/itpserver/wsdl"></sessionID>'
   
'<jobID xmlns="http://www.aia-itp.com/itpserver/wsdl"></jobID>''</soap:Body>''</soap:Envelope>'
INTO wf_string1.
CALL METHOD http_client->request->set_cdata
 
EXPORTING
   
data   = wf_string1*   offset = 0
    length =
'19000'.

CALL METHOD http_client->send
 
EXCEPTIONS
    http_communication_failure =
1
    http_invalid_state         =
2.

CALL METHOD http_client->receive
 
EXCEPTIONS
    http_communication_failure =
1
    http_invalid_state         =
2
    http_processing_failed     =
3.CLEAR wf_string1 .

wf_string1 = http_client->response->get_cdata( ).  

Here how to pass data using 'POST' method of HTTP and how to get results using HTTPs 'GET', how to use these two?

Thanks,

VijInd

Accepted Solutions (0)

Answers (1)

Answers (1)

ceedee666
Active Contributor
0 Kudos

Hi Vijlnd,

is there any specific reason why you want to call a web service using CL_HTTP_CLIENT?

Instead of manually crafting the XML and the request it would be much easier to use the web service infrastructure provide by ABAP and NW. You can, for example, simply create a ABAP proxy from a WSDL. Invoking the web service is then as easy as calling a method.

See the following link for some information regarding the ABAP web service capabilities:

http://help.sap.com/saphelp_dm40/helpdata/en/9b/dad1ae3908ee44a5caf57e10918be9/content.htm

Christian

Former Member
0 Kudos

Hi Christian,

actually I had ccreated the proxy from WSDL after lot of modifications to it for to get compatable with SAP CRM, then what exactly we made was WSDL with multiple message parts will not supproted by SAP, so we have created one complex element with all parameters required and crated message.

After this I had created proxy, now while passed data am getting error system fault with message saying one of attributes can't be null, actually I am also passing it.

now what I feel is while sending data we have passing to this fields which becomes like work area for us but for him he expected in individual parameters, may be he need to look our request data and map it to respective fields/segrigate and validate it, but he is not doing it.

so I feel better to use HTTP_CLIENT for this...

FYI

http://scn.sap.com/thread/3307255

Thanks,

VijInd

Former Member
0 Kudos

Hi Vij,

I'm facing a similar issue. Could you consume the WSDL via http client ? Can you share your last version of your code ?

Thanks in advance

Have a nice day.