Java Code Examples for com.sun.xml.internal.ws.api.SOAPVersion

The following examples show how to use com.sun.xml.internal.ws.api.SOAPVersion. These examples are extracted from open source projects. 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 Project: openjdk-8   Source File: DispatchImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void dumpParam(T param, String method) {
  if (param instanceof Packet) {
    Packet message = (Packet)param;

    String action;
    String msgId;
    if (LOGGER.isLoggable(Level.FINE)) {
      AddressingVersion av = DispatchImpl.this.getBinding().getAddressingVersion();
      SOAPVersion sv = DispatchImpl.this.getBinding().getSOAPVersion();
      action =
        av != null && message.getMessage() != null ?
          AddressingUtils.getAction(message.getMessage().getHeaders(), av, sv) : null;
      msgId =
        av != null && message.getMessage() != null ?
          AddressingUtils.getMessageID(message.getMessage().getHeaders(), av, sv) : null;
      LOGGER.fine("In DispatchImpl." + method + " for message with action: " + action + " and msg ID: " + msgId + " msg: " + message.getMessage());

      if (message.getMessage() == null) {
        LOGGER.fine("Dispatching null message for action: " + action + " and msg ID: " + msgId);
      }
    }
  }
}
 
Example 2
@Override
public NextAction processRequest(Packet request) {
    if (isNoValidation() || !feature.isInbound() || !request.getMessage().hasPayload() || request.getMessage().isFault()) {
        return super.processRequest(request);
    }
    try {
        doProcess(request);
    } catch(SAXException se) {
        LOGGER.log(Level.WARNING, "Client Request doesn't pass Service's Schema Validation", se);
        // Client request is invalid. So sending specific fault code
        // Also converting this to fault message so that handlers may get
        // to see the message.
        SOAPVersion soapVersion = binding.getSOAPVersion();
        Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(
                soapVersion, null, se, soapVersion.faultCodeClient);
        return doReturnWith(request.createServerResponse(faultMsg,
                wsdlPort, seiModel, binding));
    }
    return super.processRequest(request);
}
 
Example 3
@Override
public Packet createServiceResponseForException(final ThrowableContainerPropertySet tc,
                                                final Packet      responsePacket,
                                                final SOAPVersion soapVersion,
                                                final WSDLPort    wsdlPort,
                                                final SEIModel    seiModel,
                                                final WSBinding   binding)
{
    // This will happen in addressing if it is enabled.
    if (tc.isFaultCreated()) return responsePacket;

    final Message faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, tc.getThrowable());
    final Packet result = responsePacket.createServerResponse(faultMessage, wsdlPort, seiModel, binding);
    // Pass info to upper layers
    tc.setFaultMessage(faultMessage);
    tc.setResponsePacket(responsePacket);
    tc.setFaultCreated(true);
    return result;
}
 
Example 4
public Object[] getHeaders(QName header, JAXBContext jaxbContext, boolean allRoles) {
    SOAPVersion soapVersion = binding.getSOAPVersion();

    List<Object> beanList = new ArrayList<Object>();
    try {
        Iterator<Header> itr = packet.getMessage().getHeaders().getHeaders(header,false);
        if(allRoles) {
            while(itr.hasNext()) {
                beanList.add(itr.next().readAsJAXB(jaxbContext.createUnmarshaller()));
            }
        } else {
            while(itr.hasNext()) {
                Header soapHeader = itr.next();
                //Check if the role is one of the roles on this Binding
                String role = soapHeader.getRole(soapVersion);
                if(getRoles().contains(role)) {
                    beanList.add(soapHeader.readAsJAXB(jaxbContext.createUnmarshaller()));
                }
            }
        }
        return beanList.toArray();
    } catch(Exception e) {
        throw new WebServiceException(e);
    }
}
 
Example 5
Source Project: openjdk-jdk8u   Source File: WSEndpointImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public Packet createServiceResponseForException(final ThrowableContainerPropertySet tc,
                                                final Packet      responsePacket,
                                                final SOAPVersion soapVersion,
                                                final WSDLPort    wsdlPort,
                                                final SEIModel    seiModel,
                                                final WSBinding   binding)
{
    // This will happen in addressing if it is enabled.
    if (tc.isFaultCreated()) return responsePacket;

    final Message faultMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, tc.getThrowable());
    final Packet result = responsePacket.createServerResponse(faultMessage, wsdlPort, seiModel, binding);
    // Pass info to upper layers
    tc.setFaultMessage(faultMessage);
    tc.setResponsePacket(responsePacket);
    tc.setFaultCreated(true);
    return result;
}
 
Example 6
private static String getMustUnderstandLiteral(SOAPVersion sv) {
    if(sv == SOAPVersion.SOAP_12) {
        return S12_MUST_UNDERSTAND_TRUE;
    } else {
        return S11_MUST_UNDERSTAND_TRUE;
    }

}
 
Example 7
private static BindingID createBindingId(String transport, SOAPVersion soapVersion) {
    if (!transport.equals(SOAPConstants.URI_SOAP_TRANSPORT_HTTP)) {
        for( BindingIDFactory f : ServiceFinder.find(BindingIDFactory.class) ) {
            BindingID bindingId = f.create(transport, soapVersion);
            if(bindingId!=null) {
                return bindingId;
            }
        }
    }
    return soapVersion.equals(SOAPVersion.SOAP_11)?BindingID.SOAP11_HTTP:BindingID.SOAP12_HTTP;
}
 
Example 8
/**
 * 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 static SOAPMessage read(SOAPVersion soapVersion, Message message) throws SOAPException {
        for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
                SOAPMessage msg = s.readAsSOAPMessage(soapVersion, message);
                if (msg != null)
                        return msg;
        }

return instance.readAsSOAPMessage(soapVersion, message);
}
 
Example 9
/**
 * Creates a {@link EndpointResponseMessageBuilder} from a {@link WrapperParameter}.
 */
public DocLit(WrapperParameter wp, SOAPVersion soapVersion) {
    super(wp, soapVersion);
    bindingContext = wp.getOwner().getBindingContext();
    wrapper = (Class)wp.getXMLBridge().getTypeInfo().type;
    dynamicWrapper = WrapperComposite.class.equals(wrapper);
    children = wp.getWrapperChildren();
    parameterBridges = new XMLBridge[children.size()];
    accessors = new PropertyAccessor[children.size()];
    for( int i=0; i<accessors.length; i++ ) {
        ParameterImpl p = children.get(i);
        QName name = p.getName();
        if (dynamicWrapper) {
            parameterBridges[i] = children.get(i).getInlinedRepeatedElementBridge();
            if (parameterBridges[i] == null) parameterBridges[i] = children.get(i).getXMLBridge();
        } else {
            try {
                accessors[i] = (dynamicWrapper) ? null :
                    p.getOwner().getBindingContext().getElementPropertyAccessor(
                    wrapper, name.getNamespaceURI(), name.getLocalPart() );
            } catch (JAXBException e) {
                throw new WebServiceException(  // TODO: i18n
                    wrapper+" do not have a property of the name "+name,e);
            }
        }
    }

}
 
Example 10
@Deprecated
public static MessageContext create(final Source m, final SOAPVersion v, final ClassLoader... classLoader) {
    return serviceFinder(classLoader,
                         new Creator() {
                             public MessageContext create(final MessageContextFactory f) {
                                 return f.doCreate(m, v);
                             }
                         });
}
 
Example 11
Source Project: jdk8u60   Source File: StreamSOAPCodec.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new {@link StreamSOAPCodec} instance using binding
 *
 * @deprecated use {@link #create(WSFeatureList)}
 */
public static StreamSOAPCodec create(WSBinding binding) {
    SOAPVersion version = binding.getSOAPVersion();
    if(version==null)
        // this decoder is for SOAP, not for XML/HTTP
        throw new IllegalArgumentException();
    switch(version) {
        case SOAP_11:
            return new StreamSOAP11Codec(binding);
        case SOAP_12:
            return new StreamSOAP12Codec(binding);
        default:
            throw new AssertionError();
    }
}
 
Example 12
public boolean isIgnorable(@NotNull SOAPVersion soapVersion, @NotNull Set<String> roles) {
    // check mustUnderstand
    String v = getAttribute(soapVersion.nsUri, "mustUnderstand");
    if(v==null || !parseBool(v)) return true;

    if (roles == null) return true;

    // now role
    return !roles.contains(getRole(soapVersion));
}
 
Example 13
Source Project: jdk8u60   Source File: StringHeader.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static String getMustUnderstandLiteral(SOAPVersion sv) {
    if(sv == SOAPVersion.SOAP_12) {
        return S12_MUST_UNDERSTAND_TRUE;
    } else {
        return S11_MUST_UNDERSTAND_TRUE;
    }

}
 
Example 14
Source Project: openjdk-8   Source File: JAXBMessage.java    License: GNU General Public License v2.0 5 votes vote down vote up
private JAXBMessage(XMLBridge bridge, Object jaxbObject, SOAPVersion soapVer) {
    super(soapVer);
    // TODO: think about a better way to handle BridgeContext
    this.bridge = bridge;
    this.rawContext = null;
    this.jaxbObject = jaxbObject;
    QName tagName = bridge.getTypeInfo().tagName;
    this.nsUri = tagName.getNamespaceURI();
    this.localName = tagName.getLocalPart();
    this.attachmentSet = new AttachmentSetImpl();
}
 
Example 15
private JAXBMessage( BindingContext context, Object jaxbObject, SOAPVersion soapVer, MessageHeaders headers, AttachmentSet attachments ) {
        super(soapVer);
//        this.bridge = new MarshallerBridge(context);
        this.bridge = context.createFragmentBridge();
        this.rawContext = null;
        this.jaxbObject = jaxbObject;
        this.headers = headers;
        this.attachmentSet = attachments;
    }
 
Example 16
Source Project: hottub   Source File: WSEndpointMOMProxy.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Packet createServiceResponseForException(final ThrowableContainerPropertySet tc,
                                                final Packet      responsePacket,
                                                final SOAPVersion soapVersion,
                                                final WSDLPort    wsdlPort,
                                                final SEIModel    seiModel,
                                                final WSBinding   binding)
{
    return wsEndpoint.createServiceResponseForException(tc, responsePacket, soapVersion,
                                                        wsdlPort, seiModel, binding);
}
 
Example 17
static ProviderArgumentsBuilder create(ProviderEndpointModel model, SOAPVersion soapVersion) {
    if (model.mode == Service.Mode.PAYLOAD) {
        return new PayloadSource(soapVersion);
    } else {
        if(model.datatype==Source.class)
            return new MessageSource(soapVersion);
        if(model.datatype==SOAPMessage.class)
            return new SOAPMessageParameter(soapVersion);
        if(model.datatype==Message.class)
            return new MessageProviderArgumentBuilder(soapVersion);
        throw new WebServiceException(ServerMessages.PROVIDER_INVALID_PARAMETER_TYPE(model.implClass,model.datatype));
    }
}
 
Example 18
Source Project: openjdk-8   Source File: Message.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retuns a unique id for the message.
 * <p><p>
 * @see {@link #getID(com.sun.xml.internal.ws.api.WSBinding)} for detailed description.
 * @param av WS-Addressing version
 * @param sv SOAP version
 * @return unique id for the message
 * @deprecated
 */
public @NotNull String getID(AddressingVersion av, SOAPVersion sv) {
    String uuid = null;
    if (av != null) {
        uuid = AddressingUtils.getMessageID(getHeaders(), av, sv);
    }
    if (uuid == null) {
        uuid = generateMessageID();
        getHeaders().add(new StringHeader(av.messageIDTag, uuid));
    }
    return uuid;
}
 
Example 19
Source Project: hottub   Source File: HeaderList.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Set<QName> getNotUnderstoodHeaders(Set<String> roles, Set<QName> knownHeaders, WSBinding binding) {
    Set<QName> notUnderstoodHeaders = null;
    if (roles == null) {
        roles = new HashSet<String>();
    }
    SOAPVersion effectiveSoapVersion = getEffectiveSOAPVersion(binding);
    roles.add(effectiveSoapVersion.implicitRole);
    for (int i = 0; i < size(); i++) {
        if (!isUnderstood(i)) {
            Header header = get(i);
            if (!header.isIgnorable(effectiveSoapVersion, roles)) {
                QName qName = new QName(header.getNamespaceURI(), header.getLocalPart());
                if (binding == null) {
                    //if binding is null, no further checks needed...we already
                    //know this header is not understood from the isUnderstood
                    //check above
                    if (notUnderstoodHeaders == null) {
                        notUnderstoodHeaders = new HashSet<QName>();
                    }
                    notUnderstoodHeaders.add(qName);
                } else {
                    // if the binding is not null, see if the binding can understand it
                    if (binding instanceof SOAPBindingImpl && !((SOAPBindingImpl) binding).understandsHeader(qName)) {
                        if (!knownHeaders.contains(qName)) {
                            //logger.info("Element not understood=" + qName);
                            if (notUnderstoodHeaders == null) {
                                notUnderstoodHeaders = new HashSet<QName>();
                            }
                            notUnderstoodHeaders.add(qName);
                        }
                    }
                }
            }
        }
    }
    return notUnderstoodHeaders;
}
 
Example 20
/**
 * Creates a {@link EndpointResponseMessageBuilder} from a {@link WrapperParameter}.
 */
public RpcLit(WrapperParameter wp, SOAPVersion soapVersion) {
    super(wp, soapVersion);
    // we'll use CompositeStructure to pack requests
    assert wp.getTypeInfo().type==WrapperComposite.class;

    parameterBridges = new XMLBridge[children.size()];
    for( int i=0; i<parameterBridges.length; i++ )
        parameterBridges[i] = children.get(i).getXMLBridge();
}
 
Example 21
Source Project: openjdk-jdk9   Source File: ResponseBuilder.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Header(SOAPVersion soapVersion, ParameterImpl param, ValueSetter setter) {
    this(soapVersion,
        param.getTypeInfo().tagName,
        param.getXMLBridge(),
        setter);
    assert param.getOutBinding()== ParameterBinding.HEADER;
}
 
Example 22
public static Header getFirstHeader(MessageHeaders headers, QName name, boolean markUnderstood, SOAPVersion sv) {
    if (sv == null) {
        throw new IllegalArgumentException(AddressingMessages.NULL_SOAP_VERSION());
    }

    Iterator<Header> iter = headers.getHeaders(name.getNamespaceURI(), name.getLocalPart(), markUnderstood);
    while (iter.hasNext()) {
        Header h = iter.next();
        if (h.getRole(sv).equals(sv.implicitRole)) {
            return h;
        }
    }

    return null;
}
 
Example 23
@Test
public void testResetDefaultNamespaceSAAJ() throws Exception {
    // Create SOAP message from XML string and process it with SAAJ reader
    XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader(
            new StringReader(INPUT_SOAP_MESSAGE));
    StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11,
            envelope, null);
    SAAJFactory saajFact = new SAAJFactory();
    SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage);

    // Check if constructed object model meets local names and namespace expectations
    SOAPElement request = (SOAPElement) soapMessage.getSOAPBody().getFirstChild();
    // Check top body element name
    Assert.assertEquals(request.getLocalName(), "SampleServiceRequest");
    // Check top body element namespace
    Assert.assertEquals(request.getNamespaceURI(), TEST_NS);
    SOAPElement params = (SOAPElement) request.getFirstChild();
    // Check first child name
    Assert.assertEquals(params.getLocalName(), "RequestParams");
    // Check if first child namespace is null
    Assert.assertNull(params.getNamespaceURI());

    // Check inner elements of the first child
    SOAPElement param1 = (SOAPElement) params.getFirstChild();
    Assert.assertEquals(param1.getLocalName(), "Param1");
    Assert.assertNull(param1.getNamespaceURI());
    SOAPElement param2 = (SOAPElement) params.getChildNodes().item(1);
    Assert.assertEquals(param2.getLocalName(), "Param2");
    Assert.assertNull(param2.getNamespaceURI());
    // Check full content of SOAP body
    Assert.assertEquals(nodeToText(request), EXPECTED_RESULT);
}
 
Example 24
Source Project: openjdk-jdk9   Source File: SAAJFactory.java    License: 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, soapVersion.nsUri);
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 25
Source Project: openjdk-jdk8u   Source File: Headers.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new {@link Header} that reads from {@link XMLStreamReader}.
 *
 * <p>
 * Note that the header implementation will read the entire data
 * into memory anyway, so this might not be as efficient as you might hope.
 */
public static Header create( SOAPVersion soapVersion, XMLStreamReader reader ) throws XMLStreamException {
    switch(soapVersion) {
    case SOAP_11:
        return new StreamHeader11(reader);
    case SOAP_12:
        return new StreamHeader12(reader);
    default:
        throw new AssertionError();
    }
}
 
Example 26
Source Project: openjdk-jdk9   Source File: SAAJMessage.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This constructor is a convenience and called by the {@link #copy}
 *
 * @param headers
 * @param sm
 */
private SAAJMessage(MessageHeaders headers, AttachmentSet as, SOAPMessage sm, SOAPVersion version) {
    this.sm = sm;
    this.parse();
    if(headers == null)
        headers = new HeaderList(version);
    this.headers = headers;
    this.attachmentSet = as;
}
 
Example 27
private void init(@Nullable MessageHeaders headers, @NotNull AttachmentSet attachmentSet, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion) {
    this.headers = headers;
    this.attachmentSet = attachmentSet;
    this.reader = reader;

    if(reader.getEventType()== START_DOCUMENT)
        XMLStreamReaderUtil.nextElementContent(reader);

    //if the reader is pointing to the end element </soapenv:Body> then its empty message
    // or no payload
    if(reader.getEventType() == XMLStreamConstants.END_ELEMENT){
        String body = reader.getLocalName();
        String nsUri = reader.getNamespaceURI();
        assert body != null;
        assert nsUri != null;
        //if its not soapenv:Body then throw exception, we received malformed stream
        if(body.equals("Body") && nsUri.equals(soapVersion.nsUri)){
            this.payloadLocalName = null;
            this.payloadNamespaceURI = null;
        }else{ //TODO: i18n and also we should be throwing better message that this
            throw new WebServiceException("Malformed stream: {"+nsUri+"}"+body);
        }
    }else{
        this.payloadLocalName = reader.getLocalName();
        this.payloadNamespaceURI = reader.getNamespaceURI();
    }

    // use the default infoset representation for headers
    int base = soapVersion.ordinal()*3;
    this.envelopeTag = DEFAULT_TAGS.get(base);
    this.headerTag = DEFAULT_TAGS.get(base+1);
    this.bodyTag = DEFAULT_TAGS.get(base+2);
}
 
Example 28
Source Project: openjdk-8   Source File: StreamHeader.java    License: GNU General Public License v2.0 5 votes vote down vote up
public final boolean isIgnorable(@NotNull SOAPVersion soapVersion, @NotNull Set<String> roles) {
    // check mustUnderstand
    if(!_isMustUnderstand) return true;

    if (roles == null)
        return true;

    // now role
    return !roles.contains(_role);
}
 
Example 29
Source Project: openjdk-8   Source File: StreamSOAPCodec.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) {
    // Move to soap:Envelope and verify
    if(reader.getEventType()!=XMLStreamConstants.START_ELEMENT)
        XMLStreamReaderUtil.nextElementContent(reader);
    XMLStreamReaderUtil.verifyReaderState(reader,XMLStreamConstants.START_ELEMENT);
    if (SOAP_ENVELOPE.equals(reader.getLocalName()) && !soapVersion.nsUri.equals(reader.getNamespaceURI())) {
        throw new VersionMismatchException(soapVersion, soapVersion.nsUri, reader.getNamespaceURI());
    }
    XMLStreamReaderUtil.verifyTag(reader, soapVersion.nsUri, SOAP_ENVELOPE);
    return new StreamMessage(soapVersion, reader, attachmentSet);
}
 
Example 30
Source Project: jdk8u60   Source File: WSEndpoint.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is used by WsaServerTube and WSEndpointImpl to create a Packet with SOAPFault message from a Java exception.
 */
public abstract Packet createServiceResponseForException(final ThrowableContainerPropertySet tc,
                                                         final Packet      responsePacket,
                                                         final SOAPVersion soapVersion,
                                                         final WSDLPort    wsdlPort,
                                                         final SEIModel    seiModel,
                                                         final WSBinding   binding);