Connecting Tech Pros Worldwide Help | Site Map

Validate Xml from Serialized Web Service Proxy Class throws on soap Array

 
LinkBack Thread Tools Search this Thread
  #1  
Old June 27th, 2008, 07:20 PM
Joris van Lier
Guest
 
Posts: n/a
Default Validate Xml from Serialized Web Service Proxy Class throws on soap Array

Hi, im trying to validate objects before they are sent over the wire to a
webservice,
the schema embedded into WSDL is not sufficient so i took that schema and
extended it with additional restrictions,
after conversion from local domain class into remote domain class the remote
class (generated from WSDL) is serialized to XML and validated using the
schema, this throws "Undefined complexType
http://schemas.xmlsoap.org/soap/encoding/:Array is used as restriction of
complex type" (translated)


How do i add this schema or map the soap array to another type?

private void ValidateRemoteDomainObject(remote.webservice.entit y o)
{
MemoryStream ms = new MemoryStream();
XmlSerializer xs = new XmlSerializer(o.GetType());
xs.Serialize(ms, o);
ms.Position = 0;
ValidateXmlSchema(new StreamReader(ms), "Schema.xsd");
}


void ValidateXmlSchema(TextReader reader, string schemaUri)
{
XmlReaderSettings xrs = new XmlReaderSettings();
xrs.ValidationType = ValidationType.Schema;
xrs.ValidationFlags &=
~XmlSchemaValidationFlags.AllowXmlAttributes;
xrs.ValidationFlags |=
XmlSchemaValidationFlags.ReportValidationWarnings;
xrs.ValidationEventHandler += new
ValidationEventHandler(ValidationEventHandler);
XmlSchema schema = XmlSchema.Read(
XmlReader.Create(schemaUri), this.ValidationEventHandler);
xrs.Schemas.Add(schema);
XmlReader xr = XmlReader.Create(reader, xrs);
while(xr.Read()){
// do something with node
}
}


void ValidationEventHandler(object sender, ValidationEventArgs e)
{
throw new ApplicationException(
String.Format("{0}", new object[] {e.Message}),
e.Exception
);
}


Joris van Lier


  #2  
Old June 27th, 2008, 07:20 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: Validate Xml from Serialized Web Service Proxy Class throws onsoap Array

Joris van Lier wrote:
Quote:
Hi, im trying to validate objects before they are sent over the wire to
a webservice,
the schema embedded into WSDL is not sufficient so i took that schema
and extended it with additional restrictions,
after conversion from local domain class into remote domain class the
remote class (generated from WSDL) is serialized to XML and validated
using the schema, this throws "Undefined complexType
http://schemas.xmlsoap.org/soap/encoding/:Array is used as restriction
of complex type" (translated)
You need a schema for the namespace
http://schemas.xmlsoap.org/soap/encoding/ that defines the Array type. I
am not sure whether the various soap specifications define a schema,
perhaps someone in microsoft.public.dotnet.framework.aspnet.webservic es
knows more.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.