j2me and IIS encoding issue - iis

I am developing a mobile app in J2ME and using IIS as my server. The IIS answers me with a Redirect page, and the new link comes this way:
"%2f(S(lgwodijh5nfd43da5354w3za))%2findex.aspx%3fa%3dvalidate"
I try to redirect to the new page like this:
conn = ( HttpConnection ) Connector.open( url );
is = conn.openInputStream();
And it gives me a Connection not found exception.
When I have the new link like this:
"/(S(lgwodijh5nfd43da5354w3za))/index.aspx?a=validate"
it works.
Is there a way in J2ME to encode the new URL to make it work? or a way to change IIS settings to send me the new link without the %2f characters?
Thanks!

Related

Getting current server name for URL build XPages

I am trying to build a URL for my XPages application,but having problem geting the current server name, can anyone help me with these?
RT.appendText("http://localhost/" +dbname+"/store.xsp?documentId="+UNID+"&action=openDocument")
You may want to handle HTTPS too:
var url = context.getUrl();
url.getScheme() + "://" + url.getHost()
If you need to get the server part from the url
context.getUrl().toString().split(facesContext.getExternalContext().getRequest().getRequestURI())[0]
I got this string from
http://xpagescheatsheet.com/cheatsheet.nsf/url.xsp
In case you are actually looking for the server host name (which is part of the URL) and not the Domino server name, then you can do the following:
return context.getUrl().toString().split(facesContext.getExternalContext().getRequest().getRequestURI())[0]
David Leedy has created a XPages URL cheatsheet with more details on URL handling.

Why is Facebook throwing an error when I edit App Domains?

I registered a .cc domain name (www.kreative.cc). But when I type "kreative.cc" in the App Domains field in the application manager I got an error
Erro There was a problem saving your changes. Please try again later.
I did test other urls and they're all right.
I've been trying for a couple of days. What can I do?
you can use the facebook graph api to write your app settings, seems that facebook is not validating the input this way. here is a simple example in php:
<?php
include 'Zend/Http/Client.php';
$http = new Zend_Http_Client('https://graph.facebook.com/MY_APP_ID');
$http->setMethod('POST');
$http->setParameterPost(array(
'access_token' => 'MY_APP_ACCESS_TOKEN',
'app_domains' => array('mydomain.cc'),
'website_url' => 'http://mydomain.cc',
'page_tab_url' => 'http://mydomain.cc',
'secure_page_tab_url' => 'https://mydomain.cc',
));
$response = $http->request()->getBody();
Try leaving the Apps Domain field empty while filling up the rest of the fields - be it Page Tab of Facebook App. That worked for me.
I have the same problem. I`m following the Developers Bug Report http://developers.facebook.com/bugs/130468767129410
If you fill App Domain Name with the site IP you'll got success. Ex: http://50.23.134.34 instead of http://www.kreative.cc.

Programmatically connect to ASP.NET WebAPI sitting behind ForeFront UAG

I have a WebAPI built using ASP.NET MVC4. It is a simple API for getting data (simple HTTP GET requests). The API is stable and has been working with our mobile (MonoTouch) app for quite some time. Now we're putting ForeFront UAG in front of the API (simply changed web.config to use windows auth. Testing the security and API through a browser e.g. Chrome, and the UAG login is presented (when hitting API first time). Enter your credentials and then you get the data back for the API GET request. All what you'd expect. Now, from .NET code (no browser) I want to do the same thing. I've seen examples accessing SharePoint programmatically and some windows phone stuff, but none of them seem to work for ASP.NET MVC4 WebApi calls from just regular old .NET code (which I'll eventually use in MonoTouch).
Anyone have an example of how to Authenticate and then make HTTP GET request successfully through UAG to an ASP.NET MVC4 WebApi?
I don't have the disposal over a ForeFront UAG so I can't test this. But in general you have a few options. The samples are snippets and some code is left out for readability.
WebClient / HttpWebRquest
CredentialCache credentials = new CredentialCache();
credentials.Add(new Uri(url), "NTLM", new NetworkCredential(userName, password, domain));
//WebClient
var webClient = new WebClient();
webClient.Credentials = credentials;
//HttpWebRequest
var request = HttpWebRequest.Create(url);
request.Credentials = credentials
HttpClient
WebRequestHandler clientHandler = new WebRequestHandler();
clientHandler.UseDefaultCredentials = true;
clientHandler.AllowPipelining = true;
clientHandler.ImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
ProgressMessageHandler progress = new ProgressMessageHandler();
httpClient = HttpClientFactory.Create(clientHandler, progress);
You have also the options of using third party libraries to get this job done, like RestSharp or Service Stack.
Personally I make use of RestSharp because of the ease of use and serializing/deserializing capabilities.

Kohana - Facebook app URL

I'm developing my first facebook app on kohana 2.3.x at the moment and I noticed that a usual app url should look like this:
http://apps.facebook.com/{my_app}/{controller}/{method}
But in my app it shows the real url.
http://mydomain.com/{controller}/{method}
Any idea how to fix that in Kohana?
Thanks in advance!
Try changing this in application/config/config.php:
$config['site_domain'] = 'apps.facebook.com/my_app/';

Sharepoint Lists.asmx: The request failed with an empty response

I'm writing a very small app to create and test caml querys for sharepoint. While executing the GetListItems method I'm receiving the following exception;
System.Net.WebException: "The request failed with an empty response."
The service is located on a https address (ssl). I setup the service as follows;
result = new ListService.Lists();
result.Url = siteUrl;
result.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
I invoke the GetListItems() method as follows;
xmlResult = spList.GetListItems(listName, string.Empty, camlQuery, null, string.Empty, null, string.Empty);
I'm trying to find out why I'm getting the empty result message. I've also tried other methods (i.e. GetListCollection) but to no avail.
At first I thought that the problem might be the URL (http instead of https), but that is not the case. I even checked it with wireshark to make sure the right URL is used.
Did someone come accross this problem and how did you solve it?
OMG...! I've solved it after all. After posting this question, I tried to get hold of the wsdl the check the service itself. When I checked it via internet explorer all was ok. When I tried to add it as a reference in VS it went wrong. So something was not ok. Then it occured to me that there was a new login screen for our company network.
After some quick phonecalls I learned what the problem was; IT Services installed a ISA 2006 server and 'forgot' to tell me. The ISA server was blocking all trafic on the HTTPS port (443) for unkown programs and or clients. That's why internet explorer presented me with a new and shiny login dialog.

Resources