Sandip's Programming Zen

An attempt to share tech/coding experiences

Posts Tagged ‘Asp.Net

Calling Asp.Net web service from PHP

with 20 comments

I just had a scenario where one of our client needs to consume our Asp.Net web service in their PHP host application.

Calling Asp.Net web service from PHP turned out to be easier then I thought. Here is how you can do.

First you need to download open source nusoap soap library, and put the lib folder under your application root directory. (I have renamed the folder name lib to nusoap in app directory).

The sample PHP code is below:

<?php
require_once(‘nusoap/nusoap.php’);

$client = new nusoap_client(‘http://www.yourdomain.com/service.asmx?WSDL&#8217;, ‘wsdl’,”, ”, ”, ”);

$err = $client->getError();
if ($err) {
echo ‘<h2>Constructor error</h2><pre>’ . $err . ‘</pre>’;
}
$param = ”;
$result = $client->call(‘functionName’, $param, ”, ”, false, true);

if ($client->fault) {
echo ‘<h2>Fault</h2><pre>’;
print_r($result);
echo ‘</pre>’;
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo ‘<h2>Error</h2><pre>’ . $err . ‘</pre>’;
} else {
// Display the result
echo ‘<h2>Result</h2><pre>’;
print_r($result);
echo ‘</pre>’;
}
}
?>

Of course, you can do much more than this, check out samples provided in downloaded nusoap source.

Advertisements

Written by Sandip

April 4, 2009 at 11:06 am

Posted in .Net, PHP, Programming

Tagged with ,

Backbase Ajax Framework with Asp.Net

with one comment

Since couple of months we are working on a new project based on Asp.Net 3.5 Framework which is using Backbase as a client rendering framework. Backbase provides a rich user interface which is independent of development platform. It sure has a learning curve but once you are through that phase you will see the real advantage of RAD.

If you are trying to use Backbase with Asp.Net and have any questions then I may try to answer them since we have passed that phase of sorting out initial hiccups.

Written by Sandip

April 3, 2009 at 3:06 am

Posted in .Net, Programming

Tagged with , ,

JQuery Validation Plugin and Asp.Net MVC

with 2 comments

Asp.Net MVC is a great framework. But, developers coming from Webforms background will find it little bit difficult not having a set of Validation controls which automatically validates form input by user. JQuery is a part of Asp.Net MVC application and I just found a nice JQuery plugin which fills the gap of Validator Controls of Webforms. It can be downloaded from here.

There are enough examples which coveres most of the routine validation needs and using it is as easy as Webforms validator controls.

Written by Sandip

April 2, 2009 at 10:33 am

Posted in .Net

Tagged with , ,

Running Asp.Net 1.1 and 2.0 together in Windows 64-bit environment

leave a comment »

To be noted, Microsoft is not going to release 64-bit version of .Net framework 1.1. So installing it on Windows 2003 64-bit OS will require it to run in “32-bit mode”. Normally this is done easily when you try to install FW 1.1 on OS it will ask you to run a command during installation and that enables IIS to run FW 1.1 in 32-bit mode.

Asp.Net Tab in IIS MMC will be missing so assigning different FW version to different websites should be done using command line tool : aspnet_regiis.exe (it is separate for each FW version and can be found in framework directory e.g. C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322)

Examples:
aspnet_regiis.exe -s W3SVC/1/ROOT/<yourappname>       (for recursive update)
aspnet_regiis.exe -sn W3SVC/1/ROOT/<yourappname>     (for non-recursive update)

For more details visit here.

Written by Sandip

June 26, 2008 at 10:45 am

Posted in Troubleshooting

Tagged with , ,

“Page cannot be displayed” Error on Asp.Net post back

with 8 comments

If you have above error displayed as soon as you do post back on your page while rest of your app is still working then you might have huge viewstate data in your page.

Normally it happens when you are loading a page displaying several hundreds records, that may generate very big viewstate value inside your page. The loading will work fine but as soon as you post back the page it will throw that error. Reason is your page becomes too bulky to be accepted by server.

To solve the problem you obviously have to reduce the side of the viewstate by either disabling viewstate on your page or disable on selected controls where it is not needed, if both of these is not possible then simply reduce the number of records displayed at a time.

Ok, that’s a generic solution but in Asp.Net framework 2.0 you can handle it by using an in-built feature called “Viewstate chunking”, this will chunk out the viewstate data so that not a single large element is generated.

Update: If you are using framework 1.1 then there is an option of in-memory viewstate compression. Check this link for more details ( I have implemented it using vb.net so you can ask me for help).

Written by Sandip

June 6, 2008 at 9:57 am

Posted in .Net

Tagged with

C# 3.0 Language Enhancements

leave a comment »

I am trying to summarize some of the most visible new C# 3.0 new language features. Here they go…

Automatic properties

Create properties in a single line

public string FirstName { get; set; }

  • No internal field required
  • Similar to property interface definition
  • Easy to upgrade when logic is required

Object initialisers

Quickly initialize properties on new objects

User user = new User { FirstName=”JD” };

  • Provides short hand object creation

Collection Initialisers

Similar to object initialisers

List<User> users = new List<User>
{
new User(),
new User()

};

Extension methods

Add new methods to existing types

public static bool ReturnTrue(this string s)
{
return true;
}

  • Specific to a given namespace
  • Potential upgrade path issues

Implicit types

Infer a type

var number = 600;

int number = 600;

Type is defined at compile time (statically type)

Partial Methods

  • Methods in partial classes
    • One with implementation
    • One without implementation
  • Primary designed for code-gen

partial void MyMethod();

partial void MyMethod()

{

//method body

}

Lambda Expressions

  • Powerful addition for querying
  • Lambda calculus
  • Introduces the => operator

U => U.FirstName.Length > 5

  • Requires value on variable creation
  • Required for anonymous types

LINQ

  • Language INtegrated Query
  • Provides new syntax for querying using Lambda Expressions

    If you know any more interesting features then put them in your comments here.

    Written by Sandip

    February 2, 2008 at 7:08 pm

    Posted in .Net

    Tagged with , , ,