ATG REST Webservices - XML response
Hi,
I need to build an ATG REST component which returns the response in XML format and it is done.
The question that I have here is that, in the XML response, the response XML that I exactly want is embedded inside <atgResponse>..</atgresponse> tag.
For ex:
The actual response that I need in the client side.
<address>
<address1>123 Main st</address1>
<address2>Apt 12</address2>
<city>Attleboro</city>
<state>MA</state>
<zip>02073</zip>
</address>
The response that I am getting back from my REST component:
<atgResponse>
<address>
<address1>123 Main st</address1>
<address2>Apt 12</address2>
<city>Attleboro</city>
<state>MA</state>
<zip>02073</zip>
</address>
</atgResponse>
Do I need to handle the logic of taking the xml that I needed from the XML response that is coming from my REST component, in the client side only?
The other concern that I have is, I do not want my client application to know that I am using ATG REST services.
Appreciate any help in this.
Thanks in advance,
Gopinath Ramasamy
I have not tried it but I would probably try to extend XMLOutputCustomizer and override sendToOutputStream(Object pDocument, DynamoHttpServletResponse pResponse) method as per the requirement. Here pDocument would actually be an instance of org.dom4j.Document so you can access and update its root element. You can also process other output elements as well by iterating through the elements and when done write the Document object through org.dom4j.Document to XMLWriter. Something like below:
Document doc = (Document)pDocument;
//process Document object
org.dom4j.io.XMLWriter writer = new org.dom4j.io.XMLWriter(pResponse.getWriter(), createDefaultOutputFormat());
writer.write(doc)Override the default /atg/rest/output/XMLOutputCustomizer configuration to refer your class and see if it serves your purpose.
API reference for XMLOutputCustomizer:
http://docs.oracle.com/cd/E24152_01/Platform.10-1/apidoc/atg/rest/output/XMLOutputCustomizer.html
Similar Messages
-
Error while bringing up ATG REST Webservice
Hi,
I am trying to bring a REST Webservice using ATG 9.3 version.I am getting the below errors in the startup of the instance.I have added "REST" module in the Manifest file and am able to see the entry " C:\ATG\ATG9.3\REST\config\config.jar" in CONFIGPATH(Please let me know if there are other ways to find if the service has come up properly).I am trying to connect to the server using JAVA based REST Client as given below.Also,i have placed the jar files in the CLASSPATH of the module.I am hoping that the webservice have not come up properly because of these startup errors.Please help me out to resolve this issue.
STARTUP EXCEPTION SEEN IN SERVER
========================
2012-06-25 06:20:36,815 INFO [STDOUT] Unable to create class atg.rest.servlet.HeadRestServlet for configuration /atg/dynamo/servlet/dafpipeline/HeadRestServlet java.lang.ClassNotFoundException: No ClassLoaders found for: atg.rest.servlet.HeadRestServlet
2012-06-25 06:21:56,325 INFO [nucleusNamespace.atg.userprofiling.sso.PassportAuthorityService] Starting passport authority service
2012-06-25 06:21:56,460 INFO [STDOUT] **** Error
2012-06-25 06:21:56,460 INFO [STDOUT]
2012-06-25 06:21:56,460 INFO [STDOUT] Mon Jun 25 06:21:56 EDT 2012
2012-06-25 06:21:56,460 INFO [STDOUT]
2012-06-25 06:21:56,460 INFO [STDOUT] 1340619716460
2012-06-25 06:21:56,460 INFO [STDOUT]
2012-06-25 06:21:56,460 INFO [STDOUT] /
2012-06-25 06:21:56,460 INFO [STDOUT]
2012-06-25 06:21:56,460 INFO [STDOUT] Unable to set configured property "/atg/dynamo/servlet/Initial.initialServices" atg.nucleus.ConfigurationException: Unable to resolve component /atg/dynamo/servlet/dafpipeline/HeadRestServlet
2012-06-25 06:22:06,528 INFO [STDOUT] Unable to create class atg.rest.RestConfiguration for configuration /atg/rest/Configuration java.lang.ClassNotFoundException: No ClassLoaders found for: atg.rest.RestConfiguration
2012-06-25 06:22:06,528 INFO [STDOUT] **** Error
2012-06-25 06:22:06,528 INFO [STDOUT]
2012-06-25 06:22:06,528 INFO [STDOUT] Mon Jun 25 06:22:06 EDT 2012
2012-06-25 06:22:06,528 INFO [STDOUT]
2012-06-25 06:22:06,528 INFO [STDOUT] 1340619726528
2012-06-25 06:22:06,528 INFO [STDOUT]
2012-06-25 06:22:06,528 INFO [STDOUT] /
2012-06-25 06:22:06,528 INFO [STDOUT]
2012-06-25 06:22:06,528 INFO [STDOUT] Unable to set configured property "/atg/rest/Initial.initialServices" atg.nucleus.ConfigurationException: Unable to resolve component /atg/rest/Configuration
CLASSPATH ENTRY
============
<classpathentry exported="true" kind="var" path="C:/ATG/ATG9.3/REST/lib/atg-rest-1.0.jar"/>
<classpathentry exported="true" kind="var" path="C:/ATG/ATG9.3/REST/lib/commons-fileupload-1.2.1.jar"/>
<classpathentry exported="true" kind="var" path="C:/ATG/ATG9.3/REST/lib/commons-io-1.4.jar"/>
<classpathentry exported="true" kind="var" path="C:/ATG/ATG9.3/REST/lib/dom4j-1.6.1.jar"/>
<classpathentry exported="true" kind="var" path="C:/ATG/ATG9.3/REST/lib/log4j-1.2.15.jar"/>
<classpathentry exported="true" kind="var" path="C:/ATG/ATG9.3/REST/client-lib/java/atg-rest-client-1.0.jar"/>
REST CLIENT:
========
import java.util.HashMap;
import java.util.Map;
import atg.rest.client.RestClientException;
import atg.rest.client.RestComponentHelper;
import atg.rest.client.RestResult;
import atg.rest.client.RestSession;
public class RestClient {
RestSession mSession;
protected void execute() throws RestClientException {
System.out.println("inside execute");
mSession = RestSession.createSession("localhost", 8080, "<USERNAME>", "<PASSWORD>");
mSession.setUseHttpsForLogin(false);
try {
mSession.login();
System.out.println("Login Successful");
catch (Throwable t) {
System.out.println(t);
finally {
try {
mSession.logout();
System.out.println("Logout Successful");
catch (RestClientException e) {
System.out.println(e);
* @param args
public static void main(String[] args) {
System.out.println("inside main");
// TODO Auto-generated method stub
RestClient testATGRest = new RestClient();
try {
testATGRest.execute();
catch (Throwable t) {
System.out.println(t);
REST CLIENT ERROR SEEN:
=================
atg.rest.client.RestClientException: java.io.IOException: Not Found http://localhost:8080/rest/bean/atg/userprofiling/ProfileServices/loginUser
atg.rest.client.RestClientException: This session is not logged in and cannot be logged outI am trying to expose a method using REST Webservice and access the method using the browser.I have followed the steps specified in the thread:
http://ecomwriter.com/2012/03/19/building-restful-web-services-using-atg/ .Have added a component called ProfileRESTWebservice and have defined a method “getLoginInfo” in the class file. The following entry is placed in the restSecurityConfiguration.xml
<resource component="/atg/userprofiling/ProfileRESTWebservice" secure="true">
<method name="getLoginInfo" secure="false"></method>
</resource>
But, I am receiving the following exception when trying to access the method using http://localhost:8080/rest/bean/atg/userprofiling/ProfileRESTWebservice/getLoginInfo
10:07:33,147 ERROR [BeanServlet] Error code: 400
atg.beans.PropertyNotFoundException: Can't find property named: getLoginInfo in class: com.vs.commerce.profile.ProfileRESTWebservice
Can't find property named: getLoginInfo in class: com.vs.commerce.profile.ProfileRESTWebservice
atg.rest.RestException: atg.beans.PropertyNotFoundException: Can't find property named: getLoginInfo in class: com.vs.commerce.profile.ProfileRESTWebservice
at atg.rest.output.RestOutputCustomizerImpl.outputBeanProperty(RestOutputCustomizerImpl.java:616)
at atg.rest.processor.BeanProcessor.doRESTGet(BeanProcessor.java:157)
at atg.rest.servlet.RestPipelineServlet.serviceRESTRequest(RestPipelineServlet.java:394)
at atg.rest.servlet.RestPipelineServlet.service(RestPipelineServlet.java:237)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.pipeline.PipelineableServletImpl.service(PipelineableServletImpl.java:298)
at atg.rest.servlet.RestPipelineServlet.service(RestPipelineServlet.java:241)
Can you pl help me out on this? -
Not able to print anything on ATG Rest webservices
Hi..I am new to ATG Rest.. Just for the heads up, i followed following steps :-
1 ) Added rest module to MANIFEST.MF
2) Created a custom class which looks like this -
package com.sgs.utils;
import atg.nucleus.GenericService;
public class SGSdummy extends GenericService {
public void dummy() throws Exception {
logDebug("sdbfhj");
3) Mapped it to the property file -
$class=com.sgs.utils.SGSdummy
$scope=global
loggingInfo=true
4) Configured the security for above component in restSecurityConfiguration.xml
<rest-security>
<resource component="/atg/commerce/order/dummy" secure="false">
<!-- <default-acl value="Profile$role$admin:read,write,execute"/> -->
<method name="dummy" secure="false"/>
</resource>
</rest-security>
I commented acl as i really didn't need it for a POC plus it was throwing 401 unauthorized.
5) Now I am calling it from chrome's Advanced Rest Client. However, status is 200 OK but I am not able to print a logDebug or sysout in my SGSdummy class.
When i check console, it says "Depth 0 is greater than maximum depth 0"
I tried to change maxDepthAllowed in configuration.properties but in vain..I need help to proceed.Now I am trying to create a REST request using custom client. I believe it should be a POST request as I am trying to call a method. My custom client looks like this :-
package atg.rest.client;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import atg.rest.client.RestClientException;
import atg.rest.client.RestComponentHelper;
import atg.rest.client.RestResult;
import atg.rest.client.RestSession;
public class RestDemoClient {
/** The m username. */
private String mUsername;
/** The m password. */
private String mPassword;
/** The m host. */
private String mHost;
/** The m port. */
private int mPort;
/** The m session. */
private RestSession mSession = null;
* Instantiates a new method call by rest.
public RestDemoClient() {
* Execute.
* @throws RestClientException the rest client exception
private void execute() {
mSession = RestSession
.createSession(mHost, mPort, mUsername, mPassword);
mSession.setUseHttpsForLogin(false);
Map<String,Object> params = new HashMap<String,Object>();
params.put("atg-rest-input", "json");
RestResult result = null;
try {
result = RestComponentHelper.executeMethod("/atg/rest/SGSdummy", "addOrder", new
Object[] {}, params, mSession);
} catch (RestClientException e1) {
System.out.println(e1);
try {
if (result != null && result.getResponseCode() == 200) {
System.out.println("Executed Successfully.");
} else {
System.out
.println("Error while execution : Error Code ["
+ result.getResponseCode()
+ "] and Message ["
+ result.getResponseMessage() + "]");
} catch (IOException e) {
System.out.println("Error while execution Successfully.");
* @param args
public static void main(String[] args) {
RestDemoClient stepUtils = new RestDemoClient();
stepUtils.mUsername = "admin";
stepUtils.mPassword = "admin";
stepUtils.mHost = "localhost";
stepUtils.mPort = 8080;
stepUtils.execute();
But everytime i execute this, I get following exception :-
atg.rest.client.RestClientException: java.io.IOException: Unauthorized Server returned HTTP response code: 401 for URL: http://localhost:8080/rest/bean/atg/rest/SGSdummy/addOrder
Exception in thread "main" java.lang.NullPointerException
at atg.rest.client.RestDemoClient.execute(RestDemoClient.java:64)
at atg.rest.client.RestDemoClient.main(RestDemoClient.java:82)
I tried different set of credentials but nothing seems to work out for me.
However it always works fine for GET requests. I am able to see status as 200 OK but it never hits my addOrder() method in SGSdummy class, hence I am not able to print sysout in that method. For status 200 OK GET requests, my logs say "[JSONOutputCustomizer] Depth 0 is greater than maximum depth 0. Outputting object of class java.lang.String as string rather than continuing to nest."
Can you give me some pointers how to run it without any errors plus it should print a random sysout in my custom class. Thanks -
Access ATG REST webservices from javascript..?
Hi All,
Can we access ATG REST web services from Javascript/jQuery..? If yes, then how..?
Thanks,
VishnuHi Nitin, I'm able to access /atg/dynamo/Configuration component's properties using REST services from following code -
*/atg/rest/security/restSecurityConfiguration.xml*
<resource component="/rest/bean/atg/dynamo/Configuration">
<default-acl value="[email protected]:read,write,execute"/>
<property name="httpPort" secure="false"/>
</resource>
client Java code :
public class RestClientRequest {
public static void main(String[] args) {
RestSession mSession = RestSession.createSession("localhost", 8180, "[email protected]", "chinna");
mSession.setUseHttpsForLogin(false);
try{
String loginStatus = mSession.login();
if(loginStatus == null || "null".equals(loginStatus)){
mSession=null;
System.out.println("Login failed");
else{
RestResult result = RestComponentHelper.getPropertyValue("/atg/dynamo/Configuration", "httpPort", null, mSession);
String test = result.readInputStream();
System.out.println("\n\n"+result.readInputStream());
but getting exception when i try to get repository item using the below code
<rest-security>
<resource component="/rest/repository/atg/commerce/catalog/ProductCatalog">
<default-acl>[email protected]:read,write,execute"</default-acl>
</resource>
</rest-security>
Client Java code:
public class RestClientRequest {
public static void main(String[] args) {
RestSession mSession = RestSession.createSession("localhost", 8180, "[email protected]", "chinna");
mSession.setUseHttpsForLogin(false);
try{
String loginStatus = mSession.login();
if(loginStatus == null || "null".equals(loginStatus)){
mSession=null;
System.out.println("Login failed");
else{
RestResult result = RestResult result = RestRepositoryHelper.getItems("/atg/commerce/catalog/ProductCatalog", "product", null, mSession);
String test = result.readInputStream();
System.out.println("\n\n"+result.readInputStream());
Exception :
Login successful
Login Status : ATG3990000
atg.rest.client.RestClientException: java.io.IOException: Unauthorized Server returned HTTP response code: 401 for URL: http://localhost:8180/rest/repository/atg/commerce/catalog/ProductCatalog/product
at atg.rest.client.RestSession.createHttpRequest(RestSession.java:755)
at atg.rest.client.RestSession.createHttpRequest(RestSession.java:722)
at atg.rest.client.RestRepositoryHelper.getItems(RestRepositoryHelper.java:188)
at in.vcarve.RestClientRequest.main(RestClientRequest.java:26)
Caused by: java.io.IOException: Unauthorized Server returned HTTP response code: 401 for URL: http://localhost:8180/rest/repository/atg/commerce/catalog/ProductCatalog/product
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at atg.rest.client.RestSession.createHttpRequest(RestSession.java:745)
... 3 more
Thanks,
Vishnu -
How to populate the webservice XML data in to Table ODI- Webserice invoke
Hi,
I have multiple work orders in my oracle db table, That means multiple WorkOrder_Item_ID's are there in my source table. When I start transfer the data from source to Target using ODI , I need to get the information of multiple Work order Item_IDs from the Webservice response data ( XML data) of another system by calling ODI Webservice Invoke in ODI and insert the same Webservice XML response data in my source table in the corresponding Item_ID's.
My First question : How can I take the data from Webservice XML and put in to correspoding Item relevent data in to Source Table
Second question: How can I send the multiple work order item ID at the same time to the Webservice and insert the relevant item data in to Source table using ODI.
Finally this combined soure table data should be moved to Target table in ODI.. That I know.. How to do it.
Can any one please give answers for the above said two questions.
Thanks,
Rajesh
Edited by: user11226287 on Oct 30, 2009 4:40 AM
Edited by: user11226287 on Nov 1, 2009 10:44 PM
Edited by: user11226287 on Nov 1, 2009 10:59 PMI find some words in the implementation guide, it says:"To collect data from your non-Oracle ERP systems or your trading partners' systems,you model each non-Oracle ERP system or trading partner as an Oracle Applications organization and store their setup and transaction data there".
But I can't find where to model the application organization for the legacy system.
anyone can give some clues? Thanks in advance. -
I am using something like this as input to an ATG rest webservice which does validation with an array input.
But i am not sure how to receive it in a formhandler especially from request.
{'atg-rest-param-class-types':{'container-class':
'java.util.ArrayList','element-class':
'java.lang.String'},'arg1':['sit','stay','speak']}
Pls help.
Should i use JSON input customizer?Hi,
By receiving you mean you want to receive the output of this request which is in the form an array. In this case you can use atg-rest-output and type should be JSON. The output will parse itself into JSON. You'll not need Output Customizer for this.
Regards,
RahulV -
XML payload in RESTful webservice
Hi all,
Can anyone please suggest on how to call the RESTful webservice (which is used by our client) by passing an XML payload from a PL SQL stored procedure? It is for the authentication purpose. And the username and password has to be passed as the XML payload to the RESTful webservice . Please help, it's a bit urgent.
Thanks in advance
Geethu
Edited by: 982489 on Mar 22, 2013 3:02 AMHi all,
Can anyone please suggest on how to call the RESTful webservice (which is used by our client) by passing an XML payload from a PL SQL stored procedure? It is for the authentication purpose. And the username and password has to be passed as the XML payload to the RESTful webservice . Please help, it's a bit urgent.
Thanks in advance
Geethu
Edited by: 982489 on Mar 22, 2013 3:02 AM -
Getting error response while trying to access REST webservice through Powerbuilder
Hi Team,
I am trying to access a rest webservice through powerbuilder 12.5(.net).The rest webservice is secured through basic authentication.I am passing the userid and password through powerbuilder to acess the service,But its returning an error .But while i am trying to accss the same REST webservice through SOAPUI, i am able to get the response.
Please find the below line of code which i have written in powerbuilder.
p_testcleint2 lp_rest
string ls_string
lp_rest=create p_testcleint2
PBWebHttp.WebClientCredential lsCredential //configure credentials
lsCredential = create PBWebHttp.WebClientCredential
lsCredential.AccessAuthentication = PBWebHttp.AuthenticationMode.Basic!
lsCredential.Password='Pa$$word1!'
lsCredential.Username='admin'
lp_rest.restConnectionObject.ClientCredential = lsCredential //add credentials to connection
try
lp_rest.PostMessage()
catch (System.Exception ee)
messagebox("Failure",string(ee.Message))
end try
Error i am getting as below :
The remote server returned an error:(401) unauthorized.
Can you please let me know why this error is coming or do i need to any extra paramert in the lsCredential to handle this.
Thanks in advance.
Regards
SubratHi Chris,
Thanks for the reply.
Yes i checked -in fiddler, the basic authentication request is not generating in the fiddler.
In the same Rest service if i turned off the basic authentication then call is happening in Powerbuilder and its displaying in fiddler also.
Regards
Subrat -
Invalid request when calling REST-webservice with UTL_HTTP.
Hello,
When i try to send some data to a REST-webservice i get as response "INVALID REQUEST"
I Think it is about the request-body that seems to be no UTF-8.
I tried to set the characterset with utl_http.set_body_charset(t_http_req, 'UTF-8').
But when i read the characterset with utl_http.get_body_charset(t_charset);, is still get "ISO-8859-1"
I am using: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
Some help would realy be appreciated because i am out of options trying to get the code working..
======MY CODE==========
create or replace procedure ipm40_send_bekendmaking(p_bdmg_id in number)
as
r_bekendmaking ipm40_bekendmakingen%rowtype;
r_gemeente ipm40_gemeenten%rowtype;
l_url httpuritype;
t_http_req utl_http.req;
t_http_resp utl_http.resp;
t_request_body varchar2(32767);
t_respond varchar2(32767);
-- t_teller integer := 1;
-- t_output varchar2(2000);
t_start number := 1;
t_body_lengte number;
t_chunkdata varchar2(4000);
t_tijd_1 varchar2(256);
t_tijd_2 varchar2(256);
t_timeout integer;
t_length number;
t_charset varchar2(256);
begin
select *
into r_bekendmaking
from ipm40_bekendmakingen
where id = p_bdmg_id;
select *
into r_gemeente
from ipm40_gemeenten
where gmte_code = r_bekendmaking.gmte_code;
l_url := httpuritype.createuri('http://zwolle.stadsbeheer.com:82/apex/ipm40bekendmaking?p_bdmg_id='||r_bekendmaking.id);
t_request_body := l_url.getClob();
/* request that exceptions are raised for error Status Codes */
--Utl_Http.Set_Response_Error_Check ( enable => true );
/* allow testing for exceptions like Utl_Http.Http_Server_Error */
--Utl_Http.Set_Detailed_Excp_Support ( enable => true );
utl_http.set_transfer_timeout(300);
t_http_req:= utl_http.begin_request( r_gemeente.url_webservice_bekendmakingen
, 'POST'
, 'HTTP/1.1');
utl_http.set_body_charset(t_http_req, 'UTF-8');
utl_http.get_body_charset(t_charset);
utl_http.set_authentication(t_http_req,r_gemeente.user_webservice_bekendmakingen,r_gemeente.pw_webservice_bekendmakingen);
t_length := length(t_request_body);
utl_http.set_header(t_http_req, 'Content-Type', 'application/xml charset=UTF-8');
utl_http.set_header(t_http_req, 'Content-Length', t_length);
utl_http.set_header(t_http_req, 'Transfer-Encoding', 'chunked' ); --
t_body_lengte := dbms_lob.getlength(t_request_body);
loop
t_chunkdata := dbms_lob.substr(t_request_body, 2000, t_start);
utl_http.write_text ( t_http_req, t_chunkdata );
t_start := t_start + 2000;
if t_start > t_body_lengte
then
exit;
end if;
end loop;
t_http_resp:= utl_http.get_response(t_http_req);
utl_http.read_text(t_http_resp, t_respond);
utl_http.end_response(t_http_resp);
if instr(t_respond,'Successfully document processed') != 0
then
update ipm40_bekendmakingen
set ind_status = 'S'
, datum_verzonden = sysdate
, response = t_respond
where id = r_bekendmaking.id;
else
update ipm40_bekendmakingen
set ind_status = 'F'
, datum_verzonden = null
, response = t_respond
where id = r_bekendmaking.id ;
end if;
commit;
exception
when others
then
t_tijd_2 := to_char(sysdate,'HH24:MI:SS');
t_respond := substr(sqlerrm,1,2000);
update ipm40_bekendmakingen
set ind_status = 'F'
, datum_verzonden = null
, response = t_respond
where id = r_bekendmaking.id ;
commit;
end;
===THE RESPOND=============
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to process the request:
<PRE>
POST /pushxml/pushxml-bm HTTP/1.0
Authorization: Basic Ymtfc21hcnRob2xkaW5nOllyZXMzdlFR
Content-Type: application/xml charset=UTF-8
Content-Length: 2096
Transfer-Encoding: chunked
Connection: close
</PRE>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Invalid Request
</STRONG>
</UL>
<P>
Some aspect of the HTTP Request is invalid. Possible problems:
<UL>
<LI>Missing or unknown request method
<LI>Missing URL
<LI>Missing HTTP Identifier (HTTP/1.0)
<LI>Request is too large
<LI>Content-Length missing for POST or PUT requests
<LI>Illegal character in hostname; underscores are not allowed
</UL>
<P>Your cache administrator is [email protected].
<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Fri, 12 Aug 2011 17:33:24 GMT by asd2cc001.asp4all.nl (squid)
</ADDRESS>
</BODY></HTML>Always check the access_log and error_log files of the Apache web server in such a case. This will identify whether the error comes from Apache itself, mod_plsql, the Apex run-time engine, or the Oracle database.
I see that you're creating a HTTP/1.1 in PL/SQL - however, the web server response indicates a HTTP/1.0 call was received. Unusual. And could be part of the problem. -
Create Document in RESTful webservice
Hi,
Anyone help me in java code
how to create a webi document using restful webservice?
My Code:
HttpPost httpRequest_create_doc = new HttpPost( "http://localhost:6405/biprws/raylight/v1/documents");
httpRequest_create_doc.setHeader("Accept","application/xml");
httpRequest_create_doc.setHeader("Content-Type","application/xml");
httpRequest_create_doc.setHeader("X-SAP-LogonToken", sLogonToken);
I am getting this response
HTTP/1.1 400 Bad Request [Server: Apache-Coyote/1.1, Date: Thu, 25 Sep 2014 12:12:19 GMT, Content-Type: application/xml, Content-Length: 135, Connection: close]
Regards,
kavitha SHi Bhushan,
Thanks for your information.I have added body.i am getting same response as
HTTP/1.1 400 Bad Request .
Help me if i done any wrong in my coding.
String docname="Sampledocument.xml";
String folder_id="1001";
String create_doc = "<documents><name>"+docname+"</name><folderId>"+folder_id+"</folderId></documents>";
HttpPost httpRequest_create_doc = new HttpPost( "http://localhost:6405/biprws/raylight/v1/documents");
httpRequest_create_doc.setHeader("Accept","application/xml");
httpRequest_create_doc.setHeader("Content-Type","application/xml");
httpRequest_create_doc.setHeader("X-SAP-LogonToken", sLogonToken);
httpRequest_create_doc.setEntity(new StringEntity(create_doc));
HttpClient httpclient = new DefaultHttpClient();
HttpResponse httpResponse= httpclient.execute(httpRequest_create_doc);
Regards,
kavitha S -
I am trying the below URL to get the WEBi report from SAP BO using the Rest Webservice support that is now available.
http://{serverIP:serverPort}/biprws/raylight/v1/documents/{documentId}
I am able to get the report but as I compare the same report response when using SAOP Webservice, there seems to be a mismatch in the response. Here is what I see in the SOAP response:
</td><td c="1" ><cell ref="1.E.4t" bid="14" h="26" w="231" pad="6,7" sid="-10"><ct >Some arbitrary value</ct><value type="xs:string">Some arbitrary value</value></cell>
But when I run it through REST, I am missing the <value ..> tag:
</td><td c="1" ><cell ref="1.E.4t" bid="14" h="26" w="231" pad="6,7" bt="1" sid="-10"><ct >Some arbitrary value</ct></cell>
Apart from this right at the start of the xml response, I see some property mismatch as well.
SOAP has this property extra:
<property name="output.format.xml.valuemode">yes</property>
While REST has these property extra:
<property name="output.format.xml.option.style">1</property>
<property name="output.format.xml.styledict.fontplatform">html</property>
<property name="output.format.xml.td.bandinfo">yes</property>
<property name="source.selected">data</property>
<property name="xelement.xml.object">yes</property>
<property name="xelement.xml.object.usemap">yes</property>
<property name="xelement.xml.object.usersupportedformat">image/png</property>
I am not sure if:
the <value ...> tag miss is because of these missing/extra properties or
current REST support has some issues
For my application the value tag is a must and I can't do without this, but with REST it seems no way to obtain that.
Any help or pointer(s) in this regard is appreciated!Hello Milind,
According to our Product Owner Sam Polichouk, the solution should be available for you in 4.1 SP3, which is currently scheduled for release by the end of March 2014 (subject to change). The product team recommends that you get the raw, unformatted data values from within the Dataset specific call. This data contains a type to tell the end user what kind of data it is, so you can format it or use it properly.
The updated documentation for the SDK will be available at SAP BusinessObjects Business Intelligence platform 4.1 – SAP Help Portal Page once the Support Pack is publicly released. -
Hi All,
I’m having a hard time figuring out how to make Rest WebService calls.
I tried executing this directly through browser and I get an error.
http:localhost:8080/rest/bean/atg/userprofiling/ProfileServices/loginUser?arg1=[email protected]&arg2=Password
13:18:20,613 ERROR [RestSecurityServlet] Error code: 401
Access to the requested resource is not allowed: /atg/userprofiling/ProfileServices
atg.rest.RestException: Access to the requested resource is not allowed: /atg/userprofiling/ProfileServices
at atg.rest.processor.RestSecurityProcessor.checkAccess(RestSecurityProcessor.java:546)
at atg.rest.processor.RestSecurityProcessor.handleGetRequest(RestSecurityProcessor.java:313)
at atg.rest.processor.RestSecurityProcessor.doRESTGet(RestSecurityProcessor.java:199)
at atg.rest.servlet.RestPipelineServlet.serviceRESTRequest(RestPipelineServlet.java:417)
at atg.rest.servlet.RestPipelineServlet.service(RestPipelineServlet.java:260)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
at atg.servlet.pipeline.PipelineableServletImpl.service(PipelineableServletImpl.java:320)
at atg.rest.servlet.RestPipelineServlet.service(RestPipelineServlet.java:264)
at atg.rest.servlet.HeadRestServlet.service(HeadRestServlet.java:130)
at atg.servlet.pipeline.PipelineableServletImpl.service(PipelineableServletImpl.java:267)
From the documentation I understand that I need to create a session, is the session only necessary to access secured components since this
particular method “ProfileServices.loginUser “ has been declared as not secure in restSecurityConfiguration.xml
Also, are there two different ways in which I can log in
1. Using RestSession.createSession providing the username and password.
2. Or using ProfileServices.loginUser or ProfileFormHandler
Can someone please clarifyIf you are invoking the REST web-service from a Java client then you can create a RestSession object using the createSession method. But in your case you seem to be invoking it with a HTTP request which by default would be treated as a GET request by ATG's REST implementation. Therefore being a GET, it would try to fetch a property "loginUser" from /atg/userprofiling/ProfileServices component (based on your URL) which would always fail.
To invoke loginUser() method of ProfileServices with your passed argument you need to tell ATG's REST system to treat your incoming request not as GET but as a POST request which you can do using atg-rest-http-method control parameter in your request like this
http:localhost:8080/rest/bean/atg/userprofiling/ProfileServices/loginUser?arg1=[email protected]&arg2=Password&atg-rest-http-method=POST
It should work this way provided your restSecurityConfiguration.xml is proper. -
Not able to invoke ATG Rest services
Hi,
I'm new ATG Rest service, To just create a dummy rest service I followed the below steps.
1. added REST module in MANIFEST.MF file
ATG-Required: DAS DPS DSS DCS B2CCommerce DAS REST
2. created restSecurityCnfiguration.xml under atg/rest/seurity and following is the content of this file
<programlisting>
<rest-security>
<default-acl value="Profile$login$admin:read,write,execute" />
<resource component="/atg/service/TestComponent" secure="false"/>
</rest-security>
</programlisting>
3. Created a TestComponent in my existing application and created a method testName
public class TestComponent {
public String getTestName(){
return "arvind";
4. Deployed my application on jboss.
Now I'm trying to invoke this from a java class
protected void execute() throws RestClientException {
String mUsername = "admin";
String mPassword = "admin";
String mHost = "localhost";
int mPort = 8080;
RestSession mSession = null;
RestResult result = null;
mSession = RestSession.createSession(mHost, mPort, mUsername, mPassword);
mSession.setUseHttpsForLogin(false);
mSession.setUseInternalProfileForLogin(false);
try {
mSession.login();
println("Login Successful");
result = RestComponentHelper.executeMethod("/atg/service/TestComponent", "testName", new Object[] {}, null, mSession);
catch (Throwable t) {
println(t);
} finally {
try {
mSession.logout();
println("Logout Successful");
} catch (RestClientException e) {
println(e);
----------------------------------------------------------------------out put ---------------------------------------------
Login Successful
atg.rest.client.RestClientException: java.io.IOException: Unauthorized Server returned HTTP response code: 401 for URL: http://localhost:8080/rest/bean/atg/service/TestComponent/testName
at atg.rest.client.RestSession.createHttpRequest(RestSession.java:755)
at atg.rest.client.RestComponentHelper.executeMethod(RestComponentHelper.java:252)
at com.techm.restclient.RestClientSample.execute(RestClientSample.java:63)
at com.techm.restclient.RestClientSample.main(RestClientSample.java:87)
Caused by: java.io.IOException: Unauthorized Server returned HTTP response code: 401 for URL: http://localhost:8080/rest/bean/atg/service/TestComponent/testName
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at atg.rest.client.RestSession.createHttpRequest(RestSession.java:745)
... 3 more
Logout Successful
Even if I provide any username and password, which don't even exist, it says login succussful but while invocation it fails. Please help me here,
What is default user I can use? or way to create new user ?
Thanks in Advance,
Arvind
Edited by: Arvind Pal on Oct 4, 2012 10:21 AM
Edited by: Arvind Pal on Oct 4, 2012 10:22 AMI created a user through ACC, and made the following changes.
<programlisting>
<rest-security>
<default-acl value="Profile$login$arvind:read,write,execute" />
<resource component="/atg/service/TestComponent" secure="false"/>
</rest-security>
</programlisting>
and now I'm getting the loginStatus i.e userid of user "arvind".
But while executing the invocation of web service call I'm getting the same exception.
Do we need to give some permission somewhere for this user ? or I'm doing something wrong with restSecurityConfiguration.xml
Login status[390002]
Login Successful
atg.rest.client.RestClientException: java.io.IOException: Unauthorized Server returned HTTP response code: 401 for URL: http://localhost:8080/rest/bean/atg/service/TestComponent/getTestName
at atg.rest.client.RestSession.createHttpRequest(RestSession.java:755)
at atg.rest.client.RestSession.createHttpRequest(RestSession.java:722)
at atg.rest.client.RestComponentHelper.getPropertyValue(RestComponentHelper.java:182)
at com.techm.restclient.RestClientSample.execute(RestClientSample.java:98)
at com.techm.restclient.RestClientSample.main(RestClientSample.java:128)
Caused by: java.io.IOException: Unauthorized Server returned HTTP response code: 401 for URL: http://localhost:8080/rest/bean/atg/service/TestComponent/getTestName
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at atg.rest.client.RestSession.createHttpRequest(RestSession.java:745)
... 4 more
Logout Successful
Edited by: Arvind Pal on Oct 4, 2012 12:36 PM -
Consume a restful webservice using plsql
Hi
We need to consume a restful webservice and this needs to be implemented using plsql.
I know that we can use utl_dbws or utl_http to consume SOAP based web services but
there is not much information on how to consume restful web services.
kindly let me know if you have information.
Cheers
rigel851866 wrote:
Im looking for the opposite scenario where i need to access a restful web service from plsql.Why would a RESTful call be any different from a normal URL call? HTTP is the transport mechanism - and UTL_HTTP is used in PL/SQL as the client side of a HTTP conversation.
I posted sample code of a how to use PL/SQL as a brower client in {message:id=1925297} - using a pipeline table to demonstrate the contents returned by the web server in response using plain SQL.
Depending on what the contents is, you can write it into a BLOB (dealing with binary data returned), a CLOB (for XML data for example), or using varchar2 you can for example parse a text/csv response (no need for a pipeline in such a case).
The only real issue I can see with a RESTful service is URL construction - as the URL becomes "parameterised" and not just the query string itself, or the data contents (name values) in the POST structure. -
RESTful webservices invocation from OSB.
Can some one please explain the best way to develop the OSB service to invoke the Restful services.
1. Only proxy service is enough to handle the request, no need of business service?
2. when moving the code from one env to other, we use a business service to update endpoint url which is the common approach we generally follow, to make the osb service loosely coupled. how to use the business service when invoking the restservice? does we have the base uri value in the transport url and will get appended with the relative-uri value which we frame as part of the request in the outbound variable in the proxy settings?
3. when invoking the rest service do we need to append all the request message to the url itself or the request can be passed separately as request body and the main rest uri will have only the key fields as part of the relative-uri?
4. If we receive huge request message does the URL support the entire request?
5. how the response/error will be returned when calling the Restful webservice?
I am assuming this appraoch. Can some one please confirm does this approach works with RESTful service invocation from OSB.
Request processing:
Source System request-> Proxy Service -> Transformation to end system specific -> Business service (with base-uri -> http://mainappl.com/web/cmr/{relative-uri from outbound transport}) -> endsystem
Response processing:
endsystem Response/Error -> Business Service -> Proxy Service -> transformation to source system specific -> source system.
Please advice which is the best approach to follow while invoking the RESTful webservices from OSB.
Thanks..
Edited by: user12679330 on May 5, 2010 4:33 AM
Edited by: user12679330 on May 5, 2010 5:00 AMHi,
Thanks for the update. Can you please explain the above mentioned approach works or how it should be?
I have one requirement, can some one explain the implementation for this:
I have one element which is of type unbound. I need to map this element to a single enelement value by separating each element value with a ;, before that I need to check wheteher this element(s) are present in the request then need to appened all these element values to a single element and the end of this element need to append default values.
Scenario:
<student>
<name>asd</name>
<address>
<street>street1</street>
<street>street2</street>
<street>street3</street>
||
||
</address>
to be mapped it to:
<student>
<field name="NAME">asd</field>
<field name="ADDRESS">street1;street2;street3;default1;default2;default3</field>
</student>
Here need to check if street names are present in the request xml, if yes ned to assign it to ADDRESS as mentioned above if street names present or not need to append the default values at the end to the ADDRESS field.
Thanks in advance.
Maybe you are looking for
-
How to fetch attachments in workflows to Outlook
Dear colleagues, We have purchase requisition (PR) workflow in use and integration between SAP and Outlook; workflows are approved via Outlook or Blackberry. Now there is such a requirement that when a document is linked to PR by using service object
-
How i connect to my localhost machine to other database machine for sending
hi, in our organization lan is there. how should i pass the jdbc connection commands through java program to get the data from database from my system to other database system. here in my system there is no database. please provide the code for that.
-
Is Airport Extreme the right product for me?
Greetings, everyone: Currently, I have an iMac G4 connected to a DSL internet connection via an Ethernet cable on a Linksys router. The router also feeds 2 iBook G4s in the house, as well as a Windows laptop. After a lengthy call to their tech suppor
-
Lookup of connections & queues
I'm new to JMS, and would appreciate it if someone could please clear up this confusion... There appear to be 2 ways to access a Queue object: Method 1: Through a session, i.e: QueueConnection con= factory.createQueueConnection(); QueueSession sessi
-
Minimizing downtime after house move.
I'm moving house in October and wish to have Infinity from the moment I move in. How can I acheive this? The previous owner has Infinity and so I am assuming that an engineer visit is not required - is that a fair assumption? I am not moving my exist