xsi and xsd - Namespace Prefixes

Topics: Technical Questions
Jul 30, 2009 at 10:41 PM

Hi,

When consuming an existing service (out of my control to change anything), I am getting the following:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

 

After exposing the service in MSE, I am getting the reduced version as follows:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

 

This leads to my generated code in VS to crash with the exception under. It has been generated from the MSE wsdl.

[...].ScoreTest threw exception: System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'score'. ---> System.InvalidOperationException: There is an error in XML document (62, 42). ---> System.InvalidOperationException: Namespace prefix 'xsd' is not defined[...] 

 

The line in question is <ns1:val xsi:type="xsd:string">PP06</ns1:val> 

 

Any thoughts on how I can solve the exception problem?

 

Best regards
Henrik

 

Developer
Jul 31, 2009 at 2:31 AM

Taking it offline:

Jul 31, 2009 at 7:44 AM
naveedzaheer wrote:

Taking it offline:

 Sent you a mail. Thanks for replying so fast.

Aug 4, 2009 at 6:11 PM

Hi all,

I fixed this yesterday by creating a WCF Behavior and using a policy on the endpoint containing the behavior and the parameters for prefix and namespace. Really standard WCF stuff, but it feels like patching a bug but leaving the bug in place. I don't think the incoming message should loose namespaces, but I'm no expert. Maybe it won't affect anything but the SOAP constructs (envelope, header, body)?

Anyway, this fixed my issue quickly.

/Henrik

Jul 29, 2010 at 8:01 PM
h3nr1k wrote:

Hi all,

I fixed this yesterday by creating a WCF Behavior and using a policy on the endpoint containing the behavior and the parameters for prefix and namespace. Really standard WCF stuff, but it feels like patching a bug but leaving the bug in place. I don't think the incoming message should loose namespaces, but I'm no expert. Maybe it won't affect anything but the SOAP constructs (envelope, header, body)?

Anyway, this fixed my issue quickly.

/Henrik

 May I ask how did you fix it? I mean how to add the prefix into the incomming message in WCF?

 

I am having this "Namespace prefix 'xsd' is not defined." exception in my WCF service and have not found an answer for it.

Thanks

 

Frank