Package test;
Import Javax.jws.WebService;
@WebService Public
interface HelloWorld {public
string SayHello (string name);
}
Package test;
Import Javax.jws.WebService;
@WebService public
class Helloworldimpl implements HelloWorld {public
string SayHello (string name) {
System.out.println ("SayHello is called");
Return "Hello" +name;
}
}
Package test;
Import Org.apache.cxf.endpoint.Server;
Import Org.apache.cxf.jaxws.JaxWsServerFactoryBean;
public class Mainserver {public
static void Main (string[] args) {
Jaxwsserverfactorybean Factorybean = new Jaxw Sserverfactorybean ();
HelloWorld Hello = new Helloworldimpl ();
Factorybean.setservicebean (hello);
Factorybean.setserviceclass (helloworldimpl.class);
Factorybean.setaddress ("Http://127.0.0.1:8080/HelloWorld");
Server server = Factorybean.create ();
Server.start ();
}
}
Package test;
Import Org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
public class Helloworldclient {public
static void Main (string[] args) {
Jaxwsproxyfactorybean bean = new Jaxwspro Xyfactorybean ();
Bean.setaddress ("Http://127.0.0.1:8080/HelloWorld");
Bean.setserviceclass (helloworld.class);
HelloWorld world = (HelloWorld) bean.create ();
System.out.println (World.sayhello ("LCY"));
}
}
Note: Some of the online video examples give the Mainserver class inside only wrote Factorybean.setserviceclass (Helloworldimpl.class);
Should have been added to the front.
HelloWorld Hello = new Helloworldimpl ();
Factorybean.setservicebean (hello);
Otherwise it will be reported abnormal, abnormal situation see: http://topic.csdn.net/u/20110809/15/a39454e4-4c73-4ef6-9a34-5b30608eed4f.html?62533
Solve the problem from: http://www.opensourceforce.org/forum/viewthread.php?action=printable&tid=2613