Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Services (http://www.velocityreviews.com/forums/f64-asp-net-web-services.html)
-   -   How can I process an input parameter of a given "type"? (http://www.velocityreviews.com/forums/t787256-how-can-i-process-an-input-parameter-of-a-given-type.html)

C. 08-30-2007 04:36 PM

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.


John Saunders [MVP] 08-30-2007 07:15 PM

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57