Pros & Cons for consuming web services in ABAP using ABAP PROXY
Hi,
Other then performence is there any other disadvantages like security,etc for consuming web services in ABAP using ABAP proxy?
I really appreciate if some one provide the more details(Pros & Cons ) regarding cosuming web services and I also want to know is there any other way to consume web services in ABAP.
Thanks.
<i> is there any other way to consume web services in ABAP</i>
you can use cl_http_client class to make your program to act as http client and post the soap message too webservice. This way you dont need to generate proxy, but you should know the soap message format.
Regards
Raja
Similar Messages
-
Best practice for consuming web services
Hi
we are consuming web service in orchestration by "Add Generated Item".By using this option it creates 1 orch,1xsd file and some bindings.
we have different projects for schemas,maps and orchestration under our solution in visual studio.
Now i need to know that what will be the best practice for consuming web service in orchestration i mean in which project should i use "add generated item" (in orchstration project or in schemas project) coz it generates both 1 orch and 1
schema.
thanksFrom a service orientation perspective you should abstract the service artifacts from the other artifacts. Otherwise it will be very difficult to update the service interface without affecting the other artifacts. For example you don't want to have to redeply
your entire application if only one field changes in the service you consume.
So I typically generate the items, remove the unnecessary stuff, and put them in a separate project.
Depending on the control you have over the services you want to consume, it would even be better to create another layer of abstraction. By that I mean create your own interface (schema) and map that one to the one the service exposes. This basically
is only necessary if you consume external services that are beyond your control. By abstracting the interface it exposes, you limit the impact of changes of that interface on the rest of your system. All changes are abstracted behind your own interface.
If you consume internal services, you can probably control the way the interface is defined. In a service oriented world all internal services expose a well known interface, based on the domain objects you have within your organisation.
Jean-Paul Smit | Didago IT Consultancy
Blog |
Twitter | LinkedIn
MCTS BizTalk 2006/2010 + Certified SOA Architect
Please indicate "Mark as Answer" if this post has answered the question. -
Code for consuming web services in ABAP
*& Report ZVM_GET_CITY_TIME
REPORT zvm_get_city_time.
PARAMETERS:
p_city TYPE zget_city_time_soap_in-city.
DATA:
cl_proxy TYPE REF TO zco_time_service_soap,
input TYPE zget_city_time_soap_in,
output TYPE zget_city_time_soap_out,
systerr TYPE REF TO cx_ai_system_fault,
w_error TYPE c.
TRY.
CREATE OBJECT cl_proxy
EXPORTING
logical_port_name = 'ZCO_TIME_SERVICE_SOAP'.
CATCH cx_ai_system_fault.
CREATE OBJECT systerr.
WRITE:/ 'Error in creating object - ', systerr->errortext.
ENDTRY.
TRY.
input-city = p_city.
CALL METHOD cl_proxy->get_city_time
EXPORTING
input = input
IMPORTING
output = output.
CATCH cx_ai_system_fault.
CREATE OBJECT systerr.
WRITE:/ 'Error in calling the method - ', systerr->errortext.
w_error = 'X'.
ENDTRY.
CHECK w_error NE 'X'.
SKIP.
WRITE:/ 'The current time in ', p_city, ' is ',
output-get_city_time_result.<i> is there any other way to consume web services in ABAP</i>
you can use cl_http_client class to make your program to act as http client and post the soap message too webservice. This way you dont need to generate proxy, but you should know the soap message format.
Regards
Raja -
Error while consuming Web Service (returning XML ) in ABAP
Hi,
i am trying to consume a web service in ABAP. ( webservice which takes a request and return a XML string back).
I created a proxy class in SE80. and i tested it successfully.
When i tried to use the class in my program, it is giving dump.
i am not sure what is the problem. I guess it is not able to handle null values in XML.if that is the case. how to handle it..The dump says:
Runtime Errors OBJECTS_OBJREF_NOT_ASSIGNED
Except. CX_SY_REF_IS_INITIAL
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
caught and
therefore caused a runtime error.
The reason for the exception is:
You attempted to use a 'NULL' object reference (points to 'nothing')
access a component (variable: "LO_CLIENTPROXY").
An object reference must point to an object (an instance of a class)
before it can be used to access components.
Either the reference was never set or it was set to 'NULL' using the
CLEAR statement.
I think this dump is because of the default value ( space) in some elements. How to avoide that.
wheni catch CX_SY_REF_IS_INITIAL it is not giving any dump. But this is not my requirement. Because it is not getting anything into response string. -
HI
I am consuming web service WSDL file in ABAP using client proxy concept. But every time i execute the program system is
asking for portal user name and pwd. where can i put user name an pwd so that system can take it directly from there
during run time.
Regards,
Shyam.Yes,
There is a place in SOAMANAGER to put userid and pwd for portal user. and this works.
Thanks,
Shyam -
Consuming Web Services in 11.2 does not work (UTL_DBWS)
Hello
i read some documents for consuming web services on the internet , but i get an error when i call add_numbers function as follows:
i connected on WSUSER , then
SQL> select add_numbers(1,3) from dual;
The Error message is:
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.IllegalAccessException: java.lang.ExceptionInInitializerError
ORA-06512: at "WSUSER.UTL_DBWS", line 193
ORA-06512: at "WSUSER.UTL_DBWS", line 190
ORA-06512: at "WSUSER.ADD_NUMBERS", line 25"
I use the following steps to setup the UTL_DBWS :
1- Create new user 'WSUSER'
2- Run the UTL_DBWS scripts ( utl_dbws_decl.sql , utl_dbws_body.sql) on WSUSER.
3- Execute this command
loadjava -u scott/tiger -r -v -f -genmissing dbwsclientws.jar dbwsclientdb11.jar
4- Log in as sys and grant these privileges to our new user:
execute dbms_java.grant_permission('WSUSER','SYS:java.util.PropertyPermission','http.proxySet','write');
execute dbms_java.grant_permission('WSUSER','SYS:java.util.PropertyPermission','http.proxyHost', 'write');
execute dbms_java.grant_permission('WSUSER','SYS:java.util.PropertyPermission','http.proxyPort', 'write');
execute dbms_java.grant_permission('WSUSER','SYS:java.lang.RuntimePermission', 'accessClassInPackage.sun.util.calendar','');
execute dbms_java.grant_permission('WSUSER','SYS:java.lang.RuntimePermission','getClassLoader','');
execute dbms_java.grant_permission('WSUSER','SYS:java.net.SocketPermission','*','connect,resolve');
execute dbms_java.grant_permission('WSUSER','SYS:java.util.PropertyPermission','*','read,write');
execute dbms_java.grant_permission('WSUSER','SYS:java.lang.RuntimePermission','setFactory','');
execute dbms_java.grant_permission('WSUSER','SYS:java.lang.RuntimePermission', 'createClassLoader', '' )
5- Create add_numbers function on wsuser to test utl_dbws:
CREATE OR REPLACE FUNCTION add_numbers (p_int_1 IN NUMBER,
p_int_2 IN NUMBER)
RETURN NUMBER
AS
l_service UTL_DBWS.service;
l_call UTL_DBWS.call;
l_wsdl_url VARCHAR2(32767);
l_namespace VARCHAR2(32767);
l_service_qname UTL_DBWS.qname;
l_port_qname UTL_DBWS.qname;
l_operation_qname UTL_DBWS.qname;
l_xmltype_in SYS.XMLTYPE;
l_xmltype_out SYS.XMLTYPE;
l_return NUMBER;
BEGIN
l_wsdl_url := 'http://www.oracle-base.com/webservices/server.php?wsdl';
l_namespace := 'http://www.oracle-base.com/webservices/';
l_service_qname := UTL_DBWS.to_qname(l_namespace, 'Calculator');
l_port_qname := UTL_DBWS.to_qname(l_namespace, 'CalculatorPort');
l_operation_qname := UTL_DBWS.to_qname(l_namespace, 'ws_add');
l_service := UTL_DBWS.create_service (
wsdl_document_location => URIFACTORY.getURI(l_wsdl_url),
service_name => l_service_qname);
l_call := UTL_DBWS.create_call (
service_handle => l_service,
port_name => l_port_qname,
operation_name => l_operation_qname);
l_xmltype_in := SYS.XMLTYPE('<?xml version="1.0" encoding="utf-8"?>
<ws_add xmlns="' || l_namespace || '">
<int1>' || p_int_1 || '</int1>
<int2>' || p_int_2 || '</int2>
</ws_add>');
l_xmltype_out := UTL_DBWS.invoke(call_Handle => l_call,
request => l_xmltype_in);
UTL_DBWS.release_call (call_handle => l_call);
UTL_DBWS.release_service (service_handle => l_service);
l_return := l_xmltype_out.extract('//return/text()').getNumberVal();
RETURN l_return;
END;
6- Test the function
Select add_numbers(1,2) from dual
on the test i get the error message :
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.IllegalAccessException: java.lang.ExceptionInInitializerError
ORA-06512: at "WSUSER.UTL_DBWS", line 193
ORA-06512: at "WSUSER.UTL_DBWS", line 190
ORA-06512: at "WSUSER.ADD_NUMBERS", line 25
anyone have an idea to resolve this error .
thanks alotHi.
Looking at the code, it seems it is my article you are asking about.
http://www.oracle-base.com/articles/10g/utl_dbws10g.php
I've just run through it on an 11.2 instance and it works fine for me.
Make sure your server has access to the Internet and make sure the java classes are loaded successfully.
Cheers
Tim... -
How to Consume Web Service?
Hi Experts,
I need to call a Function Module in the Exit.
In this Function Create to write the code to consume web service created by third party.
Then get the Data from there and uodate SAP
Can u plz help me with the Steps Involved in this?Hi Mohsin,
Please chk this link once for consuming web services..
http://help.sap.com/saphelp_nw70/helpdata/en/bf/d005244e9d1d4d92b2fe7935556b4c/frameset.htm
http://help.sap.com/saphelp_nw04/Helpdata/EN/b4/6aae409567942ae10000000a155106/content.htm.
U shuld have authorizations for tcodes WSADMIN and SOAMANAGER for creating web services
Hope it will be useful..
Regards,
Lakshman.
Edited by: Lakshman N on Jan 13, 2009 12:06 PM -
Windows authentification while consuming web service from ABAP
Hi All,
We are consuming web service from ABAP, we have created client proxy in SE80 and configured logical port in LPCONFIG.
This one was working fine. Now we have added windows user authentification to access this service.
Now when I'm trying to regenerate this proxy in R/3 it is asking for user and password. When I enter these details this one is not working.
If I access this service direcly from internet explorer and I enter same user and password then I would able to access this service.
Could you please let me know how to handle this.
Regards
VikramThe dialog that is produced by HTTP Destination object of the logical port is designed only for use within Classic Dynpro applications. There is no prompt produced when running in Web Dynpro. If possible assign a generic user within the logical port definition and this will be used automatically by all users.
-
Consume web service in ABAP proxy with SOAP header
Hi Thomas ,
I am trying to consume web service in ABAP . I have followed the procedure from one of your web blog <a href="/people/thomas.jung3/blog/2004/11/17/bsp-a-developers-journal-part-xiv--consuming-webservices-with-abap a Developer's Journal Part XIV - Consuming WebServices with ABAP</a> . (640 release).
I need to pass SOAP header along with SOAP body. As you mentioned I have used if_wsprotocol_ws_header interface to pass header but it is still failing.
Please see below code and please give some direction to fix the issue.
1.Create ABAP proxy for WSDL (http://ws.strikeiron.com/SwanandMokashi/StockQuotes?WSDL). It has created structures only for SOAP body.
2.Create Logical port
3.Create following program to call proxy
REPORT zproxy.
DATA: ref_stock TYPE REF TO zzco_stock_quotes_soap ,
ws_header TYPE REF TO if_wsprotocol_ws_header,
name TYPE string,
namespace TYPE string.
TRY.
CREATE OBJECT ref_stock
get WS_HEADER protocol
ws_header ?= ref_stock->get_protocol('IF_WSPROTOCOL_WS_HEADER').
set somehow header as iXML-DOM tree
DATA: ixml TYPE REF TO if_ixml,
xml_document TYPE REF TO if_ixml_document,
xml_root TYPE REF TO if_ixml_element,
xml_element TYPE REF TO if_ixml_element,
xml_node TYPE REF TO if_ixml_node.
DATA l_xstring TYPE xstring.
DATA l_string TYPE string.
FIELD-SYMBOLS <fs_xstring> TYPE xstring.
Additional Header:
CONCATENATE
'<soap:Header>'
'<s1:LicenseInfo xmlns:s1="http://ws.strikeiron.com">'
'<s1:RegisteredUser>'
'<s1:UserID>[email protected]</s1:UserID>'
'<s1:Password>aaaaaaaa</s1:Password>'
'</s1:RegisteredUser></s1:LicenseInfo>'
'</soap:Header>' INTO l_string.
convert to xstring
l_xstring = cl_proxy_service=>cstring2xstring( l_string ).
IF NOT l_string IS INITIAL.
create iXML DOM document from XML xstring
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = l_xstring
IMPORTING
document = xml_document
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
IF sy-subrc = 0 AND NOT xml_document IS INITIAL.
xml_root = xml_document->get_root_element( ).
xml_element ?= xml_root->get_first_child( ).
add header element by element to SOAP header
WHILE NOT xml_element IS INITIAL.
name = xml_element->get_name( ).
namespace = 'http://swanandmokashi.com' . "xml_element->get_namespace_uri( ).
IF NOT xml_element IS INITIAL.
ENDIF.
ws_header->set_request_header(
name = name
namespace = namespace
dom = xml_element ).
xml_element ?= xml_element->get_next( ).
ENDWHILE.
ENDIF.
ENDIF.
CATCH cx_ai_system_fault .
ENDTRY.
*Call soap body using abap proxy class.
DATA: get_quotes TYPE zzget_quotes_soap_out .
DATA: get_quotes1 TYPE zzget_quotes_soap_in .
get_quotes1-quote_ticker = 'GE'.
TRY.
CALL METHOD ref_stock->get_stock_quotes
EXPORTING
get_quotes1 = get_quotes1
IMPORTING
get_quotes = get_quotes.
CATCH cx_ai_system_fault .
CATCH cx_ai_application_fault .
ENDTRY.
4.It is throwing cx_ai_system_fault error.
SOAP details:
Input:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding" >
<soap:Header>
<s1:LicenseInfo xmlns:s1="http://ws.strikeiron.com">
<s1:RegisteredUser>
<s1:UserID>[email protected]</s1:UserID>
<s1:Password>aaaaaaaa</s1:Password>
</s1:RegisteredUser>
</s1:LicenseInfo>
</soap:Header>
<soap:Body>
<tns:GetQuotes xmlns:tns="http://swanandmokashi.com">
<tns:QuoteTicker>GE</tns:QuoteTicker>
</tns:GetQuotes>
</soap:Body>
</soap:Envelope>
Thanks,
Kavitha.Hi ,
Thank you for the response. Did you passed user email and password ([email protected] /aaaaaaaa) part of licenseinfo->resisteredUser along with Quoteticker GE in analyzer?
<a href="http://www.strikeiron.com/Analyzer/OnlineAnalyzer.aspx?WSDL=http://ws.strikeiron.com/SwanandMokashi/StockQuotes?WSDL">ANALYZER</a>
Thanks,
Kavitha. -
To consume web service in ABAP is it required that server should be XI.
Hi ,
I am trying to connect to a webservice from netweaver 7.0 systemand it gives an error " Not configured as integration engine". Is it required to have integration engine to consume web service.
SanjayHi Sanjay
You can consume webservices in ABAP but its better to use XI in mid to avoid point to point communication. Using XI you can have a central hub for all services you consume or publish
Check this link as well
BSP a Developer's Journal Part XIV - Consuming WebServices with ABAP
Thanks
Gaurav -
Problem at Consume WEB Service in ABAP
hello!!
I tell them my problem, is to create a web service from the SE80, which could be used properly.
Then there was a change of server, which migrated to the developments and the web service is recreation, but this can not be consumed.
now I need help, is where do I indicate that the basis so that they can return to consume web services, what services or settings should be activated.
any suggestion or help are welcome.
The ECC system is a 5 AS ABAP only.
from now, I appreciate any help or guidance I can get.What is the problem? Are all the services active in SICF for web services and how is the web service being consumed is it through a wsdl file ?
-
How to consume Web Services form ABAP ?
Hi,
Please advise how to consume web services from ABAP Code ? is there any automatic generating proxy class in order to consume web services ?
I am using NW 7.0 SP15
Thank You and Best Regards
Fernand LesmanaHi Fernand,
chk out for this link
Consume an ABAP Webservice (WAS 620) from .Net
Send SMS to India from ABAP
working web service from ABAP
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a4433436-0301-0010-f2a9-9281ad574054
Regards
Sampath -
How to consume WEB SERVICES from ABAP ??
Q: How to consume WEB SERVICES from ABAP program??
the point here is i am using SAP release 620 and the creation of proxy is out of scenario
and also no XI. Its only through ABAP program i need to consume one web service (its a HTTPS one ),
Using cl_http_client... i tried it but i am totally confused of whats happening ???
Req some senior ppl advice on the same/approach.
any hints will suffice my way of approach...!!!
Please do put in your valuable advices..!!
Thanks in advance..!!!!Hello Srinivas,
Following is the code for calling web service:
data: client type ref to if_http_client,
host type string value 'server url',
service type string value '8080',
path type string value '/sap/public/ping',
errortext type string,
proxy_service type string,
scheme type i value 1.
call method cl_http_client=>create
exporting host = host
service = service
proxy_host = host
proxy_service = service
scheme = scheme
importing client = client
exceptions
argument_not_found = 1
internal_error = 2
plugin_not_active = 3
others = 4.
case sy-subrc.
when 0.
write 'Server reached successfully'.
when others.
write: 'sy-subrc =', sy-subrc.
endcase.
Once you got the client object you can call following methods:
"Set the requrie URL for the web service you want to call. This is not WSDL anyway!!
cl_http_utility=>set_request_uri( request = client->request
uri =' url 2 be called ').
*Then you can call send method with proper inputs for sending request to WS
CALL METHOD client->send
Then you can use receive method for getting the response
CALL METHOD client->receive
*You can get last error in case of exceptions
CALL METHOD cl_http_client=>get_last_error
*Close the client object
CALL METHOD client->close
For more information on full code refer my link in previous replay.
Thanks,
Augustin.
Edited by: Augustarian on Aug 18, 2009 1:49 PM -
Consuming Web service : Sample ABAP application
Hi Friends,
I am trying to consume existing web service. I have few questions.
--> Why do we need to create simple ABAP application while consuming Enterprise Service?
--> How this ABAP application will be triggered? Will it be triggered automatically or this is just for testing purpose?
--> After consuming Enterprise Service , which URL my end user can use to execute the functionality ( i.e to craete PO )
Waiting for your expert responses.
Thanks,
Rashmi JainHello,
Please see the responses below:
-->Why do we need to create simple ABAP application while consuming Enterprise Service?
When you created consumer proxy, you have a proxy class autogenerated. The ABAP program is to provide input data and instantiate and call the method within the proxy class.
--> How this ABAP application will be triggered? Will it be triggered automatically or this is just for testing purpose?
The program can be triggered using a Transaction or can be scheduled through batch or event based.
--> After consuming Enterprise Service , which URL my end user can use to execute the functionality ( i.e to craete PO )
The end user does not have to know the URL. This is built into WSDL from which you created consumer proxy.
Thanks,
Venu -
How to consume Web Service in ABAP WebDynpro
Hi
I want to know the entire details about how to consume Web Service in WebDynpro application.
regards
PiyushhI piyush,
Have a look at this Blog by Thomas Jung.
/people/thomas.jung/blog/2007/12/17/consuming-services-with-abap
on consuming webservies thru webdynpro ABAP
Cheers
Mary
Maybe you are looking for
-
Release of service entry sheet
hi all, i want to setup release for service entry sheet. in spro-mm-external service-release procedure of service entry sheet? what is the spro path where ican create characterstics and class for release> how many levels of approval can be assigned f
-
I have been using my iPhone and ipad to turn on Apple TV. I thought I would try home share since we all like looking at our family pictures and music. Well, now I can't turn on the Apple TV. (My remote went through the wash) what do I do? I'm addicte
-
Mic activation on iPod Touch 2nd gen?
Does anyone know if the mic is working with the new 2.2 update? If not any idea when it will be available?
-
Debugging a User Exit or Program
Hi, I would like to debug a program, and locate and fix an error in one of the user exits. How can I go about doing this? Thanks, Shah.
-
New iMac, major difference or not?
I see some articles now appearing on the new iMac range announced yesterday. Does anyone have any real performance data yet which compares the current to previous models? With new NVIDIA GPU and DDR3 versus DDR2 but same frontside bus (1066) and Inte