use of com.sun.xml.ws.api.pipe.Codec in project metro-jax-ws by eclipse-ee4j.
the class StreamMessageTest method useStreamCodec.
private StreamMessage useStreamCodec(String msg) throws IOException {
Codec codec = Codecs.createSOAPEnvelopeXmlCodec(SOAPVersion.SOAP_11);
Packet packet = new Packet();
ByteArrayInputStream in = new ByteArrayInputStream(msg.getBytes());
codec.decode(in, "text/xml", packet);
return (StreamMessage) packet.getInternalMessage();
}
use of com.sun.xml.ws.api.pipe.Codec in project metro-jax-ws by eclipse-ee4j.
the class AbstractServerAsyncTransport method handle.
/**
* Reads and decodes infoset from the connection and invokes the endpoints. The
* response is encoded and written to the connection. The response could be
* written using a different thread.
*
* @param connection that carries the web service request
* @throws IOException if an i/o error happens while encoding/decoding
*/
protected void handle(final T connection) throws IOException {
final Codec codec = codecPool.take();
Packet request = decodePacket(connection, codec);
if (!request.getMessage().isFault()) {
endpoint.schedule(request, new WSEndpoint.CompletionCallback() {
public void onCompletion(@NotNull Packet response) {
try {
encodePacket(connection, response, codec);
} catch (IOException ioe) {
ioe.printStackTrace();
}
codecPool.recycle(codec);
}
});
}
}
use of com.sun.xml.ws.api.pipe.Codec in project metro-jax-ws by eclipse-ee4j.
the class MimeCodec method getStaticContentType.
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();
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;
}
}
use of com.sun.xml.ws.api.pipe.Codec in project metro-jax-ws by eclipse-ee4j.
the class StreamMessageTester method useStreamCodec.
/**
* Test to see if ns declarations on soap envelope are captured on to the headers after parsing.
*
* @throws Exception
*/
/* This test has been moved to jaxws-unit harness to use tag 2.1.5
public void testHeadersInStreamMessage() throws Exception {
String requestStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:user=\"http://foo.bar\">" +
"<S:Header>" +
"<user:foo>bar</user:foo>" +
"</S:Header>" +
"<S:Body>" +
"<addNumbers xmlns=\"http://example.com/\">" +
"<number1>10</number1>" +
"<number2>10</number2>" +
"</addNumbers>" +
"</S:Body></S:Envelope>";
Message message = useStreamCodec(requestStr);
HeaderList hl = message.getHeaders();
ByteArrayBuffer baos = new ByteArrayBuffer();
XMLStreamWriter writer = XMLStreamWriterFactory.create(baos);
writer.writeStartDocument();
for(Header h: hl) {
h.writeTo(writer);
}
writer.writeEndDocument();
writer.flush();
//baos.writeTo(System.out);
XMLInputFactory readerFactory = XMLInputFactory.newInstance();
XMLStreamReader reader = readerFactory.createXMLStreamReader(baos.newInputStream());
reader.next();// go to start element
Header h = Headers.create(SOAPVersion.SOAP_11,reader);
assertEquals(h.getNamespaceURI(),"http://foo.bar");
}
*/
Message useStreamCodec(String msg) throws IOException {
Codec codec = Codecs.createSOAPEnvelopeXmlCodec(SOAPVersion.SOAP_11);
Packet packet = new Packet();
ByteArrayInputStream in = new ByteArrayInputStream(msg.getBytes());
codec.decode(in, "text/xml", packet);
return packet.getMessage();
}
use of com.sun.xml.ws.api.pipe.Codec in project metro-jax-ws by eclipse-ee4j.
the class ReferenceParametersTest method useStream12Codec.
Message useStream12Codec(String msg) throws IOException {
Codec codec = Codecs.createSOAPEnvelopeXmlCodec(SOAPVersion.SOAP_12);
Packet packet = new Packet();
ByteArrayInputStream in = new ByteArrayInputStream(msg.getBytes());
codec.decode(in, "application/soap+xml", packet);
return packet.getMessage();
}
Aggregations