Java Code Examples for javax.xml.soap.SOAPMessage#saveChanges()

The following examples show how to use javax.xml.soap.SOAPMessage#saveChanges() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SoapRequestBean.java    From openxds with Apache License 2.0 6 votes vote down vote up
private static void printMessage(SOAPMessage message, String headerType) throws IOException, SOAPException {
    if (message != null) {
        //get the mime headers and print them
        System.out.println("\n\nHeader: " + headerType);
        if (message.saveRequired()) {
            message.saveChanges();
        }
        MimeHeaders headers = message.getMimeHeaders();
        printHeaders(headers);
        
        //print the message itself
        System.out.println("\n\nMessage: " + headerType);
        message.writeTo(System.out);
        System.out.println();
    }
}
 
Example 2
Source File: HubDecryptionHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private void handleDecryption(SOAPMessageContext cxt) {
   try {
      SOAPMessage soapMessage = cxt.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();
      if (soapBody == null) {
         SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
         soapBody = soapEnvelope.getBody();
      }

      FolderDecryptor.decryptFolder(soapBody, this.crypto);
      soapMessage.saveChanges();
   } catch (SOAPException var5) {
      LOG.error("SOAPException when handling the SOAP Body", var5);
      throw new RuntimeException(var5);
   } catch (UnsealConnectorException var6) {
      LOG.error("UnsealConnectorException when handling the SOAP Message: " + var6.getMessage());
      throw new FolderDecryptionRuntimeException(var6.getMessage(), var6);
   } catch (TechnicalConnectorException var7) {
      LOG.error("TechnicalConnectorException when handling the SOAP Message: " + var7.getMessage());
      throw new RuntimeException(var7);
   }
}
 
Example 3
Source File: HubDecryptionHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private void handleDecryption(SOAPMessageContext cxt) {
   try {
      SOAPMessage soapMessage = cxt.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();
      if (soapBody == null) {
         SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
         soapBody = soapEnvelope.getBody();
      }

      FolderDecryptor.decryptFolder(soapBody, this.crypto);
      soapMessage.saveChanges();
   } catch (SOAPException var5) {
      LOG.error("SOAPException when handling the SOAP Body", var5);
      throw new RuntimeException(var5);
   } catch (UnsealConnectorException var6) {
      LOG.error("UnsealConnectorException when handling the SOAP Message: " + var6.getMessage());
      throw new FolderDecryptionRuntimeException(var6.getMessage(), var6);
   } catch (TechnicalConnectorException var7) {
      LOG.error("TechnicalConnectorException when handling the SOAP Message: " + var7.getMessage());
      throw new RuntimeException(var7);
   }
}
 
Example 4
Source File: MustUnderstandHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public boolean handleMessage(SOAPMessageContext cxt) {
   Boolean outbound = (Boolean)cxt.get("javax.xml.ws.handler.message.outbound");
   if (outbound.booleanValue()) {
      SOAPMessage message = cxt.getMessage();

      try {
         SOAPHeader header = message.getSOAPHeader();
         if (header != null) {
            Iterator it = header.getChildElements(WSSE);

            while(it.hasNext()) {
               SOAPElement el = (SOAPElement)it.next();
               el.removeAttributeNS(message.getSOAPPart().getEnvelope().getNamespaceURI(), "mustUnderstand");
               LOG.debug("Recipe hook: The mustunderstand in security header has succesfully been removed");
            }

            message.saveChanges();
         }
      } catch (SOAPException var7) {
         throw SecurableSoapMessage.newSOAPFaultException("Recipe hook problem: " + var7.getMessage(), var7);
      }
   }

   return true;
}
 
Example 5
Source File: DispatchHandlerInvocationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvokeWithDOMSourcMessageMode() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
    assertNotNull(wsdl);

    AddNumbersService service = new AddNumbersService(wsdl, serviceName);
    assertNotNull(service);

    Dispatch<DOMSource> disp = service.createDispatch(portName, DOMSource.class, Mode.MESSAGE);
    setAddress(disp, addNumbersAddress);

    TestHandler handler = new TestHandler();
    TestSOAPHandler soapHandler = new TestSOAPHandler();
    addHandlersProgrammatically(disp, handler, soapHandler);
    InputStream is = this.getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage soapReq = factory.createMessage(null, is);
    soapReq.saveChanges();
    DOMSource domReqMessage = new DOMSource(soapReq.getSOAPPart());

    DOMSource response = disp.invoke(domReqMessage);
    //XMLUtils.writeTo(response, System.out);
    assertNotNull(response);
}
 
Example 6
Source File: SoapActionHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public boolean handleOutbound(SOAPMessageContext context) {
   try {
      boolean hasSoapAction = false;
      if (context.containsKey("javax.xml.ws.soap.http.soapaction.use")) {
         hasSoapAction = ((Boolean)context.get("javax.xml.ws.soap.http.soapaction.use")).booleanValue();
      }

      if (hasSoapAction) {
         String soapAction = (String)context.get("javax.xml.ws.soap.http.soapaction.uri");
         LOG.debug("Adding SOAPAction to mimeheader");
         SOAPMessage msg = context.getMessage();
         String[] headers = msg.getMimeHeaders().getHeader("SOAPAction");
         if (headers != null) {
            LOG.warn("Removing SOAPAction with values: " + ArrayUtils.toString(headers));
            msg.getMimeHeaders().removeHeader("SOAPAction");
         }

         msg.getMimeHeaders().addHeader("SOAPAction", soapAction);
         msg.saveChanges();
      }

      return true;
   } catch (SOAPException var6) {
      throw SOAPFaultFactory.newSOAPFaultException("WSSecurity problem: [SOAPACTION]" + var6.getMessage(), var6);
   }
}
 
Example 7
Source File: ArcherAuthenticatingRestConnection.java    From FortifyBugTrackerUtility with MIT License 5 votes vote down vote up
public Long addValueToValuesList(Long valueListId, String value) {
	LOG.info("[Archer] Adding value '"+value+"' to value list id "+valueListId);
	// Adding items to value lists is not supported via REST API, so we need to revert to SOAP API
	// TODO Simplify this method?
	// TODO Make this method more fail-safe (like checking for the correct response element)?
	Long result = null;
	try {
		MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();
        SOAPPart soapPart = message.getSOAPPart();
        SOAPEnvelope envelope = soapPart.getEnvelope();
        SOAPBody body = envelope.getBody();
        SOAPElement bodyElement = body.addChildElement(envelope.createName("CreateValuesListValue", "", "http://archer-tech.com/webservices/"));
        bodyElement.addChildElement("sessionToken").addTextNode(tokenProviderRest.getToken());
        bodyElement.addChildElement("valuesListId").addTextNode(valueListId+"");
        bodyElement.addChildElement("valuesListValueName").addTextNode(value);
        message.saveChanges();
 
        SOAPMessage response = executeRequest(HttpMethod.POST, 
        		getBaseResource().path("/ws/field.asmx")
        		.request()
        		.header("SOAPAction", "\"http://archer-tech.com/webservices/CreateValuesListValue\"")
        		.accept("text/xml"),
        		Entity.entity(message, "text/xml"), SOAPMessage.class);
        @SuppressWarnings("unchecked")
		Iterator<Object> it = response.getSOAPBody().getChildElements();
        while (it.hasNext()){
        	Object o = it.next();
        	if ( o instanceof SOAPElement ) {	
        		result = new Long(((SOAPElement)o).getTextContent());
        	}
          }
        System.out.println(response);
	} catch (SOAPException e) {
		throw new RuntimeException("Error executing SOAP request", e);
	}
	return result;
}
 
Example 8
Source File: AbstractMessageImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void transportHeaders(Packet packet, boolean inbound, SOAPMessage msg) throws SOAPException {
    Map<String, List<String>> headers = getTransportHeaders(packet, inbound);
    if (headers != null) {
        addSOAPMimeHeaders(msg.getMimeHeaders(), headers);
    }
    if (msg.saveRequired()) msg.saveChanges();
}
 
Example 9
Source File: AbstractSecurityTest.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link SoapMessage} from the contents of a document.
 * @param doc the document containing the SOAP content.
 */
protected SoapMessage getSoapMessageForDom(Document doc) throws SOAPException {
    SOAPMessage saajMsg = MessageFactory.newInstance().createMessage();
    SOAPPart part = saajMsg.getSOAPPart();
    part.setContent(new DOMSource(doc));
    saajMsg.saveChanges();

    SoapMessage msg = new SoapMessage(new MessageImpl());
    Exchange ex = new ExchangeImpl();
    ex.setInMessage(msg);
    msg.setContent(SOAPMessage.class, saajMsg);
    return msg;
}
 
Example 10
Source File: SAAJFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPMessage readAsSOAPMessageSax2Dom(final SOAPVersion soapVersion, final Message message) throws SOAPException {
    SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
    SAX2DOMEx s2d = new SAX2DOMEx(msg.getSOAPPart());
    try {
        message.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
    } catch (SAXException e) {
        throw new SOAPException(e);
    }
    addAttachmentsToSOAPMessage(msg, message);
    if (msg.saveRequired())
        msg.saveChanges();
    return msg;
}
 
Example 11
Source File: SAAJFactory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reads Message as SOAPMessage.  After this call message is consumed.
 * @param soapVersion SOAP version
 * @param message Message
 * @return Created SOAPMessage
 * @throws SOAPException if SAAJ processing fails
 */
public SOAPMessage readAsSOAPMessage(final SOAPVersion soapVersion, final Message message) throws SOAPException {
SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
SaajStaxWriter writer = new SaajStaxWriter(msg);
try {
    message.writeTo(writer);
} catch (XMLStreamException e) {
    throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
}
msg = writer.getSOAPMessage();
addAttachmentsToSOAPMessage(msg, message);
if (msg.saveRequired())
        msg.saveChanges();
return msg;
}
 
Example 12
Source File: SAAJFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public SOAPMessage readAsSOAPMessageSax2Dom(final SOAPVersion soapVersion, final Message message) throws SOAPException {
    SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
    SAX2DOMEx s2d = new SAX2DOMEx(msg.getSOAPPart());
    try {
        message.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
    } catch (SAXException e) {
        throw new SOAPException(e);
    }
    addAttachmentsToSOAPMessage(msg, message);
    if (msg.saveRequired())
        msg.saveChanges();
    return msg;
}
 
Example 13
Source File: AbstractMessageImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void transportHeaders(Packet packet, boolean inbound, SOAPMessage msg) throws SOAPException {
    Map<String, List<String>> headers = getTransportHeaders(packet, inbound);
    if (headers != null) {
        addSOAPMimeHeaders(msg.getMimeHeaders(), headers);
    }
    if (msg.saveRequired()) msg.saveChanges();
}
 
Example 14
Source File: SAAJFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPMessage readAsSOAPMessageSax2Dom(final SOAPVersion soapVersion, final Message message) throws SOAPException {
    SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
    SAX2DOMEx s2d = new SAX2DOMEx(msg.getSOAPPart());
    try {
        message.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
    } catch (SAXException e) {
        throw new SOAPException(e);
    }
    addAttachmentsToSOAPMessage(msg, message);
    if (msg.saveRequired())
        msg.saveChanges();
    return msg;
}
 
Example 15
Source File: AbstractITEndpoint.java    From spring-ws-security-soap-example with MIT License 5 votes vote down vote up
/**
 * Calls the web service being tested and returns the response.
 *
 * @param request
 *            request to the web service
 * @return the web service response
 * @throws SOAPException
 *             never, this is a required declaration
 */
protected final SOAPMessage callWebService(final SOAPMessage request)
        throws SOAPException {
    final SOAPConnectionFactory soapConnectionFactory; // Connection factory
    final MimeHeaders headers; // Message headers

    soapConnectionFactory = SOAPConnectionFactory.newInstance();

    // Sets the SOAP action
    headers = request.getMimeHeaders();
    headers.addHeader("SOAPAction", soapAction);
    request.saveChanges();

    return soapConnectionFactory.createConnection().call(request, wsURL);
}
 
Example 16
Source File: SendMTConverterUtils.java    From opencps-v2 with GNU Affero General Public License v3.0 4 votes vote down vote up
private static SOAPMessage convertSendMTToXML(SendMT sendMT) {
	try {
		JAXBContext jaxbContext = JAXBContext.newInstance(SendMT.class);
		MessageFactory mf = MessageFactory.newInstance();
		SOAPMessage message = mf.createMessage();

		SOAPBody body = message.getSOAPBody();

		SOAPHeader soapheader = message.getSOAPHeader();
		soapheader.detachNode();

		Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
		// output pretty printed
		jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
		//process marshaller
		jaxbMarshaller.marshal(sendMT, body);
		//jaxbMarshaller.marshal(sendMT, System.out);
		message.saveChanges();

		// Process convert SOAP-ENV to soapenv
		SOAPPart soapPart = message.getSOAPPart();
		SOAPEnvelope envelope = soapPart.getEnvelope();
		// SOAPHeader header = message.getSOAPHeader();
		SOAPBody bodyConvert = message.getSOAPBody();
		SOAPFault fault = bodyConvert.getFault();
		envelope.removeNamespaceDeclaration(envelope.getPrefix());
		envelope.addNamespaceDeclaration(Constants.PREFERRED_PREFIX, Constants.SOAP_ENV_NAMESPACE);
		envelope.addNamespaceDeclaration(Constants.PREFERRED_PREFIX_TEM, Constants.SOAP_ENV_NAMESPACE_TEM);
		envelope.setPrefix(Constants.PREFERRED_PREFIX);
		bodyConvert.setPrefix(Constants.PREFERRED_PREFIX);
		if (fault != null) {
			fault.setPrefix(Constants.PREFERRED_PREFIX);
		}
		message.saveChanges();

		return message;
	} catch (Exception e) {
		_log.error(e);
	}

	return null;
}
 
Example 17
Source File: SamlTokenTest.java    From steady with Apache License 2.0 4 votes vote down vote up
private SoapMessage makeInvocation(
    Map<String, Object> outProperties,
    List<String> xpaths,
    Map<String, Object> inProperties,
    Map<String, String> inMessageProperties
) throws Exception {
    Document doc = readDocument("wsse-request-clean.xml");

    WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor();
    PhaseInterceptor<SoapMessage> handler = ohandler.createEndingInterceptor();

    SoapMessage msg = new SoapMessage(new MessageImpl());
    Exchange ex = new ExchangeImpl();
    ex.setInMessage(msg);

    SOAPMessage saajMsg = MessageFactory.newInstance().createMessage();
    SOAPPart part = saajMsg.getSOAPPart();
    part.setContent(new DOMSource(doc));
    saajMsg.saveChanges();

    msg.setContent(SOAPMessage.class, saajMsg);

    for (String key : outProperties.keySet()) {
        msg.put(key, outProperties.get(key));
    }

    handler.handleMessage(msg);

    doc = part;

    for (String xpath : xpaths) {
        assertValid(xpath, doc);
    }

    byte[] docbytes = getMessageBytes(doc);
    XMLStreamReader reader = StaxUtils.createXMLStreamReader(new ByteArrayInputStream(docbytes));

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

    dbf.setValidating(false);
    dbf.setIgnoringComments(false);
    dbf.setIgnoringElementContentWhitespace(true);
    dbf.setNamespaceAware(true);

    DocumentBuilder db = dbf.newDocumentBuilder();
    db.setEntityResolver(new NullResolver());
    doc = StaxUtils.read(db, reader, false);

    WSS4JInInterceptor inHandler = new WSS4JInInterceptor(inProperties);

    SoapMessage inmsg = new SoapMessage(new MessageImpl());
    inmsg.put(SecurityConstants.SAML_ROLE_ATTRIBUTENAME, "role");
    for (String inMessageProperty : inMessageProperties.keySet()) {
        inmsg.put(inMessageProperty, inMessageProperties.get(inMessageProperty));
    }
    ex.setInMessage(inmsg);
    inmsg.setContent(SOAPMessage.class, saajMsg);

    inHandler.handleMessage(inmsg);

    return inmsg;
}
 
Example 18
Source File: SignatureConfirmationTest.java    From steady with Apache License 2.0 4 votes vote down vote up
@org.junit.Test
public void testSignatureConfirmationRequest() throws Exception {
    Document doc = readDocument("wsse-request-clean.xml");

    WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor();
    PhaseInterceptor<SoapMessage> handler = ohandler.createEndingInterceptor();

    SoapMessage msg = new SoapMessage(new MessageImpl());
    Exchange ex = new ExchangeImpl();
    ex.setInMessage(msg);
    
    SOAPMessage saajMsg = MessageFactory.newInstance().createMessage();
    SOAPPart part = saajMsg.getSOAPPart();
    part.setContent(new DOMSource(doc));
    saajMsg.saveChanges();

    msg.setContent(SOAPMessage.class, saajMsg);

    msg.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
    msg.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
    msg.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
    msg.put(WSHandlerConstants.USER, "myalias");
    msg.put("password", "myAliasPassword");
    //
    // This is necessary to convince the WSS4JOutInterceptor that we're
    // functioning as a requestor
    //
    msg.put(org.apache.cxf.message.Message.REQUESTOR_ROLE, true);

    handler.handleMessage(msg);
    doc = part;
    
    assertValid("//wsse:Security", doc);
    assertValid("//wsse:Security/ds:Signature", doc);

    byte[] docbytes = getMessageBytes(doc);
    //
    // Save the signature for future confirmation
    //
    List<WSHandlerResult> sigv = CastUtils.cast((List<?>)msg.get(WSHandlerConstants.SEND_SIGV));
    assertNotNull(sigv);
    assertTrue(sigv.size() != 0);
    
    XMLStreamReader reader = StaxUtils.createXMLStreamReader(new ByteArrayInputStream(docbytes));

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

    dbf.setValidating(false);
    dbf.setIgnoringComments(false);
    dbf.setIgnoringElementContentWhitespace(true);
    dbf.setNamespaceAware(true);

    DocumentBuilder db = dbf.newDocumentBuilder();
    db.setEntityResolver(new NullResolver());
    doc = StaxUtils.read(db, reader, false);

    WSS4JInInterceptor inHandler = new WSS4JInInterceptor();

    SoapMessage inmsg = new SoapMessage(new MessageImpl());
    ex.setInMessage(inmsg);
    inmsg.setContent(SOAPMessage.class, saajMsg);

    inHandler.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
    inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE, "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");

    inHandler.handleMessage(inmsg);
    
    //
    // Check that the inbound signature result was saved
    //
    WSSecurityEngineResult result = 
        (WSSecurityEngineResult) inmsg.get(WSS4JInInterceptor.SIGNATURE_RESULT);
    assertNotNull(result);
    
    List<WSHandlerResult> sigReceived = 
        CastUtils.cast((List<?>)inmsg.get(WSHandlerConstants.RECV_RESULTS));
    assertNotNull(sigReceived);
    assertTrue(sigReceived.size() != 0);
    
    testSignatureConfirmationResponse(sigv, sigReceived);
}
 
Example 19
Source File: WSS4JInOutTest.java    From steady with Apache License 2.0 4 votes vote down vote up
@Test
public void testCustomProcessorObject() throws Exception {
    Document doc = readDocument("wsse-request-clean.xml");

    WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor();
    PhaseInterceptor<SoapMessage> handler = ohandler.createEndingInterceptor();

    SoapMessage msg = new SoapMessage(new MessageImpl());
    Exchange ex = new ExchangeImpl();
    ex.setInMessage(msg);
    
    SOAPMessage saajMsg = MessageFactory.newInstance().createMessage();
    SOAPPart part = saajMsg.getSOAPPart();
    part.setContent(new DOMSource(doc));
    saajMsg.saveChanges();

    msg.setContent(SOAPMessage.class, saajMsg);

    msg.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
    msg.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
    msg.put(WSHandlerConstants.USER, "myalias");
    msg.put("password", "myAliasPassword");

    handler.handleMessage(msg);

    doc = part;
    
    assertValid("//wsse:Security", doc);
    assertValid("//wsse:Security/ds:Signature", doc);

    byte[] docbytes = getMessageBytes(doc);
    XMLStreamReader reader = StaxUtils.createXMLStreamReader(new ByteArrayInputStream(docbytes));

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

    dbf.setValidating(false);
    dbf.setIgnoringComments(false);
    dbf.setIgnoringElementContentWhitespace(true);
    dbf.setNamespaceAware(true);

    DocumentBuilder db = dbf.newDocumentBuilder();
    db.setEntityResolver(new NullResolver());
    doc = StaxUtils.read(db, reader, false);

    final Map<String, Object> properties = new HashMap<String, Object>();
    final Map<QName, Object> customMap = new HashMap<QName, Object>();
    customMap.put(
        new QName(
            WSConstants.SIG_NS,
            WSConstants.SIG_LN
        ),
        CustomProcessor.class
    );
    properties.put(
        WSS4JInInterceptor.PROCESSOR_MAP,
        customMap
    );
    WSS4JInInterceptor inHandler = new WSS4JInInterceptor(properties);

    SoapMessage inmsg = new SoapMessage(new MessageImpl());
    ex.setInMessage(inmsg);
    inmsg.setContent(SOAPMessage.class, saajMsg);

    inHandler.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);

    inHandler.handleMessage(inmsg);
    
    WSSecurityEngineResult result = 
        (WSSecurityEngineResult) inmsg.get(WSS4JInInterceptor.SIGNATURE_RESULT);
    assertNotNull(result);
    
    Object obj = result.get("foo");
    assertNotNull(obj);
    assertEquals(obj.getClass().getName(), CustomProcessor.class.getName());
}
 
Example 20
Source File: EjbRpcProvider.java    From tomee with Apache License 2.0 4 votes vote down vote up
private Object[] demarshallArguments() throws Exception {
    SOAPMessage message = messageContext.getMessage();
    messageContext.setProperty(org.apache.axis.SOAPPart.ALLOW_FORM_OPTIMIZATION, Boolean.TRUE);
    if (message != null) {
        message.saveChanges();
    }

    try {
        Message reqMsg = messageContext.getRequestMessage();
        SOAPEnvelope requestEnvelope = reqMsg.getSOAPEnvelope();
        RPCElement body = getBody(requestEnvelope, messageContext);
        body.setNeedDeser(true);
        Vector args = null;
        try {
            args = body.getParams();
        } catch (SAXException e) {
            if (e.getException() != null) {
                throw e.getException();
            }
            throw e;
        }

        Object[] argValues = new Object[operation.getNumParams()];

        for (int i = 0; i < args.size(); i++) {
            RPCParam rpcParam = (RPCParam) args.get(i);
            Object value = rpcParam.getObjectValue();

            ParameterDesc paramDesc = rpcParam.getParamDesc();

            if (paramDesc != null && paramDesc.getJavaType() != null) {
                value = JavaUtils.convert(value, paramDesc.getJavaType());
                rpcParam.setObjectValue(value);
            }
            int order = (paramDesc == null || paramDesc.getOrder() == -1) ? i : paramDesc.getOrder();
            argValues[order] = value;
        }
        return argValues;
    } finally {
        messageContext.setProperty(org.apache.axis.SOAPPart.ALLOW_FORM_OPTIMIZATION, Boolean.FALSE);
    }
}