use of com.sun.xml.ws.api.SOAPVersion in project metro-jax-ws by eclipse-ee4j.
the class DispatchImpl method dumpParam.
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);
}
}
}
}
use of com.sun.xml.ws.api.SOAPVersion in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageTest method testMtomAttachmentCid.
public void testMtomAttachmentCid() throws Exception {
String testMtomMessageReload_01 = "multipart/related;type=\"application/xop+xml\";boundary=\"----=_Part_0_1145105632.1353005695468\";start=\"<cbe648b3-2055-413e-b8ed-877cdf0f2477>\";start-info=\"text/xml\"";
MessageContext m1 = mcf.createContext(getResource("testMtomMessageReload_01.msg"), testMtomMessageReload_01);
Packet packet = (Packet) m1;
Message riMsg = packet.getInternalMessage();
// This will cause all the attachments to be created ...
// Iterator<Attachment> as = packet.getInternalMessage().getAttachments().iterator();
// SAAJFactory:
SOAPVersion soapVersion = packet.getMessage().getSOAPVersion();
SOAPMessage saajMsg = soapVersion.getMessageFactory().createMessage();
SaajStaxWriterEx writer = new SaajStaxWriterEx(saajMsg, soapVersion.nsUri);
try {
riMsg.writeTo(writer);
} catch (XMLStreamException e) {
throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
}
saajMsg = writer.getSOAPMessage();
int counter = 0;
String hredCid = null;
for (Attachment a : riMsg.getAttachments()) {
hredCid = ((StreamingDataHandler) a.asDataHandler()).getHrefCid();
counter++;
}
assertTrue(writer.ma.size() == counter);
AttachmentPart ap = null;
// for (Iterator<AttachmentPart> itr = saajMsg.getAttachments(); itr.hasNext(); ) {
// System.out.println("\r\n itr.next().getContentId() " + itr.next().getContentId() );
// }
StreamingDataHandler sdh = (StreamingDataHandler) writer.ma.get(0);
assertEquals(hredCid, sdh.getHrefCid());
}
use of com.sun.xml.ws.api.SOAPVersion in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageTest method testMtomAttachment.
public void testMtomAttachment() throws Exception {
String testMtomMessageReload_01 = "multipart/related;type=\"application/xop+xml\";boundary=\"----=_Part_0_1145105632.1353005695468\";start=\"<cbe648b3-2055-413e-b8ed-877cdf0f2477>\";start-info=\"text/xml\"";
MessageContext m1 = mcf.createContext(getResource("testMtomMessageReload_01.msg"), testMtomMessageReload_01);
Packet packet = (Packet) m1;
Message message = packet.getInternalMessage();
Iterator<Attachment> as = packet.getInternalMessage().getAttachments().iterator();
Attachment att = null;
int counter = 0;
String cid1 = null;
while (as.hasNext()) {
att = as.next();
cid1 = att.getContentId();
counter++;
}
assertTrue(counter == 1);
// SAAJFactory:
SOAPVersion soapVersion = packet.getMessage().getSOAPVersion();
SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
SaajStaxWriterEx writer = new SaajStaxWriterEx(msg, soapVersion.nsUri);
try {
message.writeTo(writer);
} catch (XMLStreamException e) {
throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
}
msg = writer.getSOAPMessage();
counter = 0;
String cid2 = null;
for (Attachment a : message.getAttachments()) {
counter++;
cid2 = a.getContentId();
}
assertTrue(writer.ma.size() == counter);
StreamingDataHandler sdh = (StreamingDataHandler) writer.ma.get(0);
assertEquals(cid1, sdh.getHrefCid());
assertEquals(cid2, sdh.getHrefCid());
}
use of com.sun.xml.ws.api.SOAPVersion in project metro-jax-ws by eclipse-ee4j.
the class HttpAdapter method encodePacket.
private void encodePacket(@NotNull Packet packet, @NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
if (isNonAnonymousUri(packet.endpointAddress) && packet.getMessage() != null) {
try {
// Message is targeted to non-anonymous response endpoint.
// After call to non-anonymous processor, typically, packet.getMessage() will be null
// however, processors could use this pattern to modify the response sent on the back-channel,
// e.g. send custom HTTP headers with the HTTP 202
packet = getNonAnonymousResponseProcessor().process(packet);
} catch (RuntimeException re) {
// if processing by NonAnonymousResponseProcessor fails, new SOAPFaultMessage is created to be sent
// to back-channel client
SOAPVersion soapVersion = packet.getBinding().getSOAPVersion();
Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, re);
packet = packet.createServerResponse(faultMsg, packet.endpoint.getPort(), null, packet.endpoint.getBinding());
}
}
if (con.isClosed()) {
// Connection is already closed
return;
}
Message responseMessage = packet.getMessage();
addStickyCookie(con);
addReplicaCookie(con, packet);
if (responseMessage == null) {
if (!con.isClosed()) {
// for example, 415 may have been set earlier for Unsupported Content-Type
if (con.getStatus() == 0) {
con.setStatus(WSHTTPConnection.ONEWAY);
}
OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);
if (dump || LOGGER.isLoggable(Level.FINER)) {
ByteArrayBuffer buf = new ByteArrayBuffer();
codec.encode(packet, buf);
dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
buf.writeTo(os);
} else {
codec.encode(packet, os);
}
// close the response channel now
try {
// no payload
os.close();
} catch (IOException e) {
throw new WebServiceException(e);
}
}
} else {
if (con.getStatus() == 0) {
// if the appliation didn't set the status code,
// set the default one.
con.setStatus(responseMessage.isFault() ? HttpURLConnection.HTTP_INTERNAL_ERROR : HttpURLConnection.HTTP_OK);
}
if (isClientErrorStatus(con.getStatus())) {
OutputStream os = con.getOutput();
if (dump || LOGGER.isLoggable(Level.FINER)) {
ByteArrayBuffer buf = new ByteArrayBuffer();
writeClientError(con.getStatus(), buf, packet);
dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
buf.writeTo(os);
} else {
writeClientError(con.getStatus(), os, packet);
}
os.close();
return;
}
ContentType contentType = codec.getStaticContentType(packet);
if (contentType != null) {
con.setContentTypeResponseHeader(contentType.getContentType());
OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);
if (dump || LOGGER.isLoggable(Level.FINER)) {
ByteArrayBuffer buf = new ByteArrayBuffer();
codec.encode(packet, buf);
dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
buf.writeTo(os);
} else {
codec.encode(packet, os);
}
os.close();
} else {
ByteArrayBuffer buf = new ByteArrayBuffer();
contentType = codec.encode(packet, buf);
con.setContentTypeResponseHeader(contentType.getContentType());
if (dump || LOGGER.isLoggable(Level.FINER)) {
dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
}
OutputStream os = con.getOutput();
buf.writeTo(os);
os.close();
}
}
}
use of com.sun.xml.ws.api.SOAPVersion in project metro-jax-ws by eclipse-ee4j.
the class DomUtilTester method getSOAPMessage.
public SOAPMessage getSOAPMessage(File f) throws Exception {
SOAPVersion version = SOAPVersion.SOAP_11;
if (f.getName().endsWith("_12.xml")) {
version = SOAPVersion.SOAP_12;
}
MessageFactory mf = version.saajMessageFactory;
SOAPMessage sm = mf.createMessage(null, new FileInputStream(f));
return sm;
}
Aggregations