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

Discussion in 'ASP .Net Web Services' started by C., Aug 30, 2007.

  1. C.

    C. Guest

    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.
     
    C., Aug 30, 2007
    #1
    1. Advertising

  2. "C." <> wrote in message
    news:...
    > 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.
    --
    John Saunders [MVP]
     
    John Saunders [MVP], Aug 30, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lord0
    Replies:
    1
    Views:
    599
    Thomas Weidenfeller
    Apr 19, 2006
  2. chiara
    Replies:
    6
    Views:
    501
    Barry Schwarz
    Oct 6, 2005
  3. 2Barter.net
    Replies:
    0
    Views:
    396
    2Barter.net
    Dec 13, 2006
  4. Casey Hawthorne
    Replies:
    385
    Views:
    6,034
    ng2010
    Apr 4, 2010
  5. jcpc
    Replies:
    2
    Views:
    1,569
Loading...

Share This Page