Thus I created the standalone server per: http://stackoverflow.com/questions/1792737/in-process-soap-service-server-for-java
basically set up the .java files per the answer and do:
C:\Work\Testing\java\webservices\standalone_ws>mkdir buildsvc
C:\Work\Testing\java\webservices\standalone_ws>javac -d buildsvc helloservice/endpoint/*java
C:\Work\Testing\java\webservices\standalone_ws>java -cp buildsvc helloservice.endpoint.Server
Starting Server
Server ready...
Then, create a client:
package simpleclient;
import helloservice.endpoint.*;
import javax.xml.ws.WebServiceRef;
import javax.xml.namespace.QName;
public class HelloClient {
@WebServiceRef(wsdlLocation="http://localhost:9000/SoapContext/SoapPort?WSDL")
static HelloService service;
public static void main(String[] args) {
try {
HelloClient client = new HelloClient();
client.doTest(args);
} catch(Exception e) {
e.printStackTrace();
}
}
public void doTest(String[] args) {
try {
QName qname = new QName("http://endpoint.helloservice/", "HelloService");
HelloService service = new HelloService(null, qname);
System.out.println("Retrieving the port from the following service: " + service);
Hello port = service.getHelloPort();
System.out.println("Invoking the sayHello operation on the port.");
String name;
if (args.length > 0) {
name = args[0];
} else {
name = "No Name";
}
String response = port.sayHello(name);
System.out.println(response);
} catch(Exception e) {
e.printStackTrace();
}
}
}
Test:
mkdir build
wsimport -d build -keep -verbose http://localhost:9000/SoapContext/SoapPort?WSDL
javac -cp build simpleclient/HelloClient.java
java -cp build;. simpleclient.HelloClient bah
Then to make things interesting and to see the full stack trace to see how the WebService annotation is processed on the server or at least for clues, change the sayHello method:
public String sayHello(String name) {
return message + name + "." + (1/(1-1));
}
to throw an ArithmeticException. Redo above steps and see the stacktrace coming from the cmd window for the running server:
Starting Server
Server ready...
Apr 23, 2014 10:42:41 PM com.sun.xml.internal.ws.server.sei.TieHandler createResponse
SEVERE: / by zero
java.lang.ArithmeticException: / by zero
at helloservice.endpoint.Hello.sayHello(Hello.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.xml.internal.ws.api.server.MethodUtil.invoke(Unknown Source)
at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.InvokerTube$2.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.sei.SEIInvokerTube.processRequest(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.AuthFilter.doFilter(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
From there you can go look up these methods on grepcode for OpenJDK and see what's actually happening.
No comments:
Post a Comment