use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class DispatchHello method testNoParamHelloRequestResponseJAXB.
// todo:investigate failed assertion bad JAXB message should fail after invocation RemoteException?
/* public void testHelloResponseBadRequestResponseJAXB() throws Throwable {
JAXBContext jc = null;
NameType hello = null;
HelloResponse helloResult = null;
jc = createJAXBContext();
hello = new NameType();
helloResult = new HelloResponse();
try {
//no remote method
hello.getName().add("foo");
Dispatch dispatch = getDispatchJAXB();
Object result = dispatch.invoke(hello);
System.out.println(" testHelloResponseBadRequestResponseJAXB FAILED");
} catch (Exception e) {
try {
assertTrue(e instanceof SOAPFaultException);
//assertTrue(e.getCause() instanceof SOAPFaultException);
System.out.println(" testHelloResponseBadRequestResponseJAXB PASSED");
} catch (Exception ex){
System.out.println(" testHelloResponseBadRequestResponseJAXB FAILED");
}
}
}
*/
// todo:Investigate failed assertion invoking Result not request - expect remoteException w/SOAPFailtEx
/* public void testHelloResponseBad2RequestResponseJAXB() throws Throwable {
JAXBContext jc = null;
HelloResponse helloResult = null;
try {
jc = createJAXBContext();
helloResult = new HelloResponse();
} catch (Exception jbe) {
jbe.printStackTrace();
}
try {
helloResult.setExtra("Test ");
helloResult.setArgument("Dispatch ");
Dispatch dispatch = getDispatchJAXB();
Object result = dispatch.invoke(helloResult);
System.out.println(" testHelloResponseBadRequestResponseJAXB FAILED");
} catch (Exception e) {
try {
assertTrue(e instanceof SOAPFaultException);
//assertTrue(e.getCause() instanceof SOAPFaultException);
System.out.println(" testHelloResponseBad3RequestResponseJAXB PASSED");
} catch (Exception ex){
System.out.println(" testHelloResponseBadRequestResponseJAXB FAILED");
}
}
}
*/
public void testNoParamHelloRequestResponseJAXB() throws Throwable {
JAXBContext jc = null;
Hello_Type hello = null;
HelloResponse helloResult = null;
try {
jc = createJAXBContext();
hello = new Hello_Type();
helloResult = new HelloResponse();
} catch (Exception jbe) {
assertTrue(jbe instanceof JAXBException);
}
try {
// no hello args
Dispatch dispatch = getDispatchJAXB();
Object result = dispatch.invoke(null);
assertTrue(result == null);
// System.out.println("NoParamHelloRequestResponseJAXB FAILED");
} catch (Exception e) {
assertTrue(e instanceof SOAPFaultException);
System.out.println("no param result is " + e.getClass().getName());
// assertTrue(e instanceof WebServiceException);
System.out.println("NoParamHelloRequestResponseJAXB PASSED");
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class DispatchHello method testHelloRequestResponseJAXBWPorts.
public void testHelloRequestResponseJAXBWPorts() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("http transport only exiting");
return;
}
JAXBContext jc = null;
HelloResponse result = null;
Hello_Type hello = new Hello_Type();
jc = createJAXBContext();
try {
hello.setArgument("foo");
hello.setExtra("Test ");
Dispatch dispatch = getDispatchJAXBWithPorts();
result = (HelloResponse) dispatch.invoke(hello);
assertEquals(((HelloResponse) result).getExtra(), hello.getExtra());
assertEquals(((HelloResponse) result).getArgument(), hello.getArgument());
} catch (WebServiceException jex) {
fail("testHelloRequestResponseJAXB FAILED");
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class DispatchHello method testHelloRequestResponseJAXBPortsAvailable.
public void testHelloRequestResponseJAXBPortsAvailable() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("http transport only exiting");
return;
}
JAXBContext jc = null;
HelloResponse helloResult = null;
Hello_Type hello = new Hello_Type();
jc = createJAXBContext();
try {
hello.setArgument("foo");
hello.setExtra("Test ");
Dispatch dispatch = getDispatchJAXBWithPorts();
Object result = dispatch.invoke(hello);
assertEquals(((HelloResponse) result).getExtra(), hello.getExtra());
assertEquals(((HelloResponse) result).getArgument(), hello.getArgument());
} catch (WebServiceException jex) {
fail("testHelloRequestResponseJAXB FAILED");
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class DispatchHello method xxtestHelloRequestResponseJAXBWPorts.
public void xxtestHelloRequestResponseJAXBWPorts() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("http transport only exiting");
return;
}
JAXBContext jc = null;
HelloResponse result = null;
Hello_Type hello = new Hello_Type();
jc = createJAXBContext();
try {
hello.setArgument("foo");
hello.setExtra("Test ");
Dispatch dispatch = getDispatchJAXBWithPorts();
result = (HelloResponse) dispatch.invoke(hello);
assertEquals(((HelloResponse) result).getExtra(), hello.getExtra());
assertEquals(((HelloResponse) result).getArgument(), hello.getArgument());
} catch (WebServiceException jex) {
fail("testHelloRequestResponseJAXB FAILED");
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class HelloAsyncImpl method invoke.
@Override
public void invoke(Source source, AsyncProviderCallback<Source> cbak, WebServiceContext ctxt) {
System.out.println("**** Received in AsyncProvider Impl ******");
try {
Hello_Type hello = recvBean(source);
String arg = hello.getArgument();
if (arg.equals("sync")) {
String extra = hello.getExtra();
if (extra.equals("source")) {
cbak.send(sendSource());
} else if (extra.equals("bean")) {
cbak.send(sendBean());
} else {
throw new WebServiceException("Expected extra = (source|bean|fault), Got=" + extra);
}
} else if (arg.equals("async")) {
new Thread(new RequestHandler(cbak, hello)).start();
} else {
throw new WebServiceException("Expected Argument = (sync|async), Got=" + arg);
}
} catch (Exception e) {
throw new WebServiceException("Endpoint failed", e);
}
}
Aggregations