You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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().
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.
749
748
750
749
By default, the DbWebApiClient uses Windows authentication for the convenience of intranet usage scenarios. Please see its constructor overrides for other options.
751
750
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
-
754
751
#### JavaScript Client
755
752
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.
@@ -770,7 +767,7 @@ You can use jQuery.ajax easily to call the Web API, or you can use [DbWebApi Cli
770
767
....
771
768
</script>
772
769
```
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.
774
771
```javascript
775
772
....
776
773
var input = {
@@ -792,7 +789,7 @@ Alternatively, $.getDb can be used for HTTP GET if need be. All input parameters
792
789
793
790
##### Cross-domain
794
791
###### 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.
796
793
```XML
797
794
<configuration>
798
795
<appSettings>
@@ -818,7 +815,7 @@ Usually the CORS preflight will fail by a 401 unauthorized error _(Access is den
818
815
- Use HTTP GET method to avoid sending application/json (or xml) Content-Type header - _Browser never send any body in GET request._
819
816
$.getDb(...) can encode input JSON object into a special parameter in query string.
820
817
_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:
822
819
```javascript
823
820
....
824
821
var input = {
@@ -830,17 +827,12 @@ _But there is a limitation on length of the URL, large data still requires the u
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._
844
836
845
837
.
846
838
@@ -925,15 +917,15 @@ Invoke-RestMethod -UseDefaultCredentials -method Post -Uri "http://dbwebapi.test
925
917
*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.*
926
918
*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.*
927
919
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.
929
921
930
922
931
923
### Restrictions
932
924
* 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.
933
925
* 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.
934
926
[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.
935
927
* 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.
0 commit comments