Calling a rest based json webservice in program
Hi All,
How to call a REST bases JSON web service in abap. Please let me the pre settings for establishing the connection
Thank you
Thanks for ur reply. so how to specify the web server IP? I have a xml and needs to be send it to server to get the response.
Thanks
Senthil
Similar Messages
-
Rest based webservices from plsql procedures/packages
Guyz.
Please let me know How to create Rest based webservices in jdeveloper tool from plsql procedures/packages.
Im very much in need
Thanks,Hi User ,
Welcome to OTN !!
You can refer to these links and figure out -
http://docs.oracle.com/cd/E16162_01/user.1112/e17455/dev_web_services.htm#CHDJIFAE
http://theblasfrompas.blogspot.com/2011/03/developing-restful-web-services-from.html
Also for calling pl/sql packages from Java , use soemthing like this - http://www.coderanch.com/t/302171/JDBC/databases/execute-PL-SQL-program-Java -
Hi, I am new to OSB and working on making OSB as a pass thru for RestFul JSON webservices. I am able to get JSON response back in case of GET request however for POST request I am getting this error:
<con:fault
xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>BEA-380000</con:errorCode>
<con:reason>Unsupported Media Type</con:reason>
<con:location>
<con:node>AegisRouteNode</con:node>
<con:path>response-pipeline</con:path>
</con:location>
</con:fault>
I have used transport header in response action to convert content type to application/json. I am not sure why it works perfectly for GET request but fails for POST.
I appreciate any help that can be provided. Thanks.> I have used transport header in response action to convert content type to application/json
Why in response? o_O
My understanding of what is happening is that the remote server rejects your POST with HTTP 415. I.e. you need to set the Content-Type transport header in request pipeline.
For GET though the server may just ignore the Content-Type header or lack thereof, and that's why it may work.
Try to point your call via Fiddler to see the actual HTTP request and response, it should give you the idea what's going on.
Vlad
http://vladimirdyuzhev.com -
Hi,
We Have a Legacy System based on REST BASED WEBSERVICES, that legacy system can understand only HTTP format(it does n't support SOAP ) our scenario is HTTP TO RFC SYNCHRONOUS.
And we have to connect PI with REST BASED WEBSERVICES ?
1---->How can we connect PI with REST BASED WEBSERVICES ?
2---->and how to test those REST BASED WEBSERVICES ?any tool for that?
Thanks,
Nagaraju.Hi Nagaraju,
you can sent message from PI via [http receiver adapter|http://help.sap.com/saphelp_nw2004s/helpdata/en/43/64dbb0af9f30b4e10000000a11466f/content.htm].
For message from legacy to PI use a simple address, what is explained in [SAP help http sender adapter|http://help.sap.com/saphelp_nw2004s/helpdata/en/43/64db4daf9f30b4e10000000a11466f/content.htm]
You can test http messages with Microsoft's tool [Wfetch|http://www.microsoft.com/download/en/details.aspx?id=21625] (in the net are hundreds of free ware http test tool available).
Regards,
Udo -
Securing REST based Webservices using OSB
Can anyone please lead me to any pointers on securing the REST based webservices.
Thanks,
KCREST is more or less, a pure HTTP service so it is as secure as that. From my perspective transport security (basic authentication, SSL) is the basic security requirement for a REST based web-service. As far as message security is concerned, you may use custom HTTP headers to pass the tokens/digest but again it requires transmission over SSL to become an effective solution.
If you really have tight requirement from message security perspective, then I would suggest going to SOAP rather than using REST.
Regards,
Anuj -
Implementing Rest/JSON Webservice
Hello,
I'm developing an app in iphone and want to use JSON webservice. Can anyone please guide me how to use json format with abap webservices or any document suggesting?
Thanks in AdvanceHi Tahir,
First create a web service in SAP. The blog by Uwe Kunath descibes this clearly. Then create an Xcode project and use the ASIHTTPRequest wrapper to connect to the web service. Parse the response with the KissXML parser. A more out of the box solution is NetWeaver Gateway. It also let you use SAP web services but it also generates iOs code for you. SAP just released a trial version in de download section.
Example of ASIHTTPRequest
- (void)getFlightData:(NSString *) selectedDate {
NSURL *url = [NSURL URLWithString:@"http://abap.sapdev.nl:8000/sap/resources/flights/from/%/to/%/date/20110128?sap-client=001"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setUsername:@"BCUSER"];
[request setPassword:@"minisap"];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
[self parseXML:response];
Example of KissXML
-(void)parseXML:(NSString*)source {
NSError *error = nil;
DDXMLDocument *theDocument = [[DDXMLDocument alloc] initWithXMLString:source options:0 error:&error];
NSArray *results = [theDocument nodesForXPath:@"/asx:abap/asx:values/TAB/BAPISFLDAT" error:&error];
for (DDXMLElement *flightdetail in results) {
NSString *airlineid = [[flightdetail elementForName:@"AIRLINEID"] stringValue];
NSString *airline = [[flightdetail elementForName:@"AIRLINE"] stringValue]; -
How to configure proxy services in OSB for Rest based services?
how to configure proxy services in OSB for Rest based services implemented using Jersey (Rest).
The Client need to contact OSB proxy servies by posting application/xml using jersey client and OSB proxy service will call the OSB business service.
i would like to know how to get this request in OSB proxy service and send it to the business service and get the response back.I would suggest you refer to the below links:
https://blogs.oracle.com/jeffdavies/entry/restful_services_with_oracle_s_1
https://blogs.oracle.com/jamesbayer/entry/using_rest_with_oracle_service
Hope this helps.
Thanks,
Patrick -
Conditional call to a subscreen in module pool program.
Hi,
Could anybody please let me know how i will be able to call a subscreen conditionally in a module pool program?
Example: I have to call a subscreen XXXX if a FLAG = X. How will I achieve this?
I tried to write the below code in PAI
if flag = 'X'.
call subscreen XXXX.
endif.
This produced an error.
Regards,
SmitheshHi
In TOP Include
data repid type sy-repid,
dynnr type sy-dynnr.
In PBO of main screen
module status_100. " First Call This Module to provide the SubScreen Number to below Code
call subscreen sub including repid dynnr. " This serves the purpose of calling subscreen based on condition
in Program.
module status_100.
repid = sy-repid.
if your_condition = 'X'. " This also can be implemented in any PAI logi as its purpose is just to pass a value to DYNNR
dynnr = '200'. " The SUB Screen Number you want to pass
else.
dynnr = '300'. " Dummy Sub Screen Screen or any other (Make Sure these are of SUB SCREEN type )
endif.
endmodule
Cheerz
Ram -
Calling a restful web service from a script task
Hi. I'm weak in c# but am looking to accomplish this...
I want to call a RESTful web service from an ssis script task. I don't want to create a web service so I'm hoping there is some publicly available one I can practice with before our web team provides me with the service I'll eventually use. Can
the community provide an example? I wish I had more but my knowledge is very limited except for using ssis in more sql centric apps. It would be great if I could exercise both a get and put verb but I understand i'll be lucky if I can even get
a get to work.
Here is an example of a get I found on the web but I don't know if its a viable candidate for me to practice with from my package...
using System;
using System.IO;
using System.Net;
using System.Text;
// Create the web request
HttpWebRequest request = WebRequest.Create("http://developer.yahoo.com/") as HttpWebRequest;
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
Console.WriteLine(reader.ReadToEnd());
and in the same article an example of a put ...
// We use the HttpUtility class from the System.Web namespace
using System.Web;
Uri address = new Uri("http://api.search.yahoo.com/ContentAnalysisService/V1/termExtraction");
// Create the web request
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
// Set type to POST
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
// Create the data we want to send
string appId = "YahooDemo";
string context = "Italian sculptors and painters of the renaissance"
+ "favored the Virgin Mary for inspiration";
string query = "madonna";
StringBuilder data = new StringBuilder();
data.Append("appid=" + HttpUtility.UrlEncode(appId));
data.Append("&context=" + HttpUtility.UrlEncode(context));
data.Append("&query=" + HttpUtility.UrlEncode(query));
// Create a byte array of the data we want to send
byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
// Set the content length in the request headers
request.ContentLength = byteData.Length;
// Write data
using (Stream postStream = request.GetRequestStream())
postStream.Write(byteData, 0, byteData.Length);
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
Console.WriteLine(reader.ReadToEnd());
Hi
db042190,
These kinds of operations are commonly found outside the SSIS section of the forum, you just need to "borrow" the code and wrap into the Script Task. And based on what you see you are on the right tracks.
One thing you need to be aware of: in production such RESTfull call usually lead to a fiasco for the machine residing in some kind of DMZ or Firewall rules prohibiting these methods or you need a proxy account to run the package and you face unbeggable admins
who resist to relaxing security.
My suggestion is to go the easy route: write the app up as a console, standalone app - it will be easier to debug and there will be complete examples of them in abundance on the web.
Arthur
MyBlog
Twitter -
[OSB1031] how to call a RESTful service from OSB with authentication
Hi all,
I called successfully a RESTful service from OSB.
We have a business service, named OrderTracer, that wraps the call to the RESTful service.
The RESTful service requires an authentication so we are trying to find out how the OSB business service should authenticate itself against the RESTful service.
In addition the RESTful service accepts username/password coded as base64.
So we defined a Service Account with static resource type and we added the reference to this service account in the business service.
But when the OSB business service calls the RESTful service, we got an error:
<fault>
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>BEA-380000</con:errorCode>
<con:reason>Unauthorized</con:reason>
<con:location>
<con:node>RouteNode</con:node>
<con:path>response-pipeline</con:path>
</con:location>
</con:fault>
</fault>
Does anyone have any hint ?
Any clue would be of great help.
Thanks in advance
ferpHi,
There's a sample on JSON REST here...
http://java.net/projects/oraclesoasuite11g/downloads/download/OSB/osb-206-JSONREST.zip
For other samples, see this...
http://java.net/projects/oraclesoasuite11g/pages/OSB
Cheers,
Vlad -
Calling the smartform based on checkbox selection in ALV
Hi
i displayed the report output in ALV using 'REUSE_ALV_GRID_DISPLAY'. I maintained checkboxes as first column of data.
and i also added three user defined buttons like check,uncheck,print form. Now my problem is when user selecting the records in ALV using the checkbox,i have to call the smartform based up on user selection of check box.i done but it is coming only for one checkbox.if we select multiple checkboxes it is not coming.but i need smartform has to call for every checkbox user has selected.
can u suggest on this.all my data in internal table i_data with checkbox field. i'm copying my code here.
LOOP AT I_DATA.
READ TABLE I_DATA INTO WA_DATA INDEX FU_SELFIELD-TABINDEX.
WA_DATA-SEL = 'X'.
MODIFY I_DATA FROM WA_DATA TRANSPORTING SEL.
FU_SELFIELD-REFRESH = 'X'.
MOVE-CORRESPONDING WA_DATA TO WA_PRINT.
APPEND WA_PRINT TO I_PRINT.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZHRF1_PTAR1001'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
* EXCEPTIONS
* NO_FORM = 1
* NO_FUNCTION_MODULE = 2
* OTHERS = 3
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 FUNCTION FM_NAME
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
* CONTROL_PARAMETERS =
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
* OUTPUT_OPTIONS =
* USER_SETTINGS = 'X'
FR_DATE = PN-BEGDA
TO_DATE = PN-ENDDA
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
TABLES
ITAB = I_PRINT
* EXCEPTIONS
* FORMATTING_ERROR = 1
* INTERNAL_ERROR = 2
* SEND_ERROR = 3
* USER_CANCELED = 4
* OTHERS = 5
IF SY-SUBRC 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
ENDCASE.
Moderator Message: Duplicate post locked. Continue with your previous thread.
Edited by: Suhas Saha on Dec 27, 2011 9:17 AMHI arjun,
according to you code,
READ TABLE I_DATA INTO WA_DATA INDEX FU_SELFIELD-TABINDEX.
the fu_selfield-tabindex contains only one number , so its trigger only one check box, it is not correct to loop i_data .
take the records which are checked and loop that internal table , using check_changed_data u can select multiple records which are checked.
one importent thing , use sy-subrc after read statement bcz see example
in second loop if the read statement has failed but the work area contains the data , so beware check sy-subrc= 0 . after read.
debug your program and check every time FU_SELFIELD-TABINDEX will be same . so reads same record so many time how many times the loop had.
instead do like this
loop at i_data into wa_data where check = 'x'.
MOVE-CORRESPONDING WA_DATA TO WA_PRINT.
endloop.
Regards
Siva -
Can I create JDE BSSV (Business Services) for REST based services?
Can I create JDE BSSV (Business Services) for REST based services? If yes, then how? In what way it will be different from SOAP based?
Hi
Within Oracle SOA Suite, Oracle Service Bus would handle the REST side of things, which in turn would call the JCA adapter to talk to your JDE backend, or vice versa.
Checkout the JDE adapter docs - http://www.oracle.com/technetwork/middleware/soasuite/documentation/jdewardsweb-1954164.pdf
and the OSB Docs - HTTP and Poller Transports - 11g Release 1 (11.1.1.7)
OSB 11.1.1.7 introduced additional REST support, so I'd recommend using that version onwards.
Cheers
iain -
[OSB1031] how to call a RESTful service from OSB
Hi all,
I need to call a RESTful service from OSB.
The RESTful URL service is http://xxx.xxx.xxx.xxx/api/ordertracer and has been implemented in IIS.
The service accepts a xml string message as input and returns an HttpStatusCode.
So I started defining a business service (named OrderTracer):
Service Type: Any XML Service
Endpoint URI: http://xxx.xxx.xxx.xxx/api/ordertracer
HTTP Request Method:POST
Or should I define instead a business service (named OrderTracer2) as following ?
Service Type = Messaging Service
Request Message Type = None
Response Message Type = Text
Endpoint URI: http://xxx.xxx.xxx.xxx/api/ordertracer
HTTP Request Method:POST
When I try to test the business service (the first one named OrderTracer) from OSB test console I got an error:
<con:metadata xmlns:con="http://www.bea.com/wli/sb/test/config">
<tran:headers xsi:type="http:HttpResponseHeaders" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:tran="http://www.bea.com/wli/sb/transports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<http:Connection>close</http:Connection>
<http:Content-Length>315</http:Content-Length>
<http:Content-Type>text/html; charset=us-ascii</http:Content-Type>
<http:Date>Wed, 03 Oct 2012 14:26:39 GMT</http:Date>
<http:Server>Microsoft-HTTPAPI/2.0</http:Server>
</tran:headers>
<tran:response-code xmlns:tran="http://www.bea.com/wli/sb/transports">3</tran:response-code>
<tran:response-message xmlns:tran="http://www.bea.com/wli/sb/transports">Not Found</tran:response-message>
<tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">us-ascii</tran:encoding>
<http:http-response-code xmlns:http="http://www.bea.com/wli/sb/transports/http">404</http:http-response-code>
</con:metadata>
Could I test that RESTful service from business service test console or should I test it from a service callout within a proxy service ?
Thanks in advance for any hints!
ferpHi,
There's a sample on JSON REST here...
http://java.net/projects/oraclesoasuite11g/downloads/download/OSB/osb-206-JSONREST.zip
For other samples, see this...
http://java.net/projects/oraclesoasuite11g/pages/OSB
Cheers,
Vlad -
Consuming a rest based srevices in abap
I am trying to consume a rest based servises in abap using the cl_rest_http_client class.
i was just trying to call a simple get method but it resulted in a responce "HTTP client - communication error".
when i use the same url from the restClient (Firefox extension it works)
I have checked some blogs which talk about consuming rest srevices. most of them have a pre requisite to importing the security certificate of the service provider using the "strust" transaction.
Since i dont have authorization for that transaction, i was wondering if it is possible to call a rest service without importing the certificate.
Kidly suggest ways in which i can overcome this
Thanks and regards,
SauravIt is not possible to make an HTTPS request without importing the certificate.
It works fine with HTTP request but for HTTPS we need to import the certificate and pass the SSL id. -
Hi All,
I have JSON web services , I am using script component to fetch data from Webservice to sql server table.
The code is working fine, if I am using sample JSON Webservice .
http://www.geoplugin.net/json.gp?jsoncallback . But when I am using HTTPS:URL , it is giving below error .
[Error Getting Data From Webservice!] Error: System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
Thanks in Advance..Hi BHVS,
According to the error message, the issue is that the certificate you are using in your web server, or the certificate in the server exposing the service you are consuming, are not issued by a trustworthy authority.
To overcome this error, we need to install the correct certificate that is used by the web service provider in the server that will be calling the web service.
For more details, please refer to the following blog:
http://www.outsystems.com/forums/discussion/5690/web-services-could-not-establish-trust-relationship-for-the-ssl-tls/
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Maybe you are looking for
-
Photo Sharing in Separate User Profiles
I have created separate user profiles for my wife and me on our new iMac. I'm returning to Mac after time away, and I cannot remember whether there is a way for us to share the same photos in each separate profile. Thoughts?
-
Two ForeignKey to define in the same table
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; public class CustomerBase public CustomerBase() this.Payments = new List<PaymentBase>(); this.Documents =
-
11.1.4 and 11.1.5 not working in windows 7 64bit
I updated to 11.1.4 and experienced the same problems as many others- uninstalling and re installing eradicated the error messages but the store never opened and my phone would not sync. I've up graded to 11.1.5 and now it is freezing, crashing- incl
-
How can I learn about SAP BW?
Hello, I need to work with it and will have access to it soon, what is the best wey to go about learning about it?
-
How do I change my App Store back to UK? Every thing is in dollars as it asked me to swap to US when I was browsing an American tv show.