Module java.xml.ws
Package javax.xml.soap

Interface SOAPBody

  • All Superinterfaces:
    Element,Node,Node,SOAPElement


    public interfaceSOAPBodyextendsSOAPElement
    An object that represents the contents of the SOAP body element in a SOAP message. A SOAP body element consists of XML data that affects the way the application-specific content is processed.

    ASOAPBody object containsSOAPBodyElement objects, which have the content for the SOAP body. ASOAPFault object, which carries status and/or error information, is an example of aSOAPBodyElement object.

    Since:
    1.6
    See Also:
    SOAPFault
    • Method Detail

      • addFault

        SOAPFault addFault()            throwsSOAPException
        Creates a newSOAPFault object and adds it to thisSOAPBody object. The newSOAPFault will have default values set for the mandatory child elements. The type of theSOAPFault will be a SOAP 1.1 or a SOAP 1.2SOAPFault depending on theprotocol specified while creating theMessageFactory instance.

        ASOAPBody may contain at most oneSOAPFault child element.

        Returns:
        the newSOAPFault object
        Throws:
        SOAPException - if there is a SOAP error
      • addFault

        SOAPFault addFault(Name faultCode,String faultString,Locale locale)            throwsSOAPException
        Creates a newSOAPFault object and adds it to thisSOAPBody object. The type of theSOAPFault will be a SOAP 1.1 or a SOAP 1.2SOAPFault depending on theprotocol specified while creating theMessageFactory instance.

        For SOAP 1.2 thefaultCode parameter is the value of theFault/Code/Value element and thefaultString parameter is the value of theFault/Reason/Text element. For SOAP 1.1 thefaultCode parameter is the value of thefaultcode element and thefaultString parameter is the value of thefaultstring element.

        ASOAPBody may contain at most oneSOAPFault child element.

        Parameters:
        faultCode - aName object giving the fault code to be set; must be one of the fault codes defined in the Version of SOAP specification in use
        faultString - aString giving an explanation of the fault
        locale - aLocale object indicating the native language of thefaultString
        Returns:
        the newSOAPFault object
        Throws:
        SOAPException - if there is a SOAP error
        Since:
        1.6, SAAJ 1.2
        See Also:
        SOAPFault.setFaultCode(javax.xml.soap.Name),SOAPFault.setFaultString(java.lang.String)
      • addFault

        SOAPFault addFault(QName faultCode,String faultString,Locale locale)            throwsSOAPException
        Creates a newSOAPFault object and adds it to thisSOAPBody object. The type of theSOAPFault will be a SOAP 1.1 or a SOAP 1.2SOAPFault depending on theprotocol specified while creating theMessageFactory instance.

        For SOAP 1.2 thefaultCode parameter is the value of theFault/Code/Value element and thefaultString parameter is the value of theFault/Reason/Text element. For SOAP 1.1 thefaultCode parameter is the value of thefaultcode element and thefaultString parameter is the value of thefaultstring element.

        ASOAPBody may contain at most oneSOAPFault child element.

        Parameters:
        faultCode - aQName object giving the fault code to be set; must be one of the fault codes defined in the version of SOAP specification in use.
        faultString - aString giving an explanation of the fault
        locale - aLocale object indicating the native language of thefaultString
        Returns:
        the newSOAPFault object
        Throws:
        SOAPException - if there is a SOAP error
        Since:
        1.6, SAAJ 1.3
        See Also:
        SOAPFault.setFaultCode(javax.xml.soap.Name),SOAPFault.setFaultString(java.lang.String),addFault(Name faultCode, String faultString, Locale locale)
      • addFault

        SOAPFault addFault(Name faultCode,String faultString)            throwsSOAPException
        Creates a newSOAPFault object and adds it to thisSOAPBody object. The type of theSOAPFault will be a SOAP 1.1 or a SOAP 1.2SOAPFault depending on theprotocol specified while creating theMessageFactory instance.

        For SOAP 1.2 thefaultCode parameter is the value of theFault/Code/Value element and thefaultString parameter is the value of theFault/Reason/Text element. For SOAP 1.1 thefaultCode parameter is the value of thefaultcode element and thefaultString parameter is the value of thefaultstring element.

        In case of a SOAP 1.2 fault, the default value for the mandatoryxml:lang attribute on theFault/Reason/Text element will be set tojava.util.Locale.getDefault()

        ASOAPBody may contain at most oneSOAPFault child element.

        Parameters:
        faultCode - aName object giving the fault code to be set; must be one of the fault codes defined in the version of SOAP specification in use
        faultString - aString giving an explanation of the fault
        Returns:
        the newSOAPFault object
        Throws:
        SOAPException - if there is a SOAP error
        Since:
        1.6, SAAJ 1.2
        See Also:
        SOAPFault.setFaultCode(javax.xml.soap.Name),SOAPFault.setFaultString(java.lang.String)
      • addFault

        SOAPFault addFault(QName faultCode,String faultString)            throwsSOAPException
        Creates a newSOAPFault object and adds it to thisSOAPBody object. The type of theSOAPFault will be a SOAP 1.1 or a SOAP 1.2SOAPFault depending on theprotocol specified while creating theMessageFactory instance.

        For SOAP 1.2 thefaultCode parameter is the value of theFault/Code/Value element and thefaultString parameter is the value of theFault/Reason/Text element. For SOAP 1.1 thefaultCode parameter is the value of thefaultcode element and thefaultString parameter is the value of thefaultstring element.

        In case of a SOAP 1.2 fault, the default value for the mandatoryxml:lang attribute on theFault/Reason/Text element will be set tojava.util.Locale.getDefault()

        ASOAPBody may contain at most oneSOAPFault child element

        Parameters:
        faultCode - aQName object giving the fault code to be set; must be one of the fault codes defined in the version of SOAP specification in use
        faultString - aString giving an explanation of the fault
        Returns:
        the newSOAPFault object
        Throws:
        SOAPException - if there is a SOAP error
        Since:
        1.6, SAAJ 1.3
        See Also:
        SOAPFault.setFaultCode(javax.xml.soap.Name),SOAPFault.setFaultString(java.lang.String),addFault(Name faultCode, String faultString)
      • hasFault

        boolean hasFault()
        Indicates whether aSOAPFault object exists in thisSOAPBody object.
        Returns:
        true if aSOAPFault object exists in thisSOAPBody object;false otherwise
      • getFault

        SOAPFault getFault()
        Returns theSOAPFault object in thisSOAPBody object.
        Returns:
        theSOAPFault object in thisSOAPBody object if present, null otherwise.
      • addBodyElement

        SOAPBodyElement addBodyElement(QName qname)                        throwsSOAPException
        Creates a newSOAPBodyElement object with the specified QName and adds it to thisSOAPBody object.
        Parameters:
        qname - aQName object with the qname for the newSOAPBodyElement object
        Returns:
        the newSOAPBodyElement object
        Throws:
        SOAPException - if a SOAP error occurs
        Since:
        1.6, SAAJ 1.3
        See Also:
        addBodyElement(Name)
      • addDocument

        SOAPBodyElement addDocument(Document document)                     throwsSOAPException
        Adds the root node of the DOMDocument to thisSOAPBody object.

        Calling this method invalidates thedocument parameter. The client application should discard all references to thisDocument and its contents upon callingaddDocument. The behavior of an application that continues to use such references is undefined.

        Parameters:
        document - theDocument object whose root node will be added to thisSOAPBody.
        Returns:
        theSOAPBodyElement that represents the root node that was added.
        Throws:
        SOAPException - if theDocument cannot be added
        Since:
        1.6, SAAJ 1.2
      • extractContentAsDocument

        Document extractContentAsDocument()                           throwsSOAPException
        Creates a new DOMDocument and sets the first child of thisSOAPBody as it's document element. The childSOAPElement is removed as part of the process.
        Returns:
        theDocument representation of theSOAPBody content.
        Throws:
        SOAPException - if there is not exactly one childSOAPElement of theSOAPBody.
        Since:
        1.6, SAAJ 1.3