【发布时间】:2011-04-22 17:56:51
【问题描述】:
我正在创建一个网络服务。我想知道如何声明参数类型并使用它 因为Java类型是不同的,例如。日期。我已经编写了客户端来使用 Java 中的 Web 服务,它工作正常,但我想知道我是否可以使用用其他语言编写的客户端来使用相同的 Web 服务。我给你一个我的网络服务的代码示例:
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.Endpoint;
@WebService
public class WiseQuoteServer {
@SOAPBinding(style = Style.RPC)
public String getQuote(String category) {
if (category.equals("fun")) {
return "5 is a sufficient approximation of infinity.";
}
if (category.equals("work")) {
return "Remember to enjoy life, even during difficult situatons.";
} else {
return "Becoming a master is relatively easily. Do something well and then continue to do it for the next 20 years";
}
}
public static void main(String[] args) {
WiseQuoteServer server = new WiseQuoteServer();
Endpoint endpoint = Endpoint.publish(
"http://localhost:9191/wisequotes", server);
}
}
【问题讨论】:
标签: java web-services arguments jax-ws