protected SOAPMessage createSoapRequest ( Object requestObj ) throws ActivityException { try { MessageFactory messageFactory = getSoapMessageFactory ( ) ; SOAPMessage soapMessage = messageFactory . createMessage ( ) ; Map < Name , String > soapReqHeaders = getSoapRequestHeaders ( ) ; if ( soapReqHeaders != null ) { SOAPHeader header = soapMessage . getSOAPHeader ( ) ; for ( Name name : soapReqHeaders . keySet ( ) ) { header . addHeaderElement ( name ) . setTextContent ( soapReqHeaders . get ( name ) ) ; } } SOAPBody soapBody = soapMessage . getSOAPBody ( ) ; Document requestDoc = null ; if ( requestObj instanceof String ) { requestDoc = DomHelper . toDomDocument ( ( String ) requestObj ) ; soapBody . addDocument ( requestDoc ) ; } else { Variable reqVar = getProcessDefinition ( ) . getVariable ( getAttributeValue ( REQUEST_VARIABLE ) ) ; XmlDocumentTranslator docRefTrans = ( XmlDocumentTranslator ) VariableTranslator . getTranslator ( getPackage ( ) , reqVar . getType ( ) ) ; requestDoc = docRefTrans . toDomDocument ( requestObj ) ; Document copiedDocument = DomHelper . copyDomDocument ( requestDoc ) ; soapBody . addDocument ( copiedDocument ) ; } return soapMessage ; } catch ( Exception ex ) { throw new ActivityException ( ex . getMessage ( ) , ex ) ; } }
Create the SOAP request object based on the document variable value .