Moved Permanently error when calling a PHP WebService from .NET - c#

I have developed a WebService in PHP... it works perfectly when I call it from a PHP application, but I have problems when calling from .NET.
The error I am received when I call a web method is "Moved Permanently".
The WSDL of the service is at: http://feriados.servicios.desytec.com/feriados?wsdl
And the .NET code is the following:
private void button1_Click(object sender, EventArgs e)
{
Servicio.Desytec_Feriados svc = new Servicio.Desytec_Feriados();
var feriados = svc.GetHolidays("8cd4c502f69b5606a8bef291deaac1ba83bb9876", "cl", "2014", "5");
System.Diagnostics.Debug.WriteLine(feriados.Length);
}

It was due because the URL of the WSDL was bad specified. It was written as http://destec.com/app.php/feriados, but the correct is http://destec.com/feriados, because .htaccess is stripping the app.php part (the webservice was programmed using Symfony PHP framework).
Regards
Jaime

Related

The request could not be completed (Not Found)

I have added a vanilla mobile service, selecting the defaults all the way. It is a .Net backend, using a new 20MB DB on an existing server I use in the North Europe DC. I created a blank Windows Store App, added the MobileServices nuget package and then followed the instructions to connect my MobileService to my app by adding the MobileServicesClient to my App.xaml class. Then I added a button with an event handler. The handler calls an async function to insert a TodoItem object into the database.
App.xaml.cs
public static MobileServiceClient MobileService = new MobileServiceClient(
"https://???.azure-mobile.net/",
"???");
I have replaced the URI and Token with ???. The one I used came from my Azure Portal for this Mobile Service.
MainPage.xaml.cs
private void Button_Click(object sender, RoutedEventArgs e)
{
CreateItem();
}
private async void CreateItem()
{
TodoItem item = new TodoItem { Text = "Sort This", Complete = false };
try
{
await App.MobileService.GetTable<TodoItem>().InsertAsync(item);
}
catch(MobileServiceInvalidOperationException ex1)
{
Debug.WriteLine(ex1.Message);
}
catch(Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
When I run this code and click the button a MobileServiceInvalidOperationException is raised:
"{"The request could not be completed. (Not Found)"}"
I am using VS2013, with Service Pack 2 installed and WindowsAzure.MobileServices 1.2.3.
The MobileService is running as I can navigate to https://MyMobileService.azure-mobile.net/ but, if I click Check It Out, I am asked to Authenticate (MyMobileService is not the actual Uri).
The post request looks ok, but the response is a 404.
I have been working on this all day, including using Windows Phone, with no luck...
I know I must be doing something wrong, or there is an issue with Azure in Northern Europe, but I can't sort it out.
Any help much appreciated.
Jason.
I had the same issue awhile ago. I switch from .net backend to javascript. Also, make sure your mobileservice and db schema match.

WP7 WebClient cannot find specific server

Ok, maybe this is the dumbest question ever but I really can't understand what's happening :D
I have this simple code:
private void button1_Click(object sender, RoutedEventArgs e)
{
Uri url = new Uri("http://www.something.com/");
WebClient wc = new WebClient();
wc.DownloadStringAsync(url);
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
}
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
string result = e.Result;
}
It works well, except for one case (obviously the one that I need), when the address of the server is "ts4.travian.it". In this case I get this error: "The remote server returned an error: NotFound."
The strange thing is that if I write a small console application with basically the same code, it works...any idea?
EDIT: To be more specific, the server return error 403 - Forbidden, but if I try the same code in a Console Application, it works perfectly...don't know what to think..I'm debugging the application on a Nokia Lumia 800
I found the problem finally. The Silverlight framework automatically set the Referer header of the HttpWebRequest, and the server "ts4.travian.it" refused it because it was not correct.
Did you forget to provide the output for that one case?
Edit:
Status code '403' implies that there' something the server doesn't like in your app. Who knows maybe it checks your UA string and sees that you're using IE Mobile i guess. Than he desides not to allow you see the content. Hm?

Using a JSON REST Service in Silverlight 4

I need to use a JSON REST Service inside my Silverlight Application so that I can display information from the REST service in my Silverlight App. Below is my code but the ClientDownloadStringCompleted() is never stepped into and I'm not sure why. The REST service does have data and is working. I just can't seem to access it so I can parse out the data I need. View of the JSON Service
string jsonlink = "http://hou-prodserver2/ArcGIS/rest/services/sar/ScheduledRig/MapServer/81/query?text=&geometry=&geometryType=esriGeometryPoint&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=MAXDATE%3E%271%2F1%2F1900%27&time=&returnCountOnly=false&returnIdsOnly=false&returnGeometry=false&maxAllowableOffset=&outSR=&outFields=MAXDATE&f=pjson";
var client = new WebClient();
client.DownloadStringCompleted += ClientDownloadStringCompleted;
client.DownloadStringAsync(new Uri(jsonlink, UriKind.Absolute));
Below is Method I'm trying to use to get access to the data but it never gets used
private void ClientDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
//handle the response.
string result = e.Result;
}
Make sure that service site has one or both of the following files at the root of the site:
crossdomain.xml
clientaccesspolicy.xml
If your Silverlight app is not on the same exact domain as the service, those files need to exist to allow it to connect. If they don't Silverlight fails silently.

How do I utilize Webclient.DownloadFile or DownloadString if the website uses SSL?

I'm writing a small utility that scrapes a webpage and emails me if the class I want has open seats. See the follow url:
Math Classes
However, I get an error everytime I execute the following code:
private void timer1_Tick(object sender, EventArgs e)
{
using (WebClient client = new WebClient())
{
//var html = client.DownloadString("https://grim.westga.edu/pls/UWGP_DAD/hwwkbull.p_us_subj_list?term_code=201108&subj=math&levl=US");
client.DownloadFile(#"https://grim.westga.edu/pls/UWGP_DAD/hwwkbull.p_us_subj_list?term_code=201108&subj=math&levl=US", #"C:\file.txt");
}
}
Any idea?
That link you posted also supports simple HTTP.
See here: http://grim.westga.edu/pls/UWGP_DAD/hwwkbull.p_us_subj_list?term_code=201108&subj=math&levl=US
Try removing your s from the url and see if that works.

How does one load a URL from a .NET client application

What is the preferred way to open a URL from a thick client application on Windows using C# and the .NET framework? I want it to use the default browser.
The following code surely works:
Process.Start("http://www.yoururl.com/Blah.aspx");
It opens the default browser (technically, the default program that handles HTTP URIs).
I'd use the Process.Start method.
private void launchURL_Click(object sender, System.EventArgs e){
string targetURL = "http://stackoverflow.com";
System.Diagnostics.Process.Start(targetURL);
}
System.Diagnostics.Process.Start("http://www.stackoverflow.com");

Categories

Resources