How can I process an input parameter of a given "type"?

C

C.

Hello,

I have a Web Service that receives an XmlDocument of a given type. But I can
not get the contents of what is being passed other than extracting it from
the HttpContext.Current.Request.InputStream and this requires removing the
SOAP envelope manually and using the nsManager and a lot of unnecessary extra
lines of code before I can validate the schema. I was assuming I can get the
content from “part†but is null. Is there any other way than using the
HttpContext?

[Webmethod]
public XmlDocument
ProcessAssignments([System.Xml.Serialization.XmlElementAttribute(Namespace =
"http://ns.hr-xml.org/2007-04-15", ElementName = "Assignment")]
AssignmentType part)
{
..
..
..
}

Thank you in advance for your time.

C.
 
J

John Saunders [MVP]

C. said:
Hello,

I have a Web Service that receives an XmlDocument of a given type. But I
can
not get the contents of what is being passed other than extracting it from
the HttpContext.Current.Request.InputStream and this requires removing the
SOAP envelope manually and using the nsManager and a lot of unnecessary
extra
lines of code before I can validate the schema. I was assuming I can get
the
content from “part†but is null. Is there any other way than using the
HttpContext?

[Webmethod]
public XmlDocument
ProcessAssignments([System.Xml.Serialization.XmlElementAttribute(Namespace
=
"http://ns.hr-xml.org/2007-04-15", ElementName = "Assignment")]
AssignmentType part)
{
.
.
.
}

It sounds like you have several problems here:

1) When your service is called, "part" is null. This is usually caused by
the client sending XML that is not in the correct namespace. You'll want to
take a close look at what is being sent, possibly by using a network tracing
tool like Microsoft Network Monitor, or ProxyTrace from www.pocketsoap.com.
2) You want to be able to validate the XML against the set of schemas. See
the article "Extend the ASP.NET WebMethod Framework by Adding XML Schema
Validation" at
http://msdn.microsoft.com/msdnmag/issues/03/07/XMLSchemaValidation/default.aspx. I
use a modification of this code, and validate both incoming _and outgoing_
XML. It saves a lot of time, since I use a hand-created schema. The schema
validation catches many errors, so that I don't have to manually validate
all the attributes. I only need to "manually" validate what the schema
validation would allow to pass.

Let us know if you have more questions on this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top