Restful service returning components
Is there any way, or indeed am I doing something wrong when creating my components, to get components to generate json consistently. The json I'm returning will have the first letter capitalized and the rest lower case when returning the component from the restful service however all capitalized when calling the compoent remotely.
Some demo components as below:
User.cfc
component {
property type="numeric" name="userid";
property type="string" name="username";
Users.cfc
component output="false" restPath="/users"
remote User function getByPK(required numeric id restArgSource="Path") output="false" httpMethod="GET" restPath="{id}"
user = new user();
user.userid = 1;
user.username = "Chicken";
return user;
Output:
/rest/users/1.json
{"Username":"Chicken","Userid":1.0}
/rest/users/1.xml
<COMPONENT ID="1" NAME="User">
<PROPERTY NAME="USERNAME" TYPE="STRING">Chicken</PROPERTY>
<PROPERTY NAME="USERID" TYPE="STRING">1</PROPERTY>
</COMPONENT>
/Users.cfc?method=getByPK&id=1&returnFormat=json
{"USERNAME":"Chicken","USERID":1}
Is this simply a quirk I have to put up with?
Hello Jereme,
I've a similar requirement and trying to perform HTTP GET thorugh PI 7.31 HTTP Java adapter, My target URL looks like
https://abc.com/api?filterFields=<FilterFields><FilterField><Id>26</Id><Value>1/1/2013,12/31/2013</Value></FilterField></FilterFields>
I've configured my HTTP receiver adapter (Java) as below
Addressing mode - URL address
Target Host - https:abc.com
Target port: 8080
Path - /api
Where should I mention the query path - ?filterFields=<FilterFields><FilterField><Id>26</Id><Value>1/1/2013,12/31/2013</Value></FilterField></FilterFields>
Actually values inside the tag Value is dynamic and will be populated in message mapping,
What should be the value of Main Payload Parameter Name in the adapter?
Thanks in advance for your help.
Similar Messages
-
How to store and display Response from REST Service
Hi,
My WADL has defined the response that my REST service returns back as below :
<object name="Get_Root">
<property name="RequestId" type="number" />
<property name="Name" type="string" />
<property name="fromPlace" type="string" />
<property name="toPlace" type="string" />
<property name="fromDate" type="string" />
<property name="toDate" type="string" />
</object>
I want to store this response; response is a single entry of the above type and not a collection (I am making the request on a button click) and then display it on the screen in multiple labels.
How can I do this? Will I have to use a collection and a gallery, even though I have a single response?
Thanks,
PragyaOkay.. got it. So MyRestData has a Get function taking some n arguments and it responds back with an object of the type I had mentioned before.
From what I understood, I have to write the below code for each label
MyRestData!Get(.....)!Name
MyRestData!Get(.....)!fromPlace
MyRestData!Get(.....)!toPlace ...and so on
Wouldn't that translate to different REST calls? Is there a way to get and store the entire response object
in the app and access each of its properties/subelements locally?
Also when you wrote the below before
Text: "The name is: " & MyRestData!Get_Root!Name
it seems that I can access the response object Get_Root using MyRestData. This is not the case for me. MyRestData only lets me access the Get function using "!", and not the response object in any way.
Thanks for your help! -
Dear all -
I am writing with the confidence that someone will be able to assist me.
I am using the Flash Builder Data Services Wizard to access a Server that utilizes REST type calls and returns JSON objects. The server is a JETTY server and it apparantly already works and is returning JSON objects (see below for example). It is both HTTP and HTTPS enabled, and right now it has a cross-domain policy file that is wide open (insecure but its not a production server, it's internal).
The crossdomain file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*" secure="false" />
<allow-access-from domain="*" to-ports="*" secure="false"/>
<site-control permitted-cross-domain-policies="master-only" />
</cross-domain-policy>
The crossdomain file is in the jetty server's root directory and is browseable via HTTP and HTTPS (i.e. browsing to it returns the xml)
Now before all of you say that using wizards sucks (generally) I thought I would utilize the FB Data Services Wizard as at least it would provide a template for which I could build additional code against, or replace and improve the code it produces.
With that in mind, I browse to the URL of the Jetty Server with any web browser (for example, Google Chrome, Firefox or IE) with a URL like this (the URL is a little confidential at the moment, but the structure is the same)
https://localhost:somePort/someKey/someUser/somePassword/someTask
*somePort is the SSL port like 8443
*someKey is a key to access the URL's set of services
returns a JSON object as a string in the web browser and it appears like the following:
{"result":success,"value":"whatEverTheValueShould"}
Looks like the JSON string/object is valid.
I went through the Flash Builder Data Services Wizard to set up HTTP access to this server. The information that I filled in is described below:
Do you want to use a Base URL as a prefix for all operation URLs?
YES
Base URL:
https://localhost:8443/someKey/
Name : someTask
Method : POST
Content-Type: application/x-www-form-urlencoded
URL : {someUser}/{somePassword}/someTask
Service Name: SampleRestapi
Services Package: services.SampleRestapi
datatype objects: valueObjects:
Completing the wizard, I run the Test Operation command. Remember, no authentication is needed to get a JSON string.
It returns:
InvocationTargetException: Unable to connect to the URL specified
I am thinking - okay, but the URL IS browseable (as I originally was able to browse to it, as noted above).
I continue to test the service by creating a Flex application that accepts a username and password in a form. when the form is submitted, the call to the service is invoked and an event handler returns the result. The code is below (with some minor changes to mask the actual source).
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:SampleRestapi="services.SampleRestapi.*"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
protected function button_clickHandler(event:MouseEvent):void
isUserValidResult.token = SampleRestAPI.isUserValid(userNameTextInput.text,passwordTextInput.text);
protected function SampleRestAPI_resultHandler(event:ResultEvent):void
// TODO Auto-generated method stub
// print out the results
txtAreaResults.text = event.result.message as String;
// txtAreaResults.appendText( "headers \n" + event.headers.toString() );
]]>
</fx:Script>
<fx:Declarations>
<SampleRestapi:SampleRestAPI id="SampleRestAPI"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
result="SampleRestAPI_resultHandler(event)"
showBusyCursor="true"/>
<s:CallResponder id="isUserValidResult"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Form defaultButton="{button}">
<s:FormItem label="UserName">
<s:TextInput id="userNameTextInput" text="q"/>
</s:FormItem>
<s:FormItem label="Password">
<s:TextInput id="passwordTextInput" text="q"/>
</s:FormItem>
<s:Button id="button" label="IsUserValid" click="button_clickHandler(event)"/>
<s:FormItem label="results:">
<s:TextArea id="txtAreaResults"/>
</s:FormItem>
</s:Form>
</s:Application>
It's a simple application to be sure. When I run it , I get the following returned in the text area field txtAreaResults:
An Internal Error Occured.
Which is equivalent to the following JSON string being returned:
{"success":false,"value":"An Internal Error Occured"}
It appears that the call is being made, and that a JSON object is being returned... however it does not return the expected results?
Again the URL constructed is the same:
https://www.somedomain.com:somePort/someKey/someUser/somePassword/someTask
So I am wondering what the issue could be:
1) is it the fact that I am browsing the test application from an insecure (http://) web page containing the Flex application and it is accessing a service through https:// ?
2) is the JSON string structurally correct? (it appears so).
3) There is a certificate enabled for HTTPs. it does not match the test site I am using ( the cert is for www.somedomain.com but I am using localhost for testing). Would that be an issue? Google Chrome and IE just asks me to proceed anyway, which I say "yes".
Any help or assistance on this would be appreciated.
thanks
EdwardHello everyone -
Since I last posted an interesting update happened. I tested my Flex application again, it is calling a Jetty Server that returns a JSON object, in different BROWSERS. I disabled HTTPS for now, and the crossdomain.xml policy file is wide open for testing (ie. allowing every request to return data). So the app accessing the data using HTTP only. Browsers - IE, Opera, Firefox and Chrome. Each browser contained the SAME application, revision of the Flash Player (10.3.183.10 debugger for firefox, chrome, opera, safari PC; 11.0.1.129 consumer version in IE9,) take a look at the screen shot (safari not shown although the result was the same as IE and chrome)
Note that Opera and Firefox returned successful values (i.e. successful JSON objects) using the same code generated from the Data Services Wizard. Chrome, IE and, Safari failed with an Internal error. So I am left wondering - WHY? Is it something with the Flash Player? the Browsers? the Flex SDK? Any thoughts are appreciated. Again, the code is found in the original thread above. -
I am using the WEBSERVICE() function in Excel and a WCF REST service is called through this function.
The web service returns a string value of true or false when invoked. E.g. <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">True</string>
This has been confirmed through debugging and it seems to be working fine when invoked through a client application or browser.
However, the result shown in the cell in the Excel sheet is #VALUE!. This particular cell has a custom format (set using the Format Cells ... option) that displays "Yes" or "No". (The
custom format is "Yes" ; "Yes" ; "No".) Is this the correct way of interpreting the results of a Web Service method called in Excel? Does a #VALUE! result actually imply a formatting issue or some other interpretation
error? Is there anything missing? Can somebody suggest ideas?
Any help would be appreciated.
Many thanks,
Keith
R K HowardHi Keith,
Have you used the formula FILTERXML(xml, xpath) function to extract single pieces of data from the XML string?
If not, please follow the blog below, the author will guide you to get data from Webservice.
http://blogs.office.com/2013/03/21/use-webservice-functions-to-automatically-update-excel-2013-spreadsheets-with-online-data/
Best Regards
Lan
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Restful service unable to insert data using PL/SQL.
Hi all,
Am running: AL 2.01 standalone mode on OEL 4.8 in VM box A.
Oracle database 10.2.0.4 with Apex 4.2.0.00.27 on OEL4.8 in VM box B.
Able to performed oracle.example.hr Restful services with no problem.
Unable to insert data using AL 2.0.1 but works on AL 1.1.4.
which uses the following table (under schema: scott):
create table json_demo ( title varchar2(20), description varchar2(1000) );
grant all on json_demo to apex_public_user; and below procedure ( scott's schema ):
CREATE OR REPLACE
PROCEDURE post(
p_url IN VARCHAR2,
p_message IN VARCHAR2,
p_response OUT VARCHAR2)
IS
l_end_loop BOOLEAN := false;
l_http_req utl_http.req;
l_http_resp utl_http.resp;
l_buffer CLOB;
l_data VARCHAR2(20000);
C_USER_AGENT CONSTANT VARCHAR2(4000) := 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)';
BEGIN
-- source: http://awads.net/wp/2005/11/30/http-post-from-inside-oracle/
-- Ask UTL_HTTP not to raise an exception for 4xx and 5xx status codes,
-- rather than just returning the text of the error page.
utl_http.set_response_error_check(false);
-- Begin the post request
l_http_req := utl_http.begin_request (p_url, 'POST', utl_http.HTTP_VERSION_1_1);
-- Set the HTTP request headers
utl_http.set_header(l_http_req, 'User-Agent', C_USER_AGENT);
utl_http.set_header(l_http_req, 'content-type', 'application/json;charset=UTF-8');
utl_http.set_header(l_http_req, 'content-length', LENGTH(p_message));
-- Write the data to the body of the HTTP request
utl_http.write_text(l_http_req, p_message);
-- Process the request and get the response.
l_http_resp := utl_http.get_response (l_http_req);
dbms_output.put_line ('status code: ' || l_http_resp.status_code);
dbms_output.put_line ('reason phrase: ' || l_http_resp.reason_phrase);
LOOP
EXIT
WHEN l_end_loop;
BEGIN
utl_http.read_line(l_http_resp, l_buffer, true);
IF(l_buffer IS NOT NULL AND (LENGTH(l_buffer)>0)) THEN
l_data := l_data||l_buffer;
END IF;
EXCEPTION
WHEN utl_http.end_of_body THEN
l_end_loop := true;
END;
END LOOP;
dbms_output.put_line(l_data);
p_response:= l_data;
-- Look for client-side error and report it.
IF (l_http_resp.status_code >= 400) AND (l_http_resp.status_code <= 499) THEN
dbms_output.put_line('Check the URL.');
utl_http.end_response(l_http_resp);
-- Look for server-side error and report it.
elsif (l_http_resp.status_code >= 500) AND (l_http_resp.status_code <= 599) THEN
dbms_output.put_line('Check if the Web site is up.');
utl_http.end_response(l_http_resp);
RETURN;
END IF;
utl_http.end_response (l_http_resp);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line (sqlerrm);
raise;
END; and executing in sqldeveloper 3.2.20.09 when connecting directly to box B as scott:
SET serveroutput ON
DECLARE
l_url VARCHAR2(200) :='http://MY_IP:8585/apex/demo';
l_json VARCHAR2(20000) := '{"title":"thetitle","description":"thedescription"}';
l_response VARCHAR2(30000);
BEGIN
post( p_url => l_url, p_message =>l_json, p_response => l_response);
END;which resulted in :
anonymous block completed
status code: 200
reason phrase: OK
with data inserted. Setup using 2.0.1
Workspace : wsdemo
RESTful Service Module: demo/
URI Template: test
Method: POST
Source Type: PL/SQLand executing in sqldeveloper 3.2.20.09 when connecting directly to box B as scott:
SET serveroutput ON
DECLARE
l_url VARCHAR2(200) :='http://MY_IP:8585//apex/wsdemo/demo/test';
l_json VARCHAR2(20000) := '{"title":"thetitle","description":"thedescription"}';
l_response VARCHAR2(30000);
BEGIN
post( p_url => l_url, p_message =>l_json, p_response => l_response);
END;which resulted in :
status code: 500
reason phrase: Internal Server Error
Listener's log:
Request Path passes syntax validation
Mapping request to database pool: PoolMap [_poolName=apex, _regex=null, _workspaceIdentifier=WSDEMO, _failed=false, _lastUpdate=1364313600000, _template=/wsdemo/, _type=BASE_PATH]
Applied database connection info
Attempting to process with PL/SQL Gateway
Not processed as PL/SQL Gateway request
Attempting to process as a RESTful Service
demo/test matches: demo/test score: 0
Choosing: oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as current candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=2648625079503782|2797815111031405, uriTemplate=demo/test], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true]
Determining if request can be dispatched as a Tenanted RESTful Service
Request path has one path segment, continuing processing
Tenant Principal already established, cannot dispatch
Chose oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as the final candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=2648625079503782|2797815111031405, uriTemplate=demo/test], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true] for: POST demo/test
demo/test is a public resource
Using generator: oracle.dbtools.rt.plsql.AnonymousBlockGenerator
Performing JDBC request as: SCOTT
Mar 28, 2013 1:29:28 PM oracle.dbtools.common.jdbc.JDBCCallImpl execute
INFO: Error occurred during execution of: [CALL, begin
insert into scott.json_demo values(/*in:title*/?,/*in:description*/?);
end;, [title, in, class oracle.dbtools.common.stmt.UnknownParameterType], [description, in, class oracle.dbtools.common.stmt.UnknownParameterType]]with values: [thetitle, thedescription]
Mar 28, 2013 1:29:28 PM oracle.dbtools.common.jdbc.JDBCCallImpl execute
INFO: ORA-06550: line 1, column 6:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe
The symbol "" was ignored.
ORA-06550: line 2, column 74:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-id
java.sql.SQLException: ORA-06550: line 1, column 6:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe
The symbol "" was ignored.
ORA-06550: line 2, column 74:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-id
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:505)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:223)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:205)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1043)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3612)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3713)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4755)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1378)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.ucp.jdbc.proxy.StatementProxyFactory.invoke(StatementProxyFactory.java:242)
at oracle.ucp.jdbc.proxy.PreparedStatementProxyFactory.invoke(PreparedStatementProxyFactory.java:124)
at oracle.ucp.jdbc.proxy.CallableStatementProxyFactory.invoke(CallableStatementProxyFactory.java:101)
at $Proxy46.execute(Unknown Source)
at oracle.dbtools.common.jdbc.JDBCCallImpl.execute(JDBCCallImpl.java:44)
at oracle.dbtools.rt.plsql.AnonymousBlockGenerator.generate(AnonymousBlockGenerator.java:176)
at oracle.dbtools.rt.resource.templates.v2.ResourceTemplatesDispatcher$HttpResourceGenerator.response(ResourceTemplatesDispatcher.java:309)
at oracle.dbtools.rt.web.RequestDispatchers.dispatch(RequestDispatchers.java:88)
at oracle.dbtools.rt.web.HttpEndpointBase.restfulServices(HttpEndpointBase.java:412)
at oracle.dbtools.rt.web.HttpEndpointBase.service(HttpEndpointBase.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.doFilter(ServletAdapter.java:1059)
at com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.invokeFilterChain(ServletAdapter.java:999)
at com.sun.grizzly.http.servlet.ServletAdapter.doService(ServletAdapter.java:434)
at oracle.dbtools.standalone.SecureServletAdapter.doService(SecureServletAdapter.java:65)
at com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:379)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.grizzly.tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:196)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Error during evaluation of resource template: ORA-06550: line 1, column 6:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe
The symbol "" was ignored.
ORA-06550: line 2, column 74:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-idPlease advise.
Regards
ZackZack.L wrote:
Hi Andy,
Sorry, forgot to post the Source that's use by both AL1.1.4 and AL2.0.1.
Source
begin
insert into scott.json_demo values(:title,:description);
end;
it's failing during the insert?
Yes, it failed during insert using AL2.0.1.
So the above statement produces the following error message:
The symbol "" was ignored.
ORA-06550: line 2, column 74:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-idThis suggests to me that an unprintable character (notice how there is nothing between the double quotes - "") has worked its way into your PL/SQL Handler. Note how the error is reported to be a column 74 on line 2, yet line 2 of the above block should only have 58 characters, so at a pure guess somehow there's extra whitespace on line 2, that is confusing the PL/SQL compiler, I suggest re-typing the PL/SQL handler manually and seeing if that cures the problem. -
Role Assignment Discovery Issue for Files and Folders through Sharepoint REST services
To preface, I am a decided Sharepoint newbie in every sense. I am trying to use the Sharepoint REST services (Sharepoint 2013) to walk the folder and file structure of my Sharepoint server and, determine as I go, the Role Assignments (and subsequently
Permissions) on those folders and files. I'm using an Administrator credentials and I'm actually able to successfully do it but I've run into some caveats. All the caveats begin with this; when I'm examining a folder, for example:
/_api/Web/GetFolderByServerRelativeUrl('/sites/cmisdev/Development')/ListItemAllFields
I receive either an empty list or an error response doc when following the link supplied for ListItemAllFields. When following that kind of link for folders, I either get:
<d:ListItemAllFields
m:null="true"
/>
or an error response document that says "The object specified does not belong to a list." When I hit the /ListItemAllFields endpoint for files, I receive a response with a link for Role Assignments which subsequently also works and I get the
info I need. So, is this a bug? Why does the link returned from Sharepoint work for files and not folders? So, google, google, google, and I discover that there is another possible way to get at the Role Assignments (and that the object does, indeed, belong
to a list!).
If I know the Title (or the guid) of the folder in question, I can use the following endpoint:
/_api/Web/Lists/GetByTitle('Development')
If I use that endpoint, I get the information I would have expected to get from following /ListItemAllFields and the subsequent Role Assignments links all work and I get what I need. If there's a bug and this is how I have to work around it, that's fine
but I have yet to discover how to dynamically determine the Title of a given folder nor am I sure if all Titles are supposed to be unique within a given Sharepoint server. I'm assuming that the folder name as represented in the server relative URL and the
Title may be different and this is where my newbishness may start to shine if I'm misunderstanding what a "List" is supposed to be in Sharepoint. Anyway, I did find that I could use the Properties endpoint to perhaps get the Title, for example:
/_api/Web/GetFolderByServerRelativeUrl('/sites/cmisdev/Development')/Properties
gives me:
<d:vti_x005f_listtitle>Development</d:vti_x005f_listtitle>
whose value I assume I could then supply to the /GetByTitle endpoint and be golden. However, "vti_x005f_listtitle" just sounds a little too deep to be something I should be relying on but maybe that's kosher. That's part of what I'm trying to
find out. Also, if there is a way to use the Sharepoint REST API to discover the guid of a given object, then I could look it up in that way.
So, in summary:
1. Am I going about getting folder Role Assignment information in the wrong way? Based on the CSOM examples I've seen, I believe I'm doing it correctly and that the answer to #2 below is a resounding "Yes!" :)
2. Is it a bug if I'm not able to use /ListItemAllFields on folders using the server relative url?
3. If I'm supposed to use GetByTitle as a workaround, am I discovering that Title correctly through /Properties? Seems quite circuitous and awkward. Are Titles required to be unique throughout a given Sharepoint server?
4. If I'm supposed to use the guid, how can I use the REST interface to discover an object's guid? Once we get down to the Role Assignments and other links, the guid appears in those links but I don't know how to discover it independently if that's the
path I should use to get the data I described above.Upon further research, I'll answer my own question for the benefit of some other potential future newbie. The answer to question number 1 above is "Not exactly.". The server relative URLs I was using corresponded to lists (which are
returned as a collection through /_api/web/lists). I was treating them mentally like regular folders. That, coupled with the fact that accessing their data as I showed above returns a ListItemAllFields link, made me think that was the way to get
the Role Assignments just as I would for files and, as it turns out, "real" folders and sub-folders created under these lists. That was the other problem with thinking of these lists as regular folders. So, ListItemAllFields works on
all files and folders in a list. However, if you want Role Assignments for the lists themselves, you can keep track of the Titles and\or Guids from the /_api/web/lists that you're interested in (in my case, all non-hidden "document library"
type lists) and then access those Role Assignments as I discussed in questions 3 and 4 above. For example, from the /_api/web/lists collection from my test server, the "Development" document library Role Assignments are accessable via /_api/Web/Lists(guid'cd242eeb-aafa-4efa-aecc-9bbdf8e3d459')/RoleAssignments
or /_api/Web/Lists/GetByTitle('Development')/RoleAssignments. -
Hello,
I'm new to the whole Flex system and I'm trying to integrate with WCF Rest Services
I see that Flex doesn't support PUT and DELETE which is fine because we can use the x-http-method-override header which I assume you set in Flex with the headers property of the HttpService object?
httpService.headers["x-http-method-override"] = "DELETE"
The other thing is the HTTP Status code - it seems that Flex can't give you the HTTP Status code returned by the HttpService and that codes over 200 cause an exception. Is this correct and is this going to be resolved in Flex 4?
Thanks,
DaveI had a similar problem with 302 codes. Firefox gets HTTPStatusEvent.HTTP_STATUS and IE gets Event.COMPLETE. Can you check HTTPStatusEvent in Safari?
Basically the HTTP stuff is a total disaster because of all the inconsistencies in the browser plug-in interfaces. So much for "write once run anywhere"! More like write once, test everywhere, pray...
If you're in control of the server returning the 204 I'd say change it to not do that but I understand that may not be an option. -
APEX post restful service inserts null value
Oracle APEX 4.2.5
Oracle Rest Data Service 2.0.7
Apache Tomcat 7
Oracle database 11.2.0.4
Oracle APEX PUT web service inserts null value into column. This is either a bug or the documentation does not properly cover how to correctly set PUT restful services.
GET web services works fine.
I have granted the role of apex_rest_public_user to both apex_public_user and the schema owner.
The payload is a small xml document, but even a text document will yield the same result.
I am using the Oracle REST Data Service 2.0.5
Web service code:
RESTful Service Module: software_details/
URI Template: xml_parser
Method: POST
Source Type: PL/SQL
MIME: Types Allowed: application/xml
Requires Secure Access: NO
Source :
begin
insert into clob_test (x)
values (blob_to_clob(:body)); ## according to some online post, :body is where APEX places any data being transferred through a web service. I have yet to find any official ##documentation on it.
commit:
end;
##Blob_to_clob function code
CREATE OR REPLACE FUNCTION blob_to_clob (blob_in IN BLOB)
RETURN CLOB
AS
v_clob CLOB;
v_varchar VARCHAR2(32767);
v_start PLS_INTEGER := 1;
v_buffer PLS_INTEGER := 32767;
BEGIN
DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);
FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(blob_in) / v_buffer)
LOOP
v_varchar := UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(blob_in, v_buffer, v_start));
DBMS_LOB.WRITEAPPEND(v_clob, LENGTH(v_varchar), v_varchar);
v_start := v_start + v_buffer;
END LOOP;
RETURN v_clob;
END blob_to_clob;
#Table code
create table clob_test(
x clob));
Thank you,I am experiencing the same issue.
I implemented the 'chunked file loading' example from Kris Rice's blog at Kris' blog: August 2013 in y workspace at the Oracle hosted APEX site and everything works fine.
However, I get a null value for 'data' when I implement the same example at my work site.
Work Site config is
Apache Tomcat 7
Oracle REST Data Services version : 2.0.6.27.18.06
Application Express 4.2.2.00.11
Oracle RDBMS 11.2.0.3
I am NOT using SSL at my work site. However this does not seem to affect a POST with form values.
Varad. -
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 -
RESTful service with EJB 3.1 endpoint cannot be found (404)
Hi,
I have a Resource configured as a EJB 3.1 Stateless Bean. I also have an overridden Application class to customize the context root. However, the client just cannot seem to find the Resource. What am I doing wrong? The Resource is packaged and deployed as a war.
Cross posted: http://www.coderanch.com/t/546565/java-Web-Services-SCDJWS/certification/RESTful-service-EJB-endpoint-cannot#2480046
Tests in error:
testSendRequestAndGetGreeting(name.app.abhi.helloworld.ejb.restful.client.HelloWorldEjbRestfulClientTest): GET http://localhost:9090/practice/helloworld?name=Duke returned a response status of 404 Not Found
Resource:
@Path("helloworld")
@Stateless
public class HelloWorldBean {
@GET
@Produces("text/plain")
public String getQuintessentialGreeting(@QueryParam("name") String name) {
if (name == null) {
throw new WebApplicationException(Response.Status.BAD_REQUEST);
return "Say hello to the world, " + name;
Application class:
@ApplicationPath("practice")
public class ApplicationConfig extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> clazzez = super.getClasses();
if (clazzez == null) {
clazzez = new HashSet<Class<?>>();
clazzez.add(name.app.abhi.helloworld.ejb.restful.service.HelloWorldBean.class);
return clazzez;
Client:
public class HelloWorldEjbRestfulClient {
private final static String ENDPOINT_URI = "http://localhost:9090/"
+ "practice/helloworld";
public String sendRequestAndGetGreeting(String name) {
Client client = Client.create();
WebResource webResource = client.resource(ENDPOINT_URI);
webResource.accept(MediaType.TEXT_PLAIN);
return webResource.queryParam("name", name).get(java.lang.String.class);
}Edited by: asarkar on Jul 24, 2011 12:20 PMI figured this out...the context root is NOT the one specified in the @ApplicationPath annotation. The context root has to be specificed in the vendor-specific dd, glassfish-web.xml for example, or the default needs to be accepted.
The endpoint URI is of the form http://hostname:port/contextRoot/applicationPath/path, where applicationPath is specific with @ApplicationPath and path with @Path.
Edited by: asarkar on Jul 24, 2011 2:45 PM -
[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 -
Issue with calling restful services via HTTP in an Orchestration
The company I work for is using RESTful services for our I/O. We are processing EDI files using Biztalk, and are calling the REST services via HTTP from a c# code called within the orchestration. At lower volumes, the service performs fine, but at higher
transaction volumes, the HTTP calls never return. Is there a resource that needs to be tuned somewhere on the biztalk node to allow higher volumes of HTTP calls? Its not the REST service side - it has no problems handling loads generated by non biztalk nodes.
For further clarification, the EDI message is a multi batched, so there are many simultaneous orchestrations running at once. I have started to look at ways to throttle how many instances can run at once, but I still suspect some resource in the HTTP
sequence that we dont have enough of.
Ideas?I think you were not enough free threads in the ThreadPool to complete the operation.
So you can work out with Max connection setting in your BTSNTSvc file first
<system.net>
<connectionManagement>
<add address="http://name.of.server.here" maxconnection="1oo" />
</connectionManagement>
</system.net>
and try increasing number of threads allocated to the specific send Host instance and your Orchestration instance ,you can try twinkling Response timeout in minutes as well on host instance
Thanks
Abhishek -
The Opration timed out occurred on calling REST Service in Addin in windows 7 ultimate 64 bit
Hi,
I have created VSTO solution for Outlook Addin in Visual studio 2010.
In that on button it will call Java REST webservice and validating the username and password.
Evrything working fine in few systems.But it showing "The operation timed out" in WIndows 7 64 bit office 2013.
In other windows 7 machine with office 2010 and 2007 its working perfectly.
Below is the code :
var responseMessage = (String)null;
var request = WebRequest.Create(string.Concat(serviceUrl, resourceUrl)) as HttpWebRequest;
if (request != null)
request.ContentType = "application/xml";
request.MediaType = "text/xml";
request.Method = method;
request.keepalive=false;
request.ContentLength = xmlRequestBody.Length;
ServicePointManager.Expect100Continue = false;
//var objContent = HttpContentExtensions.CreateDataContract(requestBody);
if (method == "POST" && xmlRequestBody != null)
byte[] requestBodyBytes = ASCIIEncoding.UTF8.GetBytes(xmlRequestBody.ToString());
request.ContentLength = requestBodyBytes.Length;
using (Stream postStream = request.GetRequestStream())
postStream.Write(requestBodyBytes, 0, requestBodyBytes.Length);
if (request != null)
request.Credentials = new NetworkCredential("Username", "password");
//request.ProtocolVersion = HttpVersion.Version11;
var response = request.GetResponse() as HttpWebResponse;
if (response.StatusCode == HttpStatusCode.OK)
Stream responseStream = response.GetResponseStream();
if (responseStream != null)
var reader = new StreamReader(responseStream);
responseMessage = reader.ReadToEnd();
else
responseMessage = response.StatusDescription;
return responseMessage;
Could you please help what could be the reason.Any firewall issue or any serviced related issue.Kidly suggest.Hi,
I have created the windows application using REST Service and tested the application on
windows 7 64 bit Ultimate edition but I'm getting the same error "The
operation timed out" attached the screen shot for your reference.
http://www.screencast.com/t/YeIJxl383a
I developed the application on Windows 7 Ultimate 64 bit version it is working on my machine. while the executing exe on another windows 7 64 bit Ultimate
edition which is on the virutal machine Im getting the error.
There is no visual studio installed on the Virtual machine , i have installed the Dot Net frame work 4.0 client profile on the virtual machine.
Could you please suggest is there any issues related to opearating system or related to framework.
Kindly help with some suggestions. -
Calling Apex restful service in android
Hi frnds i have created apex restful service, now i want to access it in android...
So any one can help me how to call restful services using ksoap2.jarI got solution using HttpClient, but i can acces only "GET" method of restful services
But how to access Restfukl service using "POST" method
here is my code that i use to access rest service using "GET"
String url = "http://198.16.11.12:2000/apex/jigar/mr/employees/10";
HttpClient httpclient = new DefaultHttpClient();
HttpGet hg = new HttpGet(url);
HttpResponse response = httpclient.execute(hg);
str = inputStreamToString(response.getEntity().getContent());
Now insted of GET when i use POST to access service it returns null, what can be my URl in case of post? -
Invoking RESTful service from OSB
Hi
I need to invoke Restful service from OSB11g in order to do that...
1. I have created Business service with the end point of the RESTful service.
2. Running the Business service and provided the XML as input in Transport Header--> query-string.. i got the response as bellow:
<serviceResponse returnCode="-1">
<statusMessage messageId="Exception" messageType="" severityCode="E">
<text>
Required input not supplied. Please revisit your input values and try again.
</text>
</statusMessage>
</serviceResponse>
Is this the correct way i am doing or am i missing something..???
Thanks
VasuHi Vasu,
did you solve your issue ?
I have a similar scenario where 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
I tested it from business service test console:
- in Transport
-> query-string I put my input xml
-> http-method: POST
-> Content-Type: text/xml
but on execute 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 15:07:38 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>
May I ask you to provide me any hints ?
Thanks in advance for any help
ferp
Maybe you are looking for
-
My laptop is broken, hard disk failure. It's gone to the hospital but it will require a new hard disk. I have an iPod. I also have iCloud which everything ( I think) has been backed up to. I have an new iPhone and need to sync it up. Can I sync it
-
I recently reimaged a brand new W510 w/WinXP w/SP3 & installed Lenovo Toolbox utility. Which immediately identified an issue w/the 1394 Net Adapter in Device Manager. Looking at the Device Status (details) it states "The Device Cannot Start (code 10)
-
The find function doesn't expanding the xml nodes to search. If the xml is expanded , then find function highlights both matching tag and data. how to fix this. == This happened == Every time Firefox opened
-
Error in Model View Distribution
Hello all, Re: Error in distribution of model view I am referring this thread, as i am facing the same error. The thread does not have answers to solve the issue. The issue is, when i try to distribute my view i am facing the below error. Communi
-
Need help from people who know Java. Some beginner questions.
Hello all. I just recently became interested in programming and I chose Java to learn (not really sure why), I am not really interested in the whole Java Applets thing because i can already do the same things in Flash. What I really want to do is to