private void addSchemaLocationForExceptionToSOAPMessage(SOAPMessage soapResponseMessage) throws SOAPException { SOAPEnvelope envelope = soapResponseMessage.getSOAPPart().getEnvelope(); envelope.addNamespaceDeclaration(W3CConstants.NS_XSI_PREFIX, W3CConstants.NS_XSI); StringBuilder schemaLocation = new StringBuilder(); schemaLocation.append(envelope.getNamespaceURI()); schemaLocation.append(" "); schemaLocation.append(envelope.getNamespaceURI()); schemaLocation.append(" "); schemaLocation.append(N52XmlHelper.getSchemaLocationForOWS110Exception()); envelope.addAttribute(N52XmlHelper.getSchemaLocationQNameWithPrefix(), schemaLocation.toString()); } }
/** * Determines if the envelope is SOAP 1.1 or 1.2. * * @param soapMessage The SOAPMessage * @return The true if envelope is SOAP 1.2 * @throws SOAPException If the envelope could not be read */ public static Boolean isSOAP12(SOAPMessage soapMessage) throws SOAPException { return soapMessage.getSOAPPart().getEnvelope().getNamespaceURI().equals(SOAP12_URI); }
/** * Determines if the envelope is SOAP 1.1 or 1.2. * * @param soapMessage The SOAPMessage * @return The true if envelope is SOAP 1.2 * @throws SOAPException If the envelope could not be read */ public static Boolean isSOAP12(SOAPMessage soapMessage) throws SOAPException { return soapMessage.getSOAPPart().getEnvelope().getNamespaceURI().equals(SOAP12_URI); }
private void addSchemaLocationForExceptionToSOAPMessage(SOAPMessage soapResponseMessage) throws SOAPException { SOAPEnvelope envelope = soapResponseMessage.getSOAPPart().getEnvelope(); envelope.addNamespaceDeclaration(W3CConstants.NS_XSI_PREFIX, W3CConstants.NS_XSI); StringBuilder schemaLocation = new StringBuilder(); schemaLocation.append(envelope.getNamespaceURI()); schemaLocation.append(" "); schemaLocation.append(envelope.getNamespaceURI()); schemaLocation.append(" "); schemaLocation.append(N52XmlHelper.getSchemaLocationForOWS110Exception()); envelope.addAttribute(N52XmlHelper.getSchemaLocationQNameWithPrefix(), schemaLocation.toString()); } }
/** * Determine if a SOAPMessage is SOAP 1.2 * * @param soapMessage * @return * @throws SOAPException */ public static boolean isSOAP12(SOAPMessage soapMessage) throws SOAPException { SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); if (SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(soapEnvelope.getNamespaceURI())) return true; return false; }
private void verifySOAPVersion(OperationMetaData opMetaData, SOAPEnvelope soapEnvelope) { String envNS = soapEnvelope.getNamespaceURI(); String bindingId = opMetaData.getEndpointMetaData().getBindingId(); if (CommonSOAPBinding.SOAP11HTTP_BINDING.equals(bindingId) && Constants.NS_SOAP11_ENV.equals(envNS) == false) NativeLoggers.ROOT_LOGGER.unexpectedSoapEnvelopeVersion("1.1", envNS); if (CommonSOAPBinding.SOAP12HTTP_BINDING.equals(bindingId) && Constants.NS_SOAP12_ENV.equals(envNS) == false) NativeLoggers.ROOT_LOGGER.unexpectedSoapEnvelopeVersion("1.2", envNS); }
/** * Determine if a SOAPMessage is SOAP 1.2 * * @param soapMessage * * @return * * @throws SOAPException */ public static boolean isSOAP12(SOAPMessage soapMessage) throws SOAPException { SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); if (SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(soapEnvelope.getNamespaceURI())) return true; return false; }
/** * Determine if a SOAPMessage is SOAP 1.2 * * @param soapMessage * * @return * * @throws SOAPException */ public static boolean isSOAP12(SOAPMessage soapMessage) throws SOAPException { SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); if (SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(soapEnvelope.getNamespaceURI())) return true; return false; }
private String getSOAPContentType(CommonMessageContext msgContext) throws SOAPException { //Check binding type in the endpoint metadata if (msgContext != null && Constants.SOAP12HTTP_BINDING.equalsIgnoreCase(msgContext.getEndpointMetaData().getBindingId())) { return SOAPConstants.SOAP_1_2_CONTENT_TYPE; } //Check the message envelope SOAPEnvelope env = soapPart != null ? soapPart.getEnvelope() : null; if (env != null && SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(env.getNamespaceURI())) { return SOAPConstants.SOAP_1_2_CONTENT_TYPE; } //Default to soap 1.1 return SOAPConstants.SOAP_1_1_CONTENT_TYPE; }
string.append(envelope.getNamespaceURI()); string.append(' '); string.append(envelope.getNamespaceURI()); if (value != null && !value.isEmpty()) { string.append(' ');
/** * Make Security Header Non-MustUnderstand */ public void resetMustUnderstandOnSecHeader() { try { findSecurityHeader(); if (null != wsseSecurity) { wsseSecurity.removeAttributeNS(this.getEnvelope().getNamespaceURI(), "mustUnderstand"); } } catch (XWSSecurityException e) { log.log(Level.SEVERE, "WSS0370.error.deleting.secheader", e.getMessage()); } }
private String getToken(MessageContext msgContext) { SOAPMessage sm = ((SOAPMessageContext) msgContext).getMessage(); SOAPEnvelope envelope; try { envelope = sm.getSOAPPart().getEnvelope(); SOAPHeader header = (SOAPHeader) Util.findElement(envelope, new QName(envelope.getNamespaceURI(), "Header")); if (header == null) { header = (SOAPHeader) envelope.getOwnerDocument() .createElementNS(envelope.getNamespaceURI(), envelope.getPrefix() + ":Header"); } return Util.findElementByWsuId(header, "BinarySecurityToken") .getTextContent(); } catch (SOAPException e) { logger.jbossWSUnableToCreateBinaryToken(e); return null; } } }
private String getToken(MessageContext msgContext) { SOAPMessage sm = ((SOAPMessageContext) msgContext).getMessage(); SOAPEnvelope envelope; try { envelope = sm.getSOAPPart().getEnvelope(); SOAPHeader header = (SOAPHeader) Util.findElement(envelope, new QName(envelope.getNamespaceURI(), "Header")); if (header == null) { header = (SOAPHeader) envelope.getOwnerDocument() .createElementNS(envelope.getNamespaceURI(), envelope.getPrefix() + ":Header"); } return Util.findElementByWsuId(header, "BinarySecurityToken") .getTextContent(); } catch (SOAPException e) { logger.jbossWSUnableToCreateBinaryToken(e); return null; } } }
public NamespaceContext getNamespaceContext() throws XWSSecurityException{ if(nsContext == null){ nsContext = new NamespaceContextImpl(); ((NamespaceContextImpl)nsContext).add( getEnvelope().getPrefix(), getEnvelope().getNamespaceURI()); if (getEnvelope().getNamespaceURI() == MessageConstants.SOAP_1_2_NS) { ((NamespaceContextImpl)nsContext).add("SOAP-ENV", MessageConstants.SOAP_1_2_NS); ((NamespaceContextImpl)nsContext).add("env", MessageConstants.SOAP_1_2_NS); } } return nsContext; }
public void copyAttributes(final SecurableSoapMessage secureMsg, final SecurityHeader _secHeader) throws XWSSecurityException{ String SOAP_namespace = secureMsg.getEnvelope().getNamespaceURI(); String SOAP_prefix = secureMsg.getEnvelope().getPrefix(); String value_mustUnderstand= _secHeader.getAttributeNS(SOAP_namespace, "mustUnderstand"); String value_S12_role= _secHeader.getAttributeNS(SOAP_namespace, "role"); String value_S11_actor = _secHeader.getAttributeNS(SOAP_namespace, "actor"); String value_S12_relay = _secHeader.getAttributeNS(SOAP_namespace, "relay"); if(value_mustUnderstand!=null && !value_mustUnderstand.equals("")){ this.setAttributeNS(SOAP_namespace, SOAP_prefix+":mustUnderstand", value_mustUnderstand); } if(value_S12_role!=null && !value_S12_role.equals("")){ this.setAttributeNS(SOAP_namespace, SOAP_prefix+":role", value_S12_role); } if(value_S11_actor!=null && !value_S11_actor.equals("")){ this.setAttributeNS(SOAP_namespace, SOAP_prefix+":actor", value_S11_actor); } if(value_S12_relay!=null&&!value_S12_relay.equals("")){ this.setAttributeNS(SOAP_namespace, SOAP_prefix+":relay", value_S12_relay); } }
public static SOAPMessage getSOAPFault(String protocol, String faultString) { if (protocol==null) { protocol = javax.xml.soap.SOAPConstants.SOAP_1_1_PROTOCOL; } try { MessageFactory factory = MessageFactory.newInstance(protocol); if (factory==null) { factory = MessageFactory.newInstance(); } SOAPMessage message = factory.createMessage(); SOAPBody body = message.getSOAPBody(); SOAPFault fault = body.addFault(); fault.setFaultString(faultString); SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); String envelopeNamespace = envelope.getNamespaceURI(); QName faultCode = new QName(envelopeNamespace, "Server", "env"); fault.setFaultCode(faultCode); return message; } catch(SOAPException e) { logger.log(Level.WARNING, "Cannot create soap fault for " + faultString); } return null; }
public void writeTo(XMLStreamWriter writer) throws XMLStreamException { try { writer.writeStartDocument(); if (!parsedMessage) { DOMUtil.serializeNode(sm.getSOAPPart().getEnvelope(), writer); } else { SOAPEnvelope env = sm.getSOAPPart().getEnvelope(); DOMUtil.writeTagWithAttributes(env, writer); if (hasHeaders()) { if(env.getHeader() != null) { DOMUtil.writeTagWithAttributes(env.getHeader(), writer); } else { writer.writeStartElement(env.getPrefix(), "Header", env.getNamespaceURI()); } for (Header h : headers.asList()) { h.writeTo(writer); } writer.writeEndElement(); } DOMUtil.serializeNode(sm.getSOAPBody(), writer); writer.writeEndElement(); } writer.writeEndDocument(); writer.flush(); } catch (SOAPException ex) { throw new XMLStreamException2(ex); //for now. ask jaxws team what to do. } }
public void writeTo(XMLStreamWriter writer) throws XMLStreamException { try { writer.writeStartDocument(); if (!parsedMessage) { DOMUtil.serializeNode(sm.getSOAPPart().getEnvelope(), writer); } else { SOAPEnvelope env = sm.getSOAPPart().getEnvelope(); DOMUtil.writeTagWithAttributes(env, writer); if (hasHeaders()) { if(env.getHeader() != null) { DOMUtil.writeTagWithAttributes(env.getHeader(), writer); } else { writer.writeStartElement(env.getPrefix(), "Header", env.getNamespaceURI()); } for (Header h : headers.asList()) { h.writeTo(writer); } writer.writeEndElement(); } DOMUtil.serializeNode(sm.getSOAPBody(), writer); writer.writeEndElement(); } writer.writeEndDocument(); writer.flush(); } catch (SOAPException ex) { throw new XMLStreamException2(ex); //for now. ask jaxws team what to do. } }
public void writeTo(XMLStreamWriter writer) throws XMLStreamException { try { writer.writeStartDocument(); if (!parsedMessage) { DOMUtil.serializeNode(sm.getSOAPPart().getEnvelope(), writer); } else { SOAPEnvelope env = sm.getSOAPPart().getEnvelope(); DOMUtil.writeTagWithAttributes(env, writer); if (hasHeaders()) { if(env.getHeader() != null) { DOMUtil.writeTagWithAttributes(env.getHeader(), writer); } else { writer.writeStartElement(env.getPrefix(), "Header", env.getNamespaceURI()); } for (Header h : headers.asList()) { h.writeTo(writer); } writer.writeEndElement(); } DOMUtil.serializeNode(sm.getSOAPBody(), writer); writer.writeEndElement(); } writer.writeEndDocument(); writer.flush(); } catch (SOAPException ex) { throw new XMLStreamException2(ex); //for now. ask jaxws team what to do. } }
if (env.getNamespaceURI(Constants.NS_PREFIX_ADDRESSING) == null) { env.addNamespaceDeclaration(Constants.NS_PREFIX_ADDRESSING, version.getNamespace());