Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6922477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:24:40+00:00 2026-05-27T10:24:40+00:00

I have a generated stub for a .net web service which has several string

  • 0

I have a generated stub for a .net web service which has several string properties. Given some response from the web service, can these properties have a null value or are they always at least converted to a string.Empty?

Are they only possibly null if the ‘nillable=”true”‘ attribute is applied to them in the WSDL?

You see… I want to just start Trim()’ing the values of the properties without getting any null reference exceptions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:24:41+00:00Added an answer on May 27, 2026 at 10:24 am

    A server should serialize a null value as null, not String.Empty, unless there’s some additional logic put in place. If you don’t wanna write a bunch of null checks, consider making an extension method for trim.

    public static string TrimOrEmpty(this string val)
    {
        if (val == null) { return string.Empty; }
        return val.Trim();
    }
    

    Edit: Or go with Anders’ more streamlined version. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using gSOAP as a Web Service toolkit and have generated the stub
Using axis2's wsdl2java tool and a third-party wsdl I have generated service stub and
I have to use a 3rd party web service implemented in .NET 2.0 (on
I am trying to hit the following web service with axis2: http://www.webservicex.net/geoipservice.asmx?WSDL I have
I have generated a collection of images. Some of them are blank as in
I have generated using openssl mycert.pem which contents the certificate. And I converted the
I need to consume an existing web service in ASP.net. The documentation of the
I have written some thing like this to fetch data from the database. public
I have a Horizontal Layout in which some vertical layouts are dispatched. I want
I have MainActivity which does some Work before it Executes an AsyncTask called Datensammlung.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.