dcidral
dcidral

Reputation: 257

Removing empty namespace from an ASMX WebService

I have a webservice with a XmlNode parameter (also I tried with XElement) and a XmlNode return type.

The problem is, I pass a parameter without a namespace like this:

<client>
    <name>Test</name>
</client>

and the server receive something like this:

<client xmlns="">
    <name>Test</name>
</client>

and the return object does the same.

Normally it wouldn't be a problem, but I use a custom checksum to validate the request. Something like pass the MD5 of the xml parameter to another parameter. And when the server declare the namespace, it breaks the MD5.

Now I'm removing the declaration with a replace to make the md5 works. Someone have a better idea? (without workarounds)

Upvotes: 3

Views: 1428

Answers (2)

Kirk Broadhurst
Kirk Broadhurst

Reputation: 28728

I am not sure why you'd validate XML using MD5. A better idea would be to validate your XML using an XSD.

There are a number of existing questions about how to validate XML against an XSD in C#

Upvotes: 1

Omnia9
Omnia9

Reputation: 1573

Are you using WCF services? Or could you migrate to them?

Could you not apply this tag to your DataContracts?

[DataContract(Namespace = "")]

That way the data will not have any namespaces at all.

Is something like this post possible?

Can I make XmlSerializer ignore the namespace on deserialization?

Upvotes: 0

Related Questions