@WebService(serviceName = "TestWsService",
targetNamespace = "http://xxxxxx.com/",
endpointInterface = "xxxxxxx")
public class TestWsServiceImpl implements TestWsService {
@Override
@DbLog(code = "test", name = "测试ws接口")
public String test(String param) {
System.out.println("入参:"+param);
return param;
}
}
@WebService(name = "TestWsService",
targetNamespace = "http:xxxx.com")
public interface TestWsService {
/**
* 保存物料信息
* @return
*/
@WebMethod
String test(String param);
}
消费webservice
// 创建客户端
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient("http://localhost:8080/except/webService/test?wsdl");
// 需要密码的情况需要加上用户名和密码
// client.getOutInterceptors().add(new ClientLoginInterceptor(USER_NAME,
// PASS_WORD));
Object[] objects = new Object[0];
try {
// invoke("方法名",参数1,参数2,参数3....);
objects = client.invoke("test", "hahhha");
return "返回数据:" + objects[0];
} catch (java.lang.Exception e) {
e.printStackTrace();
return "异常:" + e.getMessage();
}
来源:CSDN
作者:可口可乐的配方
链接:https://blog.csdn.net/weixin_41217938/article/details/103487189