Ejemplo n.º 1
0
 def __init__(self, requestEnvelope, fault_action, code, reason, subCode,
              details):
     super(_SoapFaultBase, self).__init__(
         Prefix.partialMap(Prefix.S12, Prefix.WSA, Prefix.WSE))
     replyAddress = requestEnvelope.address.mkReplyAddress(fault_action)
     self.addHeaderObject(replyAddress)
     faultNode = etree_.Element(s12Tag('Fault'))
     codeNode = etree_.SubElement(faultNode, s12Tag('Code'))
     valueNode = etree_.SubElement(codeNode, s12Tag('Value'))
     valueNode.text = 's12:{}'.format(code)
     if subCode is not None:
         subcodeNode = etree_.SubElement(codeNode, s12Tag('Subcode'))
         valueNode = etree_.SubElement(subcodeNode, s12Tag('Value'))
         valueNode.text = docNameFromQName(subCode, nsmap)
     reasonNode = etree_.SubElement(faultNode, s12Tag('Reason'))
     reasontextNode = etree_.SubElement(reasonNode, s12Tag('Text'))
     reasontextNode.set(xmlTag('lang'), 'en-US')
     reasontextNode.text = reason
     if details is not None:
         _detailNode = etree_.SubElement(faultNode, s12Tag('Detail'))
         _detailNode.set(xmlTag('lang'), 'en-US')
         if isinstance(details, str):
             detNode = etree_.SubElement(_detailNode, 'data')
             detNode.text = details
         else:
             _detailNode.append(details)
     self.addBodyElement(faultNode)
Ejemplo n.º 2
0
 def asEtreeSubNode(self, rootNode):
     hostedNode = etree_.SubElement(rootNode, dpwsTag('Hosted'))
     epRefNode = etree_.SubElement(hostedNode, wsaTag('EndpointReference'))
     for epRef in self.endpointReferences:
         epRef.asEtreeSubNode(epRefNode)
     if self.types:
         typesText = ' '.join(
             [docNameFromQName(t, rootNode.nsmap) for t in self.types])
         typesNode = etree_.SubElement(hostedNode,
                                       dpwsTag('Types'))  #, nsmap=ns)
         typesNode.text = typesText
     serviceNode = etree_.SubElement(hostedNode,
                                     dpwsTag('ServiceId'))  #, nsmap=ns)
     serviceNode.text = self.serviceId
 def updateXMLValue(self, instance, node):
     try:
         pyValue = getattr(instance, self._localVarName)
     except AttributeError: # set to None (it is in the responsibility of the called method to do the right thing)
         pyValue = None
     if pyValue is None:
         try:
             subNode = self._getElementbyChildNamesList(node, self._subElementNames, createMissingNodes=False)
             if self._attrname in subNode.attrib.keys():
                 del subNode.attrib[self._attrname]
         except ElementNotFoundException:
             return
     else:
         subNode = self._getElementbyChildNamesList(node, self._subElementNames, createMissingNodes=True)
         xmlValue = namespaces.docNameFromQName(pyValue, node.nsmap)            
         subNode.set(self._attrname, xmlValue)
    def updateXMLValue(self, instance, node):
        try:
            pyValue = getattr(instance, self._localVarName)
        except AttributeError: # set to None (it is in the responsibility of the called method to do the right thing)
            pyValue = None

        if pyValue is None:
            try:
                parentNode = self._getElementbyChildNamesList(node, self._subElementNames[:-1], createMissingNodes=False)
            except ElementNotFoundException:
                return
            subNode = parentNode.find(self._subElementNames[-1])
            if subNode is not None:
                parentNode.remove(subNode)
        else:
            subNode = self._getElementbyChildNamesList(node, self._subElementNames, createMissingNodes=True)
            value = namespaces.docNameFromQName(pyValue, subNode.nsmap)
            subNode.text = value