The simplest calling interface method of webservice (to provide ideas for beginners)

eclipse generated. This Baidu has a very detailed operation process (basically one-click generation)

Here is how to call the interface:

public static void main(String[] args){

public int checkPhoneStatus(String randomId, int phone)

throws RemoteException {

CallTncMytvSuperPkgServiceLocator Locator = null;

CallTncMytvSuperPkgPortBindingStub stub = null;

try {

// first new a xxLocator object

Locator = new CallTncMytvSuperPkgServiceLocator();

// Call the getXXPort() method of the xxLocator object to generate the xxBindingStub object

stub = (CallTncMytvSuperPkgPortBindingStub) Locator

.getCallTncMytvSuperPkgPort();

} catch (javax.xml.rpc.ServiceException e) {

e.printStackTrace();

}

// Then you can call each method in the interface through the stud object, checkStatus is the method of the interface

int result = stub.checkStatus(randomId, phone);

return result;

}

}

There is also a small case in my project:

public static String setSupervise(String str) throws RemoteException, ServiceException{
		
		SmsWsImplServiceLocator cc = new SmsWsImplServiceLocator();
		SmsWsImplServiceSoapBindingStub ss = (SmsWsImplServiceSoapBindingStub) cc.getSmsWsImplPort();
		String rr = ss.sendSmsServiceJ(str);
		return rr;
	}
	
	public String sendmessage(String phone,String content) throws RemoteException, ServiceException{
		Map<String, String> map = new HashMap<String, String>();
		map.put("fcode", null);
		map.put("userid", "t");
		map.put("pwd", "t");
		map.put("phone", phone);
		map.put("content", content);
		String str = JSONObject.fromObject(map).toString();
		System.out.println(str);
		String rr = setSupervise(str);
		System.out.println(rr);
		return rr;
	}

Hope this can give you an idea. 

======================

Creation is not easy, thank you for your support!

 

Guess you like

Origin blog.csdn.net/sinat_26494147/article/details/84940419