Skip to content

Commit 9528ed0

Browse files
committed
Updating README.md
1 parent c589751 commit 9528ed0

1 file changed

Lines changed: 21 additions & 29 deletions

File tree

README.md

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -717,46 +717,43 @@ using DataBooster.DbWebApi.Client;
717717
```
718718
``` CSharp
719719
DbWebApiClient client = new DbWebApiClient("http://dbwebapi.dev.com/oradev/");
720-
721720
// client.HttpMethod = HttpMethod.Get; // Default is POST
722721
723-
// Synchronous call. If need asynchronous call, please use ExecAsJsonAsync(..) instead.
724-
DbWebApiResponse data = client.ExecAsJson("test_schema.prj_package.foo",
722+
// Synchronous call. If need asynchronous call, please use ExecAsync(..) instead.
723+
StoredProcedureResponse data = client.Exec("test_schema.prj_package.foo",
725724
new {
726725
inDate = new DateTime(2015, 3, 16)
727726
//, ... other input parameters, if any.
728727
});
729-
730-
// You can either consume JObject[] (LINQ to JSON) directly or cast to your strong-type business class as below:
731-
IEnumerable<MyStrongTypeCls> strongTypeObjs = data.ResultSets[0].Select(j => j.ToObject<MyStrongTypeCls>());
732728
```
733-
The second argument of ExecAsJson can be a dictionary that contains every parameters, or an anonymous type object that each property indicate a parameter name-value.
734-
If an array of input parameter sets is passed into the second argument of ExecAsJson, the return will be an array -- DbWebApiResponse[].
735-
`
736-
If you just need the response content stream (E.g. CSV, Excel xlsx or generated text) to be stored as a file or transfer forward to somewhere else on the network, see below example, replacing ExecAsJson() by ExecRawAsync(), then [write the HTTP content to a stream](https://msdn.microsoft.com/en-us/library/hh138076.aspx) dicectly.
729+
The second argument of Exec(...) can be a dictionary that contains every parameters, or an anonymous type object that each property indicate a parameter name-value.
730+
If an array of input parameter sets is passed into the second argument of Exec(...), the return will be an array -- StoredProcedureResponse[].
731+
_All Exec... overloads will use HTTP POST method by default. You can change the default behavior to HTTP GET if need be. (as the comment line in above example code)_
732+
.
733+
734+
If you just need the response content stream (E.g. CSV, Excel xlsx or generated text) to be stored as a file or transfer forward to somewhere else on the network, see below example, replacing Exec() by ExecAsStream().
737735
``` CSharp
738736
....
739-
var task = client.ExecRawAsync("test_schema.prj_package.foo",
737+
Stream stream = client.ExecAsStream("test_schema.prj_package.foo",
740738
new {
741739
inDate = new DateTime(2015, 3, 16)
742740
//, ... other input parameters, if any.
743741
});
744742
using (FileStream file = File.Create(...))
745743
{
746-
task.Result.Content.CopyToAsync(file).Wait();
744+
stream.CopyTo(file);
747745
}
748746
```
747+
For more general purpose, ExecAsStream _(or ExecAsStreamAsync)_, ExecAsJson _(or ExecAsJsonAsync)_, ExecAsXml _(or ExecAsXmlAsync)_ and ExecAsString _(or ExecAsStringAsync)_ overloads can be used to invoke any REST API, not limited to DbWebApi.
749748

750749
By default, the DbWebApiClient uses Windows authentication for the convenience of intranet usage scenarios. Please see its constructor overrides for other options.
751750

752-
All Exec... methods will use HTTP POST method by default. You can change the default behavior to HTTP GET if need be. (as the comment line in above example code)
753-
754751
#### JavaScript Client
755752
You can use jQuery.ajax easily to call the Web API, or you can use [DbWebApi Client JavaScript Library](http://www.nuget.org/packages/DataBooster.DbWebApi.Client.JS) to reduce repetitive coding.
756753
Sample:
757754
``` javascript
758-
<script src="Scripts/jquery-2.1.3.js" type="text/javascript"></script>
759-
<script src="Scripts/dbwebapi_client-1.0.8-alpha.js" type="text/javascript"></script>
755+
<script src="Scripts/jquery-2.1.3.js" type="text/javascript"></script>
756+
<script src="Scripts/dbwebapi_client-1.0.8-alpha.js" type="text/javascript"></script>
760757
```
761758
``` javascript
762759
<script type="text/javascript">
@@ -770,7 +767,7 @@ You can use jQuery.ajax easily to call the Web API, or you can use [DbWebApi Cli
770767
....
771768
</script>
772769
```
773-
The second argument of $.postDb - inputJson can be either a JSON string or a plain object. If it's a plain object, it will be converted by JSON.stringify before sending to the server. Below sample is equivalent to above sample.
770+
The second argument of $.postDb - _inputJson_ can be either a JSON string or a plain object. If it's a plain object, it will be converted by JSON.stringify before sending to the server. Below sample is equivalent to above sample.
774771
``` javascript
775772
....
776773
var input = {
@@ -792,7 +789,7 @@ Alternatively, $.getDb can be used for HTTP GET if need be. All input parameters
792789

793790
##### Cross-domain
794791
###### CORS
795-
The sample server projects _(.Net4.5/WebApi2 versions)_ in this repository have built-in support for CORS _(Cross-Origin Resource Sharing)_. You can change the "CorsOrigins" item of appSettings in the Web.config if you want to specify particular Origins.
792+
The sample server projects _(.Net4.5/WebApi2 versions)_ in this repository have built-in support for [CORS _(Cross-Origin Resource Sharing)_](http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api). You can change the "CorsOrigins" item of appSettings in the Web.config if you want to specify particular Origins.
796793
``` XML
797794
<configuration>
798795
<appSettings>
@@ -818,7 +815,7 @@ Usually the CORS preflight will fail by a 401 unauthorized error _(Access is den
818815
- Use HTTP GET method to avoid sending application/json (or xml) Content-Type header - _Browser never send any body in GET request._
819816
$.getDb(...) can encode input JSON object into a special parameter in query string.
820817
_But there is a limitation on length of the URL, large data still requires the use of POST method, see the next ways then:_
821-
- Attach cross-origin POST requests in any one very lightweight GET request's callback function, as in the following example:
818+
- Attach cross-origin POST request in any one very lightweight GET request's callback function, as in the following example:
822819
``` javascript
823820
....
824821
var input = {
@@ -830,17 +827,12 @@ _But there is a limitation on length of the URL, large data still requires the u
830827
function (data) {
831828
....
832829
});
833-
...
834-
$.postDb('http://dbwebapi.dev.com/oradev/other_more', ...);
835-
...
836830
});
837831
....
838832
```
839-
Here $.getDb('.../WhoAmI') acts as a bootstrapper, it makes the browser to start an authentication handshake, once IIS authenticates the request, [the default behavior of IIS](https://msdn.microsoft.com/en-us/library/aa347548.aspx) will cache a token or ticket on the server for the connection, then the immediate preflight request on the same connection is not required to be authenticated again, so the preflight request will succeed, then the browser can continue the [actual CORS request](http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api).
840-
841-
.
842-
843-
.
833+
Here $.getDb('.../WhoAmI') acts as a bootstrapper, it makes the browser to start an authentication handshake in advance, once IIS authenticates the request, [the default behavior of IIS](https://msdn.microsoft.com/en-us/library/aa347548.aspx) will cache a token/ticket on the server for the connection, then the immediate preflight request on the same connection is not required to be authenticated again, so the preflight request will succeed, then the browser can continue the actual CORS request.
834+
- HTML Form request _(Content-Type: application/x-www-form-urlencoded)_ and Multipart MIME request _(Content-Type: multipart/form-data)_ can also be used to send a fair amount of data to DbWebApi without preflight request.
835+
_The limitation of these two media types' requests is that, they can only carry input parameters for a single execution of DbWebApi on each call. If you need a bulk execution of DbWebApi on one call, only the former way (all sets of input parameters are further encapsulated in an outer JSON or XML array) can satisfy the use._
844836

845837
.
846838

@@ -925,15 +917,15 @@ Invoke-RestMethod -UseDefaultCredentials -method Post -Uri "http://dbwebapi.test
925917
*Using PowerShell array for large dataset, better to initialize an array with explicit size (instead of dynamic array with subsequent appending elements), otherwise most of performance will be lost in highly frequent memory reallocation, data copying over and over again.*
926918
*You may notice that [Invoke-RestMethod](https://technet.microsoft.com/en-us/library/hh849971.aspx) takes many fixed arguments, to be lazier to type them all the time, you can import a convenient function [Invoke-DbWebApi](https://github.com/DataBooster/DbWebApi/blob/master/Client/PowerShell/dbwebapi-client.ps1) from [dbwebapi-client.ps1](https://github.com/DataBooster/DbWebApi/blob/master/Client/PowerShell/dbwebapi-client.ps1) to further clean your PowerShell scripts. As a shell, PowerShell is much better at describing what to do, rather than how to do. Each Cmdlet or external service focuses on how to do. So keep PowerShell scripts as clean as possible will benefit the whole process flow in a clear thread.*
927919

928-
PowerShell is true powerful to do more solid work with less coding if being rationally utilized. Especially for back office system-integration applications, heterogeneous techniques across different systems can be leveraged by PowerShell's interoperability with consistent pipeline mechanism. It's also extremely handy to use PowerShell as a test/debug tool. With PowerShell, you won't even want to use Fiddler for Web API testing any more. In PowerShell, the data is visualized and extremely flexible to be quickly modified interactively.
920+
PowerShell is true powerful to do more solid work with less coding if being rationally utilized. Especially for back office system-integration applications, heterogeneous techniques across different systems can be leveraged by PowerShell's interoperability with consistent pipeline mechanism. It's also extremely handy to use PowerShell as a test/debug tool. In PowerShell, all data become visualized and extremely flexible to be quickly modified interactively.
929921

930922

931923
### Restrictions
932924
* Only basic database data types are supported -- can be mapped to .NET Framework simple data types which implement the [IConvertible](https://msdn.microsoft.com/en-us/library/system.iconvertible.aspx) interface.
933925
* Database User-Defined Types, Oracle composite data types (such as Collection Types, Varrays, Nested Tables, etc.) are currently not supported in result set columns nor in sp/func parameters.
934926
[Table-Valued Parameters (SQL Server 2008)](https://msdn.microsoft.com/en-us/library/bb675163.aspx) and [PL/SQL Associative Array Parameters](http://docs.oracle.com/cd/E51173_01/win.122/e17732/featOraCommand.htm#BABBDHBB) are supported only in sp/func input parameters.
935927
* All database procedure-names, function-names, column-names and parameter-names are regarded as case-insensitive.
936-
* [Oracle stored procedure or function overloading](https://docs.oracle.com/database/121/LNPLS/subprograms.htm#i12352) is not supported.
928+
* [Overloading of Oracle stored procedure or function](https://docs.oracle.com/database/121/LNPLS/subprograms.htm#i12352) is not supported.
937929

938930

939931

0 commit comments

Comments
 (0)