This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Mock exam question: SOAP doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Mock exam question: SOAP doubt" Watch "Mock exam question: SOAP doubt" New topic
Author

Mock exam question: SOAP doubt

Asit Baran
Greenhorn

Joined: Oct 13, 2008
Posts: 25
SOAP Message :
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<p:Process xmlns:p='http://example.org/Operations'>
<m:Envelope xmlns:m='http://schemas.xmlsoap.org/soap/envelope/'>
.......
</m:Envelope>
</p:Process>
</soap:Body>
</soap:Envelope>
What is going to happen when a Web service (whose implementation conforms to WS-I Basic Profile 1.0a) receives the following SOAP message?
Ans:
  • Generate a fault for the SOAP Message
  • Process the message for the SOAP Message

  • What will be the answer?

    Actually I'm not sure whether a soap:Header or soap:Body can have child elements which belongs to this 'http://schemas.xmlsoap.org/soap/envelope/' namespace. Can we have an 'soap:Envelope' within 'soap:Body' or 'soap:Body' within another 'soap:Body'? Is there any restrictions on that? While searching BP rules, I only got this,
    R1003 A RECEIVER MUST accept fault messages that have any number of qualified or unqualified attributes, including zero, appearing on the detail element. The namespace of qualified attributes can be anything other than "http://schemas.xmlsoap.org/soap/envelope/".

    Is there any other restrictions like this? Please clarify.
    Ivan Krizsan
    Ranch Hand

    Joined: Oct 04, 2006
    Posts: 2198
        
        1
    Hi!
    From the WS-I Basic Profile:
    R1009 An ENVELOPE MUST NOT contain Processing Instructions.

    The envelope you enclosed contains a processing instruction, thus a fault will be generated.
    Best wishes!

    Edit: This is wrong, see below!
    Adam Smolnik
    Ranch Hand

    Joined: Apr 15, 2009
    Posts: 63
    Please, take a look at the correct example related to R1011:
    CORRECT:

    <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' >
    <soap:Body>
    <p:Process xmlns:p='http://example.org/Operations' >
    <m:Data xmlns:m='http://example.org/information' >
    Here is some data with the message
    </m:Data>
    </p:Process>
    </soap:Body>
    </soap:Envelope>


    Best Regards
    Adam


    SCJP, SCWCD, SCBCD, SCDJWS
    Ivan Krizsan
    Ranch Hand

    Joined: Oct 04, 2006
    Posts: 2198
        
        1
    Hi!
    I certainly was tricked! :-)
    XML processing instructions begin with <? and ends with ?>.
    Thus, in the question, there are no processing instructions.
    Reference: http://www.w3.org/TR/REC-xml/#sec-pi
    Best wishes!
    Asit Baran
    Greenhorn

    Joined: Oct 13, 2008
    Posts: 25
    So is the message valid?
    <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
    <soap:Body>
    <p:Process xmlns:p='http://example.org/Operations'>
    <m:Envelope xmlns:m='http://schemas.xmlsoap.org/soap/envelope/'>
    ..............
    Will not this line[marked in bold] cause a problem? Can we have child elements under <soap:Body> which belongs to 'http://schemas.xmlsoap.org/soap/envelope/' namespace?

    Ivan Krizsan
    Ranch Hand

    Joined: Oct 04, 2006
    Posts: 2198
        
        1
    Hi again!
    I find this related to the SOAP Body and this question in the Basic Profile:

    R9981 An ENVELOPE MUST have exactly zero or one child elements of the soap:Body element.
    R1014 The children of the soap:Body element in an ENVELOPE MUST be namespace qualified.
    R2712 A document-literal binding MUST be serialized as an ENVELOPE with a soap:Body whose child element is an instance of the global element declaration referenced by the corresponding wsdl:message part.

    But I do not find anything saying that a child element of the SOAP Body cannot belong to the namespace of the SOAP Envelope.
    As far as I understand, you can declare the element being the contents of the SOAP Body to be a wrapper element that contains only an entry of anyType, which would allow the wrapper element to contain any legal XML contents, including other SOAP messages.
    Would be very interesting to hear if anyone finds anything that forbids usage such as this in the BP etc.
    Best wishes
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Mock exam question: SOAP doubt
     
    Similar Threads
    how to set an attribute like SOAPAction in the Header?
    SOAP doubt: The Envelope element
    BP-compliant SOAP Envelope's namespace
    Do grandchildren of Soap:body element need to be fully qualified?
    Doubt in soap:header