I'm experimenting with Xamarin, using VS and C# and trying to do simple things like calling a production WWC service ( fox ). All the examples I see out there are using Web API on the back end and using POST and GET. I realize this is the preferred way to do things. Ultimately, my WWC apps will be replaced with Web APi's, but for now...
I simply want to call my service, script map style, pass in a username and password, then get back a string just like I would do from within a FoxPro app using WW's wwhttp and post keys. Ultimately, if I can technically do this, I would be able to use my existing WWC apps to fetch all kinds of data in JSON format and deserialize it in Fox or C#.
Has anyone tried to hit a WWC fox service using HTTPClient in a C# app without prepping for POST and GET, headers and all of that.
Thanks in advance!!
Sure that will work just fine. THe only difference is that your URLs will probably look a little more 'page' centric, but otherwise it's all just HTTP.
I've built a few Cordova apps that talk to Web Connection web back ends and no problem there.
What specific issue are you worried about?
+++ Rick ---
Hi,
I'm experimenting with Xamarin, using VS and C# and trying to do simple things like calling a production WWC service ( fox ). All the examples I see out there are using Web API on the back end and using POST and GET. I realize this is the preferred way to do things. Ultimately, my WWC apps will be replaced with Web APi's, but for now...
I simply want to call my service, script map style, pass in a username and password, then get back a string just like I would do from within a FoxPro app using WW's wwhttp and post keys. Ultimately, if I can technically do this, I would be able to use my existing WWC apps to fetch all kinds of data in JSON format and deserialize it in Fox or C#.
Has anyone tried to hit a WWC fox service using HTTPClient in a C# app without prepping for POST and GET, headers and all of that.
Thanks in advance!!
West Wind Technologies
Making waves on the Web
from Maui
Basically, I'm just getting started down this path with Xamarin and trying to create an iOS app that will work as a supplement to my FoxPro app that relies heavily on WWC for data.
I see a lot of examples that look like this, which conforms with the web api routing architecture :
private const string ApiBaseAddress = "http://api.tekconf.com/v1/";
private HttpClient CreateClient ()
{
var httpClient = new HttpClient
{
BaseAddress = new Uri(ApiBaseAddress)
};
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return httpClient;
}
The first thing that stands out in the above code is, do I have to : httpClient.DefaultReuestHeaders.Accept.Clear().... and then the following line.
Since my response from the following hit: https://myWWWCwebservice/method.sciptmap will be a JSON string, I assume I can just use Newtonsoft.JSON to serialize to an object and go from there.
BTW, I read your article on the Cordova extensions for VS. Very thorough. How did you overcome the CORS ( cross scripting ) issue with javascript? I have the DevExtreme ( DevExpress ) mobile libraries and have played with them but I came away thinking that I was going to have to build a WCF backend or certainly a Web API with CORS compliance and I was just hoping to tap into the WWC apps I already have. I know these questions are somewhat juvenile, but after almost 30 years as a VFP guy, I'm a bit intimidated by all of this ever changing new stuff and am hoping to get some real traction by doing it every day and finally producing a production app in C#. Xamarin, particularly Xamarin forms looks promising if you want to go native on iOS and Android without having to do Objective C or Java. Phonegap vs Xamarin is the soundtrack to my career as of late :)
Thanks for your timely response. You're the best!!!
Gary
---------------
Gary,
Sure that will work just fine. THe only difference is that your URLs will probably look a little more 'page' centric, but otherwise it's all just HTTP.
I've built a few Cordova apps that talk to Web Connection web back ends and no problem there.
What specific issue are you worried about?
+++ Rick ---
Hi,
I'm experimenting with Xamarin, using VS and C# and trying to do simple things like calling a production WWC service ( fox ). All the examples I see out there are using Web API on the back end and using POST and GET. I realize this is the preferred way to do things. Ultimately, my WWC apps will be replaced with Web APi's, but for now...
I simply want to call my service, script map style, pass in a username and password, then get back a string just like I would do from within a FoxPro app using WW's wwhttp and post keys. Ultimately, if I can technically do this, I would be able to use my existing WWC apps to fetch all kinds of data in JSON format and deserialize it in Fox or C#.
Has anyone tried to hit a WWC fox service using HTTPClient in a C# app without prepping for POST and GET, headers and all of that.
Thanks in advance!!
All of this will work just fine with Web Connection. If you're using the wwRestProcess class most of this is all handled for your automatically.
This class is all set up to handle JSON requests and output - all you do is write methods that receives and returns data. All the serialization is taken care of for you.
As to the .NET code - yes you will will want to add the header. wwRestService will default to JSON if it's missing, but it's best to be explicit and say that you are expecting JSON back. The service also supports XML responses from the same service methods.
I believe there are overloads for HttpClient that support automatic deserialization from JSON. There should be Post<T> and Get<T> etc. methods, but I'm not sure what Xamarin supports exactly. Otherwise - yes you can use JSON.NET to deserialize the result data.
Cross site scripting is not an issue in Cordova apps - the runtime sets up the browser security to not check for that. But regardless you can use CORS headers on the server to allow the cross domain access by sending the Access-Control-Allow-Origin header from the server:
loResponse.AppendHeader("Access-Control-Allow-Origin","*")
which then makes it possible for the client to access the remote even with browser requests.
+++ Rick ---
Thanks Rick!
Basically, I'm just getting started down this path with Xamarin and trying to create an iOS app that will work as a supplement to my FoxPro app that relies heavily on WWC for data.
I see a lot of examples that look like this, which conforms with the web api routing architecture :
private const string ApiBaseAddress = "http://api.tekconf.com/v1/";
private HttpClient CreateClient ()
{
var httpClient = new HttpClient
{
BaseAddress = new Uri(ApiBaseAddress)
};
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return httpClient;
}
The first thing that stands out in the above code is, do I have to : httpClient.DefaultReuestHeaders.Accept.Clear().... and then the following line.
Since my response from the following hit: https://myWWWCwebservice/method.sciptmap will be a JSON string, I assume I can just use Newtonsoft.JSON to serialize to an object and go from there.
BTW, I read your article on the Cordova extensions for VS. Very thorough. How did you overcome the CORS ( cross scripting ) issue with javascript? I have the DevExtreme ( DevExpress ) mobile libraries and have played with them but I came away thinking that I was going to have to build a WCF backend or certainly a Web API with CORS compliance and I was just hoping to tap into the WWC apps I already have. I know these questions are somewhat juvenile, but after almost 30 years as a VFP guy, I'm a bit intimidated by all of this ever changing new stuff and am hoping to get some real traction by doing it every day and finally producing a production app in C#. Xamarin, particularly Xamarin forms looks promising if you want to go native on iOS and Android without having to do Objective C or Java. Phonegap vs Xamarin is the soundtrack to my career as of late :)
Thanks for your timely response. You're the best!!!
Gary
---------------
Gary,
Sure that will work just fine. THe only difference is that your URLs will probably look a little more 'page' centric, but otherwise it's all just HTTP.
I've built a few Cordova apps that talk to Web Connection web back ends and no problem there.
What specific issue are you worried about?
+++ Rick ---
Hi,
I'm experimenting with Xamarin, using VS and C# and trying to do simple things like calling a production WWC service ( fox ). All the examples I see out there are using Web API on the back end and using POST and GET. I realize this is the preferred way to do things. Ultimately, my WWC apps will be replaced with Web APi's, but for now...
I simply want to call my service, script map style, pass in a username and password, then get back a string just like I would do from within a FoxPro app using WW's wwhttp and post keys. Ultimately, if I can technically do this, I would be able to use my existing WWC apps to fetch all kinds of data in JSON format and deserialize it in Fox or C#.
Has anyone tried to hit a WWC fox service using HTTPClient in a C# app without prepping for POST and GET, headers and all of that.
Thanks in advance!!
West Wind Technologies
Making waves on the Web
from Hood River
Thanks Rick.
Gary
All of this will work just fine with Web Connection. If you're using the wwRestProcess class most of this is all handled for your automatically.
This class is all set up to handle JSON requests and output - all you do is write methods that receives and returns data. All the serialization is taken care of for you.
As to the .NET code - yes you will will want to add the header. wwRestService will default to JSON if it's missing, but it's best to be explicit and say that you are expecting JSON back. The service also supports XML responses from the same service methods.
I believe there are overloads for HttpClient that support automatic deserialization from JSON. There should be Post<T> and Get<T> etc. methods, but I'm not sure what Xamarin supports exactly. Otherwise - yes you can use JSON.NET to deserialize the result data.
Cross site scripting is not an issue in Cordova apps - the runtime sets up the browser security to not check for that. But regardless you can use CORS headers on the server to allow the cross domain access by sending the Access-Control-Allow-Origin header from the server:
loResponse.AppendHeader("Access-Control-Allow-Origin","*")
which then makes it possible for the client to access the remote even with browser requests.
+++ Rick ---
Thanks Rick!
Basically, I'm just getting started down this path with Xamarin and trying to create an iOS app that will work as a supplement to my FoxPro app that relies heavily on WWC for data.
I see a lot of examples that look like this, which conforms with the web api routing architecture :
private const string ApiBaseAddress = "http://api.tekconf.com/v1/";
private HttpClient CreateClient ()
{
var httpClient = new HttpClient
{
BaseAddress = new Uri(ApiBaseAddress)
};
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return httpClient;
}
The first thing that stands out in the above code is, do I have to : httpClient.DefaultReuestHeaders.Accept.Clear().... and then the following line.
Since my response from the following hit: https://myWWWCwebservice/method.sciptmap will be a JSON string, I assume I can just use Newtonsoft.JSON to serialize to an object and go from there.
BTW, I read your article on the Cordova extensions for VS. Very thorough. How did you overcome the CORS ( cross scripting ) issue with javascript? I have the DevExtreme ( DevExpress ) mobile libraries and have played with them but I came away thinking that I was going to have to build a WCF backend or certainly a Web API with CORS compliance and I was just hoping to tap into the WWC apps I already have. I know these questions are somewhat juvenile, but after almost 30 years as a VFP guy, I'm a bit intimidated by all of this ever changing new stuff and am hoping to get some real traction by doing it every day and finally producing a production app in C#. Xamarin, particularly Xamarin forms looks promising if you want to go native on iOS and Android without having to do Objective C or Java. Phonegap vs Xamarin is the soundtrack to my career as of late :)
Thanks for your timely response. You're the best!!!
Gary
---------------
Gary,
Sure that will work just fine. THe only difference is that your URLs will probably look a little more 'page' centric, but otherwise it's all just HTTP.
I've built a few Cordova apps that talk to Web Connection web back ends and no problem there.
What specific issue are you worried about?
+++ Rick ---
Hi,
I'm experimenting with Xamarin, using VS and C# and trying to do simple things like calling a production WWC service ( fox ). All the examples I see out there are using Web API on the back end and using POST and GET. I realize this is the preferred way to do things. Ultimately, my WWC apps will be replaced with Web APi's, but for now...
I simply want to call my service, script map style, pass in a username and password, then get back a string just like I would do from within a FoxPro app using WW's wwhttp and post keys. Ultimately, if I can technically do this, I would be able to use my existing WWC apps to fetch all kinds of data in JSON format and deserialize it in Fox or C#.
Has anyone tried to hit a WWC fox service using HTTPClient in a C# app without prepping for POST and GET, headers and all of that.
Thanks in advance!!