Strict Standards: Redefining already defined constructor for class wpdb in /home/hassan/subdomains/blog/wp-includes/wp-db.php on line 56

Deprecated: Assigning the return value of new by reference is deprecated in /home/hassan/subdomains/blog/wp-includes/cache.php on line 36

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /home/hassan/subdomains/blog/wp-includes/cache.php on line 384

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 560

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el($output) in /home/hassan/subdomains/blog/wp-includes/classes.php on line 684

Deprecated: Assigning the return value of new by reference is deprecated in /home/hassan/subdomains/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/hassan/subdomains/blog/wp-includes/theme.php on line 540
Invoke .Net 2.0 Web Services with 1.0 client
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 627

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 691

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 692

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 627

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 691

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 692

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 627

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 691

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 692

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 627

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 691

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/kses.php on line 692

Invoke .Net 2.0 Web Services with 1.0 client

Filed Under
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/formatting.php on line 82
Development


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/hassan/subdomains/blog/wp-includes/formatting.php on line 82

The other day a co-worker got into a situation in which he tried to invoke a Web Service but was getting unexpected or no results. He was upgrading/maintaining an application that was written in .Net 1.1. Parts of his maintenance tasks were to invoke a service that was recently deployed in the company.

I took a look at the services WSDL and realized that his problem is probably due to the fact the WebService was using Nullable Types which were introduced in .Net 2.0. At first that may not seem like an issue.

A Nullable Type for say, int, is used to hold all the possible values of int and a null value. In pre 2.0 days, this was not possible resulting in a multitude of work-arounds. But since 2.0 it is possible to give a variable of type Nullable int a value of null to indicate that the variable has not been instantiated or assigned.

So in this particular case, any use of Nullable Types in the Web Service were being treated as optional parameters.

When using Visual Studio 2003 to add a Web Service Reference or manually executing Wsdl.exe that comes with .Net SDK (1.0 and 1.1), the proxy that is generated is does not take into account Nullable Types because the concept did not exist at the time these tools came out. The generated proxy represents an int? as just int. If this proxy was used to call the Service, it would pass a 0 for that field as a default value rather than null which in turn would cause the WebService to think the client intended to pass a 0.

A quick fix to this problem is to manually edit the proxy after it has been generated and change the type of the fields/properties to string. System.String is capable of holding a range of characters and a null value. The drawback will be that the proxy will not be a 100% strongly typed, but this can be fixed with encapsulation of the filed/property.

Comments

Leave a Reply