com.sun.xml.internal.ws.api.message.Message Java Examples

The following examples show how to use com.sun.xml.internal.ws.api.message.Message. 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: WSEndpointImpl.java    From hottub with 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 #2
Source File: MimeCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public ContentType getStaticContentType(Packet packet) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;
    Message msg = packet.getMessage();
    boolean hasAttachments = !msg.getAttachments().isEmpty();
    Codec rootCodec = getMimeRootCodec(packet);

    if (hasAttachments) {
        String boundary = "uuid:" + UUID.randomUUID().toString();
        String boundaryParameter = "boundary=\"" + boundary + "\"";
        // TODO use primaryEncoder to get type
        String messageContentType =  MULTIPART_RELATED_MIME_TYPE +
                "; type=\"" + rootCodec.getMimeType() + "\"; " +
                boundaryParameter;
        ContentTypeImpl impl = new ContentTypeImpl(messageContentType, packet.soapAction, null);
        impl.setBoundary(boundary);
        impl.setBoundaryParameter(boundaryParameter);
        packet.setContentType(impl);
        return impl;
    } else {
        ct = rootCodec.getStaticContentType(packet);
        packet.setContentType(ct);
        return ct;
    }
}
 
Example #3
Source File: MUTube.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This should be used only in ServerMUPipe
 *
 * @param notUnderstoodHeaders
 * @return Message representing a SOAPFault
 *         In SOAP 1.1, notUnderstoodHeaders are added in the fault Detail
 *         in SOAP 1.2, notUnderstoodHeaders are added as the SOAP Headers
 */

final Message createMUSOAPFaultMessage(Set<QName> notUnderstoodHeaders) {
    try {
        String faultString = MUST_UNDERSTAND_FAULT_MESSAGE_STRING;
        if (soapVersion == SOAP_11) {
            faultString = "MustUnderstand headers:" + notUnderstoodHeaders + " are not understood";
        }
        Message  muFaultMessage = SOAPFaultBuilder.createSOAPFaultMessage(
                soapVersion,faultString,soapVersion.faultCodeMustUnderstand);

        if (soapVersion == SOAP_12) {
            addHeader(muFaultMessage, notUnderstoodHeaders);
        }
        return muFaultMessage;
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example #4
Source File: ServerSchemaValidationTube.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@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 #5
Source File: PayloadQNameBasedOperationFinder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
     *
     * @return not null if it finds a unique handler for the request
     *         null if it cannot idenitify a unique wsdl operation from the Payload QName.
     *
     * @throws DispatchException if the payload itself is incorrect, this happens when the payload is not accepted by
     *          any operation in the port.
     */
//  public QName getWSDLOperationQName(Packet request) throws DispatchException{

    public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
        Message message = request.getMessage();
        String localPart = message.getPayloadLocalPart();
        String nsUri;
        if (localPart == null) {
            localPart = EMPTY_PAYLOAD_LOCAL;
            nsUri = EMPTY_PAYLOAD_NSURI;
        } else {
            nsUri = message.getPayloadNamespaceURI();
            if(nsUri == null)
                nsUri = EMPTY_PAYLOAD_NSURI;
        }
        WSDLOperationMapping op = methodHandlers.get(nsUri, localPart);

        // Check if payload itself is correct. Usually it is, so let us check last
        if (op == null && !unique.containsKey(nsUri,localPart)) {
            String dispatchKey = "{" + nsUri + "}" + localPart;
            String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(dispatchKey);
            throw new DispatchException(SOAPFaultBuilder.createSOAPFaultMessage(
                 binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient));
        }
        return op;
    }
 
Example #6
Source File: Stubs.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
 
Example #7
Source File: WSEndpointImpl.java    From jdk8u60 with 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 #8
Source File: Stubs.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
 
Example #9
Source File: Stubs.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new {@link Dispatch} stub that connects to the given pipe.
 *
 * @param portInfo
 *      see <a href="#param">common parameters</a>
 * @param owner
 *      see <a href="#param">common parameters</a>
 * @param binding
 *      see <a href="#param">common parameters</a>
 * @param clazz
 *      Type of the {@link Dispatch} to be created.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param mode
 *      The mode of the dispatch.
 *      See {@link Service#createDispatch(QName, Class, Service.Mode)}.
 * @param epr
 *      see <a href="#param">common parameters</a>
 * TODO: are these parameters making sense?
 */
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
                                             WSService owner,
                                             WSBinding binding,
                                             Class<T> clazz, Service.Mode mode,
                                             @Nullable WSEndpointReference epr) {
    if (clazz == SOAPMessage.class) {
        return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Source.class) {
        return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == DataSource.class) {
        return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
    } else if (clazz == Message.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Message>");
    } else if (clazz == Packet.class) {
        if(mode==Mode.MESSAGE)
            return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
        else
            throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
    } else
        throw new WebServiceException("Unknown class type " + clazz.getName());
}
 
Example #10
Source File: FastInfosetCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    /* Implements similar logic as the XMLMessage.create(String, InputStream).
     * But it's faster, as we know the InputStream has FastInfoset content*/
    Message message;
    in = hasSomeData(in);
    if (in != null) {
        message = Messages.createUsingPayload(new FastInfosetSource(in),
                SOAPVersion.SOAP_11);
    } else {
        message = Messages.createEmpty(SOAPVersion.SOAP_11);
    }

    packet.setMessage(message);
}
 
Example #11
Source File: StreamSOAPCodec.java    From openjdk-jdk8u-backup with 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 #12
Source File: TieHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Message createResponse(JavaCallInfo call) {
        Message responseMessage;
        if (call.getException() == null) {
            responseMessage = isOneWay ? null : createResponseMessage(call.getParameters(), call.getReturnValue());
        } else {
            Throwable e = call.getException();
            Throwable serviceException = getServiceException(e);
            if (e instanceof InvocationTargetException || serviceException != null) {
//              Throwable cause = e.getCause();
              //if (!(cause instanceof RuntimeException) && cause instanceof Exception) {
                if (serviceException != null) {
                    // Service specific exception
                    LOGGER.log(Level.FINE, serviceException.getMessage(), serviceException);
                    responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion,
                            javaMethodModel.getCheckedException(serviceException.getClass()), serviceException);
                } else {
                    Throwable cause = e.getCause();
                    if (cause instanceof ProtocolException) {
                        // Application code may be throwing it intentionally
                        LOGGER.log(Level.FINE, cause.getMessage(), cause);
                    } else {
                        // Probably some bug in application code
                        LOGGER.log(Level.SEVERE, cause.getMessage(), cause);
                    }
                    responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, cause);
                }
            } else if (e instanceof DispatchException) {
                responseMessage = ((DispatchException)e).fault;
            } else {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
                responseMessage = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
            }
        }
//        return req.createServerResponse(responseMessage, req.endpoint.getPort(), javaMethodModel.getOwner(), req.endpoint.getBinding());

        return responseMessage;
    }
 
Example #13
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
 * @param packet The packet that owns the Message
 * @return Created SOAPMessage
 * @throws SOAPException if SAAJ processing fails
 */
public static SOAPMessage read(SOAPVersion soapVersion, Message message, Packet packet) throws SOAPException {
    for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
        SOAPMessage msg = s.readAsSOAPMessage(soapVersion, message, packet);
        if (msg != null)
            return msg;
    }

    return instance.readAsSOAPMessage(soapVersion, message, packet);
}
 
Example #14
Source File: SOAPSourceDispatch.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Source toReturnValue(Packet response) {
    Message msg = response.getMessage();

    switch (mode) {
    case PAYLOAD:
        return msg.readPayloadAsSource();
    case MESSAGE:
        return msg.readEnvelopeAsSource();
    default:
        throw new WebServiceException("Unrecognized dispatch mode");
    }
}
 
Example #15
Source File: SAAJFactory.java    From openjdk-jdk8u 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 #16
Source File: SOAPMessageContextImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPMessage getMessage() {
    if(soapMsg == null) {
        try {
            Message m = packet.getMessage();
            soapMsg = m != null ? m.readAsSOAPMessage() : null;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
    return soapMsg;
}
 
Example #17
Source File: AbstractMessageImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Message toSAAJ(Packet p, Boolean inbound) throws SOAPException {
    SAAJMessage message = SAAJFactory.read(p);
    if (message instanceof MessageWritable)
        ((MessageWritable) message)
                .setMTOMConfiguration(p.getMtomFeature());
    if (inbound != null) transportHeaders(p, inbound, message.readAsSOAPMessage());
    return message;
}
 
Example #18
Source File: TieHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a response {@link JAXBMessage} from method arguments, return value
 *
 * @return response message
 */
private Message createResponseMessage(Object[] args, Object returnValue) {
    Message msg = bodyBuilder.createMessage(args, returnValue);

    for (MessageFiller filler : outFillers)
        filler.fillIn(args, returnValue, msg);

    return msg;
}
 
Example #19
Source File: ResponseBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object readResponse(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    Object retVal = null;
    for (ResponseBuilder builder : builders) {
        Object r = builder.readResponse(msg,args);
        // there's only at most one ResponseBuilder that returns a value.
        if(r!=null) {
            assert retVal==null;
            retVal = r;
        }
    }
    return retVal;
}
 
Example #20
Source File: MessageFiller.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void fillIn(Object[] methodArgs, Object returnValue, Message msg) {
    String contentId = getContentId();
    Object obj = (methodPos == -1) ? returnValue : getter.get(methodArgs[methodPos]);
    if (obj != null) {
        Attachment att = new ByteArrayAttachment(contentId,(byte[])obj,mimeType);
        msg.getAttachments().add(att);
    }
}
 
Example #21
Source File: ResponseBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object readResponse(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    Object retVal = null;
    for (ResponseBuilder builder : builders) {
        Object r = builder.readResponse(msg,args);
        // there's only at most one ResponseBuilder that returns a value.
        if(r!=null) {
            assert retVal==null;
            retVal = r;
        }
    }
    return retVal;
}
 
Example #22
Source File: LogicalMessageContextImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void updateMessage() {
    //If LogicalMessage is not acccessed, its not modified.
    if(lm != null) {
        //Check if LogicalMessageImpl has changed, if so construct new one
        // Packet are handled through MessageContext
        if(lm.isPayloadModifed()){
            Message msg = packet.getMessage();
            Message updatedMsg = lm.getMessage(msg.getHeaders(),msg.getAttachments(),binding);
            packet.setMessage(updatedMsg);
        }
        lm = null;
    }

}
 
Example #23
Source File: SAAJFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static protected void addAttachmentsToSOAPMessage(SOAPMessage msg, Message message) {
    for(Attachment att : message.getAttachments()) {
        AttachmentPart part = msg.createAttachmentPart();
        part.setDataHandler(att.asDataHandler());

        // Be safe and avoid double angle-brackets.
        String cid = att.getContentId();
        if (cid != null) {
            if (cid.startsWith("<") && cid.endsWith(">"))
                part.setContentId(cid);
            else
                part.setContentId('<' + cid + '>');
        }

        // Add any MIME headers beside Content-ID, which is already
        // accounted for above, and Content-Type, which is provided
        // by the DataHandler above.
        if (att instanceof AttachmentEx) {
            AttachmentEx ax = (AttachmentEx) att;
            Iterator<AttachmentEx.MimeHeader> imh = ax.getMimeHeaders();
            while (imh.hasNext()) {
                AttachmentEx.MimeHeader ame = imh.next();
                if ((!"Content-ID".equals(ame.getName()))
                        && (!"Content-Type".equals(ame.getName())))
                    part.addMimeHeader(ame.getName(), ame.getValue());
            }
        }
        msg.addAttachmentPart(part);
    }
}
 
Example #24
Source File: ProviderArgumentsBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates {@link Packet} from method invocation's return value
 */
protected Packet getResponse(Packet request, @Nullable T returnValue, WSDLPort port, WSBinding binding) {
    Message message = null;
    if (returnValue != null) {
        message = getResponseMessage(returnValue);
    }
    Packet response = request.createServerResponse(message,port,null,binding);
    return response;
}
 
Example #25
Source File: StubHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public JavaCallInfo readResponse(Packet p, JavaCallInfo call) throws Throwable {
        Message msg = p.getMessage();
if(msg.isFault()) {
    SOAPFaultBuilder faultBuilder = SOAPFaultBuilder.create(msg);
    Throwable t = faultBuilder.createException(checkedExceptions);
    call.setException(t);
    throw t;
} else {
        initArgs(call.getParameters());
    Object ret = responseBuilder.readResponse(msg, call.getParameters());
    call.setReturnValue(ret);
    return call;
}
}
 
Example #26
Source File: StreamSOAPCodec.java    From openjdk-jdk8u with 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 #27
Source File: SAAJFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static protected void addAttachmentsToSOAPMessage(SOAPMessage msg, Message message) {
    for(Attachment att : message.getAttachments()) {
        AttachmentPart part = msg.createAttachmentPart();
        part.setDataHandler(att.asDataHandler());

        // Be safe and avoid double angle-brackets.
        String cid = att.getContentId();
        if (cid != null) {
            if (cid.startsWith("<") && cid.endsWith(">"))
                part.setContentId(cid);
            else
                part.setContentId('<' + cid + '>');
        }

        // Add any MIME headers beside Content-ID, which is already
        // accounted for above, and Content-Type, which is provided
        // by the DataHandler above.
        if (att instanceof AttachmentEx) {
            AttachmentEx ax = (AttachmentEx) att;
            Iterator<AttachmentEx.MimeHeader> imh = ax.getMimeHeaders();
            while (imh.hasNext()) {
                AttachmentEx.MimeHeader ame = imh.next();
                if ((!"Content-ID".equals(ame.getName()))
                        && (!"Content-Type".equals(ame.getName())))
                    part.addMimeHeader(ame.getName(), ame.getValue());
            }
        }
        msg.addAttachmentPart(part);
    }
}
 
Example #28
Source File: WSEndpointImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public @NotNull
PipeHead createPipeHead() {
    return new PipeHead() {
        private final Tube tube = TubeCloner.clone(masterTubeline);

        public @NotNull
        Packet process(Packet request, WebServiceContextDelegate wscd,
                TransportBackChannel tbc) {
            Container old = ContainerResolver.getDefault().enterContainer(container);
            try {
                request.webServiceContextDelegate = wscd;
                request.transportBackChannel = tbc;
                request.endpoint = WSEndpointImpl.this;
                request.addSatellite(wsdlProperties);

                Fiber fiber = engine.createFiber();
                Packet response;
                try {
                    response = fiber.runSync(tube, request);
                } catch (RuntimeException re) {
                    // Catch all runtime exceptions so that transport
                    // doesn't
                    // have to worry about converting to wire message
                    // TODO XML/HTTP binding
                    Message faultMsg = SOAPFaultBuilder
                            .createSOAPFaultMessage(soapVersion, null, re);
                    response = request.createServerResponse(faultMsg,
                            request.endpoint.getPort(), null,
                            request.endpoint.getBinding());
                }
                return response;
            } finally {
                ContainerResolver.getDefault().exitContainer(old);
            }
        }
    };
}
 
Example #29
Source File: SOAPMessageContextImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPMessage getMessage() {
    if(soapMsg == null) {
        try {
            Message m = packet.getMessage();
            soapMsg = m != null ? m.readAsSOAPMessage() : null;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
    return soapMsg;
}
 
Example #30
Source File: StubHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public JavaCallInfo readResponse(Packet p, JavaCallInfo call) throws Throwable {
        Message msg = p.getMessage();
if(msg.isFault()) {
    SOAPFaultBuilder faultBuilder = SOAPFaultBuilder.create(msg);
    Throwable t = faultBuilder.createException(checkedExceptions);
    call.setException(t);
    throw t;
} else {
        initArgs(call.getParameters());
    Object ret = responseBuilder.readResponse(msg, call.getParameters());
    call.setReturnValue(ret);
    return call;
}
}