![]() |
How can I process an input parameter of a given "type"?
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(Names pace = "http://ns.hr-xml.org/2007-04-15", ElementName = "Assignment")] AssignmentType part) { .. .. .. } Thank you in advance for your time. C. |
Re: How can I process an input parameter of a given "type"?
"C." <C@discussions.microsoft.com> wrote in message
news:56E12B3C-2E07-4464-944B-A008E2812E06@microsoft.com... > 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(Names pace > = > "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/is...n/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. -- John Saunders [MVP] |
| All times are GMT. The time now is 04:04 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.