Import Javax.jws.WebService; /** */@WebServicepublicinterface jobservice {public String getjob ();}
import Javax.jws.WebService; @WebService (Endpointinterface = "Com.oracle.ws.c.jobservice") // Set the service endpoint interface, specify the interface for external service public class jobserviceimpl implements Jobservice {@ Override public String Getjob () {return "Jee Research Engineer | Android Research Engineer | Database Engineer | front-end Engineer | Test Engineer | operations Engineer "; public void say () {System.out.println ( "Good morning!") ); }}
Import Javax.xml.ws.Endpoint; Public class Test { publicstaticvoid main (string[] args) { jobservice Jobservice=new Jobserviceimpl (); String address= "Http://127.0.0.1:9999/ws/jobservice"; Endpoint.publish (address, jobservice); System.out.println ("WSDL address:" +address+ "?) WSDL ");} }
Client
ImportCom.oracle.ws.c.jobservice;ImportCom.oracle.ws.c.jobserviceimplservice; Public classTest {/**Test WebService Publishing by implementing an interface **/ Public Static voidMain (string[] args) {jobserviceimplservice ws=NewJobserviceimplservice (); Jobservice Jobserviceimplport=Ws.getjobserviceimplport (); String Jobs=Jobserviceimplport.getjob (); //"Jee Research Engineer | Android Research Engineer | Database Engineer | front-end Engineer | Test Engineer | operations Engineer "String[] Jobarray=jobs.split ("\\|"); System.out.println (jobarray[2]); System.out.println (jobarray[0]); System.out.println (jobarray[3]);}}
Interface-oriented WebService publishing method