use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class HelloImpl method validateDataHandler.
private void validateDataHandler(int expTotal, DataHandler dh) throws IOException {
// readOnce() doesn't store attachment on the disk in some cases
// for e.g when only one attachment is in the message
StreamingDataHandler sdh = (StreamingDataHandler) dh;
InputStream in = sdh.readOnce();
byte[] buf = new byte[8192];
int total = 0;
int len;
while ((len = in.read(buf, 0, buf.length)) != -1) {
for (int i = 0; i < len; i++) {
if ((byte) ('A' + (total + i) % 26) != buf[i]) {
throw new WebServiceException("DataHandler data is different");
}
}
total += len;
if (total % (8192 * 250) == 0) {
System.out.println("Total so far=" + total);
}
}
in.close();
sdh.close();
if (total != expTotal) {
throw new WebServiceException("DataHandler data size is different");
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class HelloImpl method validateDataHandler.
private void validateDataHandler(int expTotal, DataHandler dh) throws IOException {
// readOnce() doesn't store attachment on the disk in some cases
// for e.g when only one attachment is in the message
StreamingDataHandler sdh = (StreamingDataHandler) dh;
InputStream in = sdh.readOnce();
byte[] buf = new byte[8192];
int total = 0;
int len;
while ((len = in.read(buf, 0, buf.length)) != -1) {
for (int i = 0; i < len; i++) {
if ((byte) ('A' + (total + i) % 26) != buf[i]) {
throw new WebServiceException("DataHandler data is different");
}
}
total += len;
if (total % (8192 * 250) == 0) {
System.out.println("Total so far=" + total);
}
}
in.close();
sdh.close();
if (total != expTotal) {
throw new WebServiceException("DataHandler data size is different");
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class XMLHTTPBindingCodec method transformDataSource.
public static DataSource transformDataSource(DataSource in, boolean isFastInfoset, boolean useFastInfoset, WSFeatureList f) {
try {
if (isFastInfoset && !useFastInfoset) {
// Convert from Fast Infoset to XML
Codec codec = new XMLHTTPBindingCodec(f);
Packet p = new Packet();
codec.decode(in.getInputStream(), in.getContentType(), p);
p.getMessage().getAttachments();
codec.getStaticContentType(p);
ByteArrayBuffer bos = new ByteArrayBuffer();
ContentType ct = codec.encode(p, bos);
return XMLMessage.createDataSource(ct.getContentType(), bos.newInputStream());
} else if (!isFastInfoset && useFastInfoset) {
// Convert from XML to Fast Infoset
Codec codec = new XMLHTTPBindingCodec(f);
Packet p = new Packet();
codec.decode(in.getInputStream(), in.getContentType(), p);
p.contentNegotiation = ContentNegotiation.optimistic;
p.getMessage().getAttachments();
codec.getStaticContentType(p);
ByteArrayBuffer bos = new ByteArrayBuffer();
com.sun.xml.ws.api.pipe.ContentType ct = codec.encode(p, bos);
return XMLMessage.createDataSource(ct.getContentType(), bos.newInputStream());
}
} catch (Exception ex) {
throw new WebServiceException(ex);
}
return in;
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class DatabindingFactoryImpl method loadPropertiesFile.
Properties loadPropertiesFile(String fileName) {
ClassLoader classLoader = classLoader();
Properties p = new Properties();
try {
InputStream is = null;
if (classLoader == null) {
is = ClassLoader.getSystemResourceAsStream(fileName);
} else {
is = classLoader.getResourceAsStream(fileName);
}
if (is != null) {
p.load(is);
}
} catch (Exception e) {
throw new WebServiceException(e);
}
return p;
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class DispatchHelloLiteralTest method kkktestHelloAsyncHandlerCancelInterruptJAXB.
/* public void testHelloAsyncHandlerCancelJAXB() {
JAXBContext jc = null;
Hello_Type hello = null;
try {
jc = createJAXBContext();
hello = new Hello_Type();
} catch (Exception jbe) {
jbe.printStackTrace();
}
try {
hello.setExtra("Test ");
hello.setArgument("Dispatch ");
Dispatch dispatch = getDispatchJAXB();
JAXBAsyncHandler handler = new JAXBAsyncHandler(hello);
Future result = dispatch.invokeAsync(hello, handler);
try {
System.out.println("Response retured to test Thread " + Thread.currentThread().getId());
System.out.println("Response " + result.getClass().getName());
} catch (Exception ex) {
ex.printStackTrace();
}
while (!result.isDone()) {
System.out.println("Not done");
result.cancel(false);
assertTrue(result.isCancelled());
System.out.println("Canceled result");
}
} catch (WebServiceException e) {
e.printStackTrace();
}
}
*/
public void kkktestHelloAsyncHandlerCancelInterruptJAXB() {
JAXBContext jc = null;
Hello_Type hello = null;
try {
jc = createJAXBContext();
hello = new Hello_Type();
} catch (Exception jbe) {
jbe.printStackTrace();
}
hello.setExtra("Test ");
hello.setArgument("Dispatch ");
Dispatch dispatch = getDispatchJAXB();
JAXBAsyncHandler handler = new JAXBAsyncHandler(hello);
Future result = dispatch.invokeAsync(hello, handler);
while (!result.isDone()) {
result.cancel(true);
assertTrue(result.isCancelled());
System.out.println("Cancel interupt passed");
}
}
Aggregations